summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-05-22 17:03:07 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-05-28 18:03:44 +0000
commit2e077c4ecf2226c1845bb19d93d8e15470e4fac0 (patch)
tree37437d3f83027c69771464a4f19cbdc1018b1f40 /android
parentf2b86e5260d93705a37fa39c3e962bd447e39cdd (diff)
downloadmullvadvpn-2e077c4ecf2226c1845bb19d93d8e15470e4fac0.tar.xz
mullvadvpn-2e077c4ecf2226c1845bb19d93d8e15470e4fac0.zip
Add event notifiers to `AccountCache`
Diffstat (limited to 'android')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/service/AccountCache.kt15
1 files changed, 14 insertions, 1 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/AccountCache.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/AccountCache.kt
index cdd90b0d3c..4a52e017a0 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/AccountCache.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/AccountCache.kt
@@ -4,6 +4,7 @@ import kotlin.math.min
import kotlinx.coroutines.delay
import net.mullvad.mullvadvpn.model.GetAccountDataResult
import net.mullvad.mullvadvpn.util.JobTracker
+import net.mullvad.talpid.util.EventNotifier
import org.joda.time.DateTime
import org.joda.time.format.DateTimeFormat
@@ -15,7 +16,19 @@ class AccountCache(val daemon: MullvadDaemon, val settingsListener: SettingsList
private val jobTracker = JobTracker()
private var accountNumber: String? = null
+ set(value) {
+ field = value
+ onAccountNumberChange.notify(value)
+ }
+
private var accountExpiry: DateTime? = null
+ set(value) {
+ field = value
+ onAccountExpiryChange.notify(value)
+ }
+
+ val onAccountNumberChange = EventNotifier<String?>(null)
+ val onAccountExpiryChange = EventNotifier<DateTime?>(null)
var onAccountDataChange: ((String?, DateTime?) -> Unit)? = null
set(value) {
@@ -48,7 +61,7 @@ class AccountCache(val daemon: MullvadDaemon, val settingsListener: SettingsList
retryAttempt += 1
delay(calculateRetryFetchDelay(retryAttempt))
- } while (onAccountDataChange != null)
+ } while (onAccountDataChange != null || onAccountExpiryChange.hasListeners())
}
}
}