diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-15 23:30:20 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-15 23:46:11 +0200 |
commit | 49ac61304e5a244c674028d279f70f9631351f9c (patch) | |
tree | e196a0fb2cddb9674f6f72e50801a57e05599140 /ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt | |
parent | d79cdb0d41f05f53c13a0b247f54c28f42609e2f (diff) |
coroutines: use lifecycleScope where appropriate
There's still a bit of GlobalScope lingering around, which might be
removable.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt')
-rw-r--r-- | ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt b/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt index 3abfe07c..de1417dd 100644 --- a/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt +++ b/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt @@ -12,6 +12,7 @@ import android.util.SparseArray import android.view.MenuItem import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat +import androidx.lifecycle.lifecycleScope import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat import com.wireguard.android.Application @@ -20,7 +21,6 @@ import com.wireguard.android.backend.WgQuickBackend import com.wireguard.android.util.AdminKnobs import com.wireguard.android.util.ModuleLoader import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import java.util.ArrayList @@ -102,7 +102,7 @@ class SettingsActivity : ThemeChangeAwareActivity() { preferenceManager.findPreference<Preference>("multiple_tunnels") ).filterNotNull() wgQuickOnlyPrefs.forEach { it.isVisible = false } - GlobalScope.launch(Dispatchers.Main.immediate) { + lifecycleScope.launch(Dispatchers.Main.immediate) { if (Application.getBackend() is WgQuickBackend) { ++preferenceScreen.initialExpandedChildrenCount wgQuickOnlyPrefs.forEach { it.isVisible = true } @@ -121,7 +121,7 @@ class SettingsActivity : ThemeChangeAwareActivity() { moduleInstaller?.parent?.removePreference(moduleInstaller) } else { kernelModuleDisabler?.parent?.removePreference(kernelModuleDisabler) - GlobalScope.launch(Dispatchers.Main.immediate) { + lifecycleScope.launch(Dispatchers.Main.immediate) { try { withContext(Dispatchers.IO) { Application.getRootShell().start() } moduleInstaller?.isVisible = true |