diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-07-30 06:56:32 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-07-30 06:56:32 -0300 |
| commit | ee97756c64dc9cb2fcfcb8820d4de7dabc9bfcf4 (patch) | |
| tree | ed11456ccf6a32c390757a51a5d361f5882a3f03 | |
| parent | 90a353614d70e49587ebc4153ac990dc1a47fa22 (diff) | |
| parent | ed8b5ce170b967df039c10ab65e8381f6dfe3a6a (diff) | |
| download | mullvadvpn-ee97756c64dc9cb2fcfcb8820d4de7dabc9bfcf4.tar.xz mullvadvpn-ee97756c64dc9cb2fcfcb8820d4de7dabc9bfcf4.zip | |
Merge branch 'fix-ui-delay-when-disconnecting-too-quickly'
| -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 |
