diff options
author | pacien | 2018-03-12 14:31:06 +0100 |
---|---|---|
committer | pacien | 2018-03-12 14:31:06 +0100 |
commit | 05857ad7d85ba73b3f67571f89e12f114874bc98 (patch) | |
tree | 521235199f40fe7169f5e0791d4acf6bfe2fe2bd /app/src/main | |
parent | 2e65d5773110f2a706fb3e270c90298d39e8626d (diff) | |
download | tincapp-05857ad7d85ba73b3f67571f89e12f114874bc98.tar.gz |
Check for activity termination before updating UI elements
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt | 4 | ||||
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt index 44f3210..ff5b930 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt | |||
@@ -41,6 +41,10 @@ abstract class BaseActivity : AppCompatActivity() { | |||
41 | .show() | 41 | .show() |
42 | } | 42 | } |
43 | 43 | ||
44 | fun runOnUiThread(action: () -> Unit) { | ||
45 | if (!isFinishing && !isDestroyed) super.runOnUiThread(action) | ||
46 | } | ||
47 | |||
44 | protected fun notify(@StringRes msg: Int) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() | 48 | protected fun notify(@StringRes msg: Int) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() |
45 | protected fun notify(msg: String) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() | 49 | protected fun notify(msg: String) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() |
46 | protected fun showProgressDialog(@StringRes msg: Int): ProgressDialog = ProgressDialog.show(this, null, getString(msg), true, false) | 50 | protected fun showProgressDialog(@StringRes msg: Int): ProgressDialog = ProgressDialog.show(this, null, getString(msg), true, 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 351305c..4206f7f 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt | |||
@@ -139,7 +139,7 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef | |||
139 | text_network_disallowed_applications.setText(cfg.disallowedApplications) | 139 | text_network_disallowed_applications.setText(cfg.disallowedApplications) |
140 | } | 140 | } |
141 | 141 | ||
142 | private fun writeNodeList(nodeList: List<String>) = runOnUiThread { | 142 | private fun writeNodeList(nodeList: List<String>) { |
143 | nodeListAdapter?.setElements(nodeList) | 143 | nodeListAdapter?.setElements(nodeList) |
144 | node_list_placeholder.visibility = View.GONE | 144 | node_list_placeholder.visibility = View.GONE |
145 | list_wrapper.isRefreshing = false | 145 | list_wrapper.isRefreshing = false |