diff options
Diffstat (limited to 'ui/src/main/java/com/wireguard/android/fragment/BaseFragment.kt')
-rw-r--r-- | ui/src/main/java/com/wireguard/android/fragment/BaseFragment.kt | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.kt index 997c2221..5cbfbaee 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.kt @@ -12,6 +12,7 @@ import android.widget.Toast import androidx.databinding.DataBindingUtil import androidx.databinding.ViewDataBinding import androidx.fragment.app.Fragment +import androidx.lifecycle.lifecycleScope import com.google.android.material.snackbar.Snackbar import com.wireguard.android.Application import com.wireguard.android.R @@ -24,7 +25,6 @@ import com.wireguard.android.databinding.TunnelListItemBinding import com.wireguard.android.model.ObservableTunnel import com.wireguard.android.util.ErrorMessages import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch /** @@ -72,7 +72,7 @@ abstract class BaseFragment : Fragment(), OnSelectedTunnelChangedListener { is TunnelListItemBinding -> binding.item else -> return } ?: return - GlobalScope.launch(Dispatchers.Main.immediate) { + lifecycleScope.launch(Dispatchers.Main.immediate) { if (Application.getBackend() is GoBackend) { val intent = GoBackend.VpnService.prepare(view.context) if (intent != null) { @@ -87,7 +87,7 @@ abstract class BaseFragment : Fragment(), OnSelectedTunnelChangedListener { } private fun setTunnelStateWithPermissionsResult(tunnel: ObservableTunnel, checked: Boolean) { - GlobalScope.launch(Dispatchers.Main.immediate) { + lifecycleScope.launch(Dispatchers.Main.immediate) { try { tunnel.setStateAsync(Tunnel.State.of(checked)) } catch (e: Throwable) { |