summaryrefslogtreecommitdiffhomepage
path: root/android/src
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2021-03-13 21:05:35 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2021-03-15 13:08:16 +0000
commit86fe36cdec76af8baa7a9534bbb744fed14f2f94 (patch)
tree9ef239d63827fa19150bd07b3b50ba6802beb534 /android/src
parentf3635a0c3178448f20f48bd72408c5b5430af7cd (diff)
downloadmullvadvpn-86fe36cdec76af8baa7a9534bbb744fed14f2f94.tar.xz
mullvadvpn-86fe36cdec76af8baa7a9534bbb744fed14f2f94.zip
Use lifecycle scope to update tunnel state
Replace the job scheduled by the `jobTracker` with the usage of the fragment view's lifecycle coroutine scope. This prevents the job from running after the fragment has been destroyed.
Diffstat (limited to 'android/src')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt3
1 files changed, 2 insertions, 1 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt
index 669344b3bf..755a6c5fea 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt
@@ -5,6 +5,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
+import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.delay
import net.mullvad.mullvadvpn.R
import net.mullvad.mullvadvpn.model.TunnelState
@@ -96,7 +97,7 @@ class ConnectFragment :
}
connectionProxy.onUiStateChange.subscribe(this) { uiState ->
- jobTracker.newUiJob("updateTunnelState") {
+ viewLifecycleOwner.lifecycleScope.launchWhenStarted {
updateTunnelState(uiState, connectionProxy.state)
}
}