diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-16 00:00:31 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-16 00:00:31 +0200 |
commit | 79ae85c728585c911e22f4778cc4bed5b5ae04e2 (patch) | |
tree | 340aac93024ea5c4ad710231063e146e0d45f2b8 /ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt | |
parent | coroutines: use lifecycleScope where appropriate (diff) | |
download | wireguard-android-79ae85c728585c911e22f4778cc4bed5b5ae04e2.tar.xz wireguard-android-79ae85c728585c911e22f4778cc4bed5b5ae04e2.zip |
coroutines: lifecycleScope is by default on Main.immediate
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt')
-rw-r--r-- | ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt | 7 |
1 files changed, 3 insertions, 4 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 7b987c50..6ddbb56d 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt @@ -33,7 +33,6 @@ import com.wireguard.android.viewmodel.ConfigProxy import com.wireguard.android.widget.EdgeToEdge.setUpRoot import com.wireguard.android.widget.EdgeToEdge.setUpScrollingContent import com.wireguard.config.Config -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch /** @@ -141,7 +140,7 @@ class TunnelEditorFragment : BaseFragment(), AppSelectionListener { Snackbar.make(binding!!.mainContainer, error, Snackbar.LENGTH_LONG).show() return false } - lifecycleScope.launch(Dispatchers.Main.immediate) { + lifecycleScope.launch { when { tunnel == null -> { Log.d(TAG, "Attempting to create new tunnel " + binding!!.name) @@ -205,7 +204,7 @@ class TunnelEditorFragment : BaseFragment(), AppSelectionListener { binding!!.config = ConfigProxy() if (tunnel != null) { binding!!.name = tunnel!!.name - lifecycleScope.launch(Dispatchers.Main.immediate) { + lifecycleScope.launch { try { onConfigLoaded(tunnel!!.getConfigAsync()) } catch (_: Throwable) { @@ -242,7 +241,7 @@ class TunnelEditorFragment : BaseFragment(), AppSelectionListener { Log.d(TAG, message) // Now save the rest of configuration changes. Log.d(TAG, "Attempting to save config of renamed tunnel " + tunnel!!.name) - lifecycleScope.launch(Dispatchers.Main.immediate) { + lifecycleScope.launch { try { renamedTunnel.setConfigAsync(newConfig) onConfigSaved(renamedTunnel, null) |