summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt15
1 files changed, 4 insertions, 11 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 1d71909d69..3adf175dc3 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt
@@ -33,8 +33,6 @@ class ConnectFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
private var updateTunnelStateJob: Job? = null
private var isTunnelInfoExpanded = false
- private var keyStatusListenerId: Int? = null
- private var tunnelStateListener: Int? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -83,7 +81,7 @@ class ConnectFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
notificationBanner.onResume()
- keyStatusListenerId = keyStatusListener.onKeyStatusChange.subscribe { keyStatus ->
+ keyStatusListener.onKeyStatusChange.subscribe(this) { keyStatus ->
updateKeyStatusJob.cancel()
updateKeyStatusJob = updateKeyStatus(keyStatus)
}
@@ -100,7 +98,7 @@ class ConnectFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
switchLocationButton.location = selectedRelayItem
}
- tunnelStateListener = connectionProxy.onUiStateChange.subscribe { uiState ->
+ connectionProxy.onUiStateChange.subscribe(this) { uiState ->
updateTunnelStateJob?.cancel()
updateTunnelStateJob = updateTunnelState(uiState, connectionProxy.state)
}
@@ -119,13 +117,8 @@ class ConnectFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
locationInfoCache.onNewLocation = null
relayListListener.onRelayListChange = null
- keyStatusListenerId?.let { listener ->
- keyStatusListener.onKeyStatusChange.unsubscribe(listener)
- }
-
- tunnelStateListener?.let { listener ->
- connectionProxy.onUiStateChange.unsubscribe(listener)
- }
+ keyStatusListener.onKeyStatusChange.unsubscribe(this)
+ connectionProxy.onUiStateChange.unsubscribe(this)
updateLocationInfoJob?.cancel()
updateTunnelStateJob?.cancel()