diff options
Diffstat (limited to 'android')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt | 14 | ||||
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/LocationInfoCache.kt | 5 |
2 files changed, 6 insertions, 13 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt index 4670cd5e12..f1fb1d7860 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt @@ -1,10 +1,5 @@ package net.mullvad.mullvadvpn -import kotlinx.coroutines.launch -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.Job - import android.view.View import android.widget.TextView @@ -15,22 +10,17 @@ class LocationInfo(val parentView: View, val locationInfoCache: LocationInfoCach private val cityLabel: TextView = parentView.findViewById(R.id.city) private val hostnameLabel: TextView = parentView.findViewById(R.id.hostname) - private var updateJob: Job? = null - init { locationInfoCache.onNewLocation = { country, city, hostname -> - updateJob?.cancel() - updateJob = updateViews(country, city, hostname) + updateViews(country, city, hostname) } } fun onDestroy() { - updateJob?.cancel() locationInfoCache.onNewLocation = null } - fun updateViews(country: String, city: String, hostname: String) = - GlobalScope.launch(Dispatchers.Main) { + fun updateViews(country: String, city: String, hostname: String) { countryLabel.text = country cityLabel.text = city hostnameLabel.text = hostname diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/LocationInfoCache.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/LocationInfoCache.kt index 3884490bcc..6fc655c2a8 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/LocationInfoCache.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/LocationInfoCache.kt @@ -39,7 +39,10 @@ class LocationInfoCache( field = value when (value) { - is TunnelState.Disconnected -> fetchLocation() + is TunnelState.Disconnected -> { + location = lastKnownRealLocation + fetchLocation() + } is TunnelState.Connecting -> location = value.location is TunnelState.Connected -> { location = value.location |
