From 75fb7ba17f5977b146f166412eaf39705a5f4e73 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sat, 15 Jul 2017 11:53:43 +0200 Subject: Refactor common list views --- .../java/org/pacien/tincapp/activities/StartActivity.kt | 16 ++++++++-------- .../java/org/pacien/tincapp/activities/StatusActivity.kt | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt index 05f8904..6e8ad37 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt @@ -10,8 +10,8 @@ import android.widget.AdapterView import android.widget.ArrayAdapter import android.widget.TextView import kotlinx.android.synthetic.main.base.* +import kotlinx.android.synthetic.main.fragment_list_view.* import kotlinx.android.synthetic.main.fragment_network_list_header.* -import kotlinx.android.synthetic.main.page_start.* import org.pacien.tincapp.R import org.pacien.tincapp.context.AppPaths import org.pacien.tincapp.extensions.Android.setElements @@ -32,12 +32,12 @@ class StartActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRefr networkListAdapter = ArrayAdapter(this, R.layout.fragment_list_item) confChangeObserver = FileObserver(AppPaths.confDir().absolutePath, FileObserver.CHANGE, { _, _ -> onRefresh() }) - layoutInflater.inflate(R.layout.page_start, main_content) - network_list_wrapper.setOnRefreshListener(this) - network_list.addHeaderView(layoutInflater.inflate(R.layout.fragment_network_list_header, network_list, false), null, false) - network_list.addFooterView(View(this), null, false) - network_list.adapter = networkListAdapter - network_list.onItemClickListener = this + layoutInflater.inflate(R.layout.fragment_list_view, main_content) + list_wrapper.setOnRefreshListener(this) + list.addHeaderView(layoutInflater.inflate(R.layout.fragment_network_list_header, list, false), null, false) + list.addFooterView(View(this), null, false) + list.adapter = networkListAdapter + list.onItemClickListener = this } override fun onCreateOptionsMenu(m: Menu): Boolean { @@ -72,7 +72,7 @@ class StartActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRefr runOnUiThread { networkListAdapter?.setElements(networks) network_list_placeholder.visibility = if (networkListAdapter?.isEmpty ?: true) View.VISIBLE else View.GONE - network_list_wrapper.isRefreshing = false + list_wrapper.isRefreshing = false } } diff --git a/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt index 0d7af6e..6d97dca 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt @@ -13,8 +13,8 @@ import android.widget.TextView import java8.util.concurrent.CompletableFuture import kotlinx.android.synthetic.main.base.* import kotlinx.android.synthetic.main.dialog_text_monopsace.view.* +import kotlinx.android.synthetic.main.fragment_list_view.* import kotlinx.android.synthetic.main.fragment_network_status_header.* -import kotlinx.android.synthetic.main.page_status.* import org.pacien.tincapp.R import org.pacien.tincapp.commands.Tinc import org.pacien.tincapp.data.VpnInterfaceConfiguration @@ -39,12 +39,12 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef nodeListAdapter = ArrayAdapter(this, R.layout.fragment_list_item) refreshTimer = Timer(true) - layoutInflater.inflate(R.layout.page_status, main_content) - node_list_wrapper.setOnRefreshListener(this) - node_list.addHeaderView(layoutInflater.inflate(R.layout.fragment_network_status_header, node_list, false), null, false) - node_list.addFooterView(View(this), null, false) - node_list.onItemClickListener = this - node_list.adapter = nodeListAdapter + layoutInflater.inflate(R.layout.fragment_list_view, main_content) + list_wrapper.setOnRefreshListener(this) + list.addHeaderView(layoutInflater.inflate(R.layout.fragment_network_status_header, list, false), null, false) + list.addFooterView(View(this), null, false) + list.onItemClickListener = this + list.adapter = nodeListAdapter } override fun onCreateOptionsMenu(m: Menu): Boolean { @@ -82,7 +82,7 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef runOnUiThread { nodeListAdapter?.setElements(it) node_list_placeholder.visibility = if (nodeListAdapter?.isEmpty ?: true) View.VISIBLE else View.GONE - node_list_wrapper.isRefreshing = false + list_wrapper.isRefreshing = false if (!TincVpnService.isConnected()) openStartActivity() } } -- cgit v1.2.3