summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-09-15 15:25:13 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-09-23 15:04:28 +0000
commit79ee0857987e789f48c42d176fab272cda29b11e (patch)
tree2b4f54e57ea78b035b03c8328a1fc9c49c464ed1 /android
parentaa781efb7f248372c9ecdb08c909bfe1b0624423 (diff)
downloadmullvadvpn-79ee0857987e789f48c42d176fab272cda29b11e.tar.xz
mullvadvpn-79ee0857987e789f48c42d176fab272cda29b11e.zip
Use `observable` delegate for `isConnected`
Diffstat (limited to 'android')
-rw-r--r--android/src/main/kotlin/net/mullvad/talpid/ConnectivityListener.kt16
1 files changed, 7 insertions, 9 deletions
diff --git a/android/src/main/kotlin/net/mullvad/talpid/ConnectivityListener.kt b/android/src/main/kotlin/net/mullvad/talpid/ConnectivityListener.kt
index 5de430bbcb..aca773fca9 100644
--- a/android/src/main/kotlin/net/mullvad/talpid/ConnectivityListener.kt
+++ b/android/src/main/kotlin/net/mullvad/talpid/ConnectivityListener.kt
@@ -6,6 +6,7 @@ import android.net.ConnectivityManager.NetworkCallback
import android.net.Network
import android.net.NetworkCapabilities
import android.net.NetworkRequest
+import kotlin.properties.Delegates.observable
import net.mullvad.talpid.util.EventNotifier
class ConnectivityListener {
@@ -33,17 +34,14 @@ class ConnectivityListener {
val connectivityNotifier = EventNotifier(false)
- var isConnected = false
- private set(value) {
- field = value
-
- if (senderAddress != 0L) {
- notifyConnectivityChange(value, senderAddress)
- }
-
- connectivityNotifier.notify(value)
+ var isConnected by observable(false) { _, _, value ->
+ if (senderAddress != 0L) {
+ notifyConnectivityChange(value, senderAddress)
}
+ connectivityNotifier.notify(value)
+ }
+
var senderAddress = 0L
fun register(context: Context) {