From bd1679b7e0db627afe37f6b1e7c47997a348f3e8 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 16 Sep 2020 18:30:34 +0530 Subject: ui: await activity creation to change selected tunnel Signed-off-by: Harsh Shandilya --- ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt | 3 +-- 1 file changed, 1 insertion(+), 2 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 95af26fd..a9f118ca 100644 --- a/ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt +++ b/ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt @@ -10,7 +10,6 @@ import androidx.databinding.CallbackRegistry.NotifierCallback import androidx.lifecycle.lifecycleScope import com.wireguard.android.Application import com.wireguard.android.model.ObservableTunnel -import kotlinx.coroutines.launch /** * Base class for activities that need to remember the currently-selected tunnel. @@ -38,7 +37,7 @@ abstract class BaseActivity : ThemeChangeAwareActivity() { else -> null } if (savedTunnelName != null) - lifecycleScope.launch { selectedTunnel = Application.getTunnelManager().getTunnels()[savedTunnelName] } + lifecycleScope.launchWhenCreated { selectedTunnel = Application.getTunnelManager().getTunnels()[savedTunnelName] } // The selected tunnel must be set before the superclass method recreates fragments. super.onCreate(savedInstanceState) -- cgit v1.2.3