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 --- .../org/pacien/tincapp/activities/StartActivity.kt | 16 ++++++++-------- .../org/pacien/tincapp/activities/StatusActivity.kt | 16 ++++++++-------- app/src/main/res/layout/fragment_list_item.xml | 1 - app/src/main/res/layout/fragment_list_view.xml | 16 ++++++++++++++++ app/src/main/res/layout/page_start.xml | 18 ------------------ app/src/main/res/layout/page_status.xml | 18 ------------------ 6 files changed, 32 insertions(+), 53 deletions(-) create mode 100644 app/src/main/res/layout/fragment_list_view.xml delete mode 100644 app/src/main/res/layout/page_start.xml delete mode 100644 app/src/main/res/layout/page_status.xml 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() } } diff --git a/app/src/main/res/layout/fragment_list_item.xml b/app/src/main/res/layout/fragment_list_item.xml index c6049f5..f872573 100644 --- a/app/src/main/res/layout/fragment_list_item.xml +++ b/app/src/main/res/layout/fragment_list_item.xml @@ -5,5 +5,4 @@ android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin"> - diff --git a/app/src/main/res/layout/fragment_list_view.xml b/app/src/main/res/layout/fragment_list_view.xml new file mode 100644 index 0000000..32e951e --- /dev/null +++ b/app/src/main/res/layout/fragment_list_view.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/app/src/main/res/layout/page_start.xml b/app/src/main/res/layout/page_start.xml deleted file mode 100644 index b1bf2a4..0000000 --- a/app/src/main/res/layout/page_start.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - diff --git a/app/src/main/res/layout/page_status.xml b/app/src/main/res/layout/page_status.xml deleted file mode 100644 index bc68ea1..0000000 --- a/app/src/main/res/layout/page_status.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - -- cgit v1.2.3