summaryrefslogtreecommitdiffhomepage
path: root/ui/src/main/java/com/wireguard/android
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2023-03-23 15:15:15 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2023-03-24 14:12:21 +0100
commit763d9a9f17097876f0e0f7e77514fa1430912f32 (patch)
tree5bc477041a5c5359792f26cedc8da5636036731c /ui/src/main/java/com/wireguard/android
parentf3107e349c564598ca8a4b3eaaf48fa92a7ec367 (diff)
ui: set selected tunnel after creating fragments
I'm not sure why that comment (Samuel's) was there saying it was necessary. Given it's been async for a long while, this wasn't guaranteed anyway. So let's get rid of it and see what happens. Screen rotation seems fine thus far. Cc: Samuel Holland <samuel@sholland.org> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android')
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt11
1 files changed, 3 insertions, 8 deletions
diff --git a/ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt b/ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt
index 204a5a80..8f0855ea 100644
--- a/ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt
+++ b/ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt
@@ -7,9 +7,7 @@ package com.wireguard.android.activity
import android.os.Bundle
import androidx.databinding.CallbackRegistry
import androidx.databinding.CallbackRegistry.NotifierCallback
-import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
-import androidx.lifecycle.repeatOnLifecycle
import com.wireguard.android.Application
import com.wireguard.android.model.ObservableTunnel
import kotlinx.coroutines.launch
@@ -33,6 +31,8 @@ abstract class BaseActivity : ThemeChangeAwareActivity() {
}
override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
// Restore the saved tunnel if there is one; otherwise grab it from the arguments.
val savedTunnelName = when {
savedInstanceState != null -> savedInstanceState.getString(KEY_SELECTED_TUNNEL)
@@ -41,13 +41,8 @@ abstract class BaseActivity : ThemeChangeAwareActivity() {
}
if (savedTunnelName != null)
lifecycleScope.launch {
- repeatOnLifecycle(Lifecycle.State.CREATED) {
- selectedTunnel = Application.getTunnelManager().getTunnels()[savedTunnelName]
- }
+ selectedTunnel = Application.getTunnelManager().getTunnels()[savedTunnelName]
}
-
- // The selected tunnel must be set before the superclass method recreates fragments.
- super.onCreate(savedInstanceState)
}
override fun onSaveInstanceState(outState: Bundle) {