summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-09-16 10:51:56 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2020-09-16 10:51:56 +0200
commit52a2ae36f611db3a7a0246910f64f9f48a725efc (patch)
treefafffacdceab332b5035b59db39781f658a49955
parentabcb51d2a680ac254bba1bc2ff223462fefde649 (diff)
TunnelEditorFragment: avoid extra trip through event loop
onSelectedTunnelChanged is already queueing us to Dispatchers.Main (rather than Dispatchers.Main.immediate, which would crash, but why?), so avoid the extra trip through the event loop by toggling the selected tunnel right away. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt13
1 files changed, 6 insertions, 7 deletions
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt
index 6ddbb56d..b7912175 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt
@@ -117,14 +117,13 @@ class TunnelEditorFragment : BaseFragment(), AppSelectionListener {
inputManager?.hideSoftInputFromWindow(focusedView.windowToken,
InputMethodManager.HIDE_NOT_ALWAYS)
}
+
// Tell the activity to finish itself or go back to the detail view.
- activity.runOnUiThread {
- // TODO(smaeul): Remove this hack when fixing the Config ViewModel
- // The selected tunnel has to actually change, but we have to remember this one.
- val savedTunnel = tunnel
- if (savedTunnel === selectedTunnel) selectedTunnel = null
- selectedTunnel = savedTunnel
- }
+ // TODO(smaeul): Remove this hack when fixing the Config ViewModel
+ // The selected tunnel has to actually change, but we have to remember this one.
+ val savedTunnel = tunnel
+ if (savedTunnel === selectedTunnel) selectedTunnel = null
+ selectedTunnel = savedTunnel
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {