summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-07-01 21:12:04 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-07-01 22:59:29 +0000
commitbb6424199455898a0a9b026f70b29fd3cb885ebe (patch)
tree3532935d1fb486bbbb14860d9039fdf45fca27ad
parent09577326d4996ebea710a10688570599b11acee4 (diff)
downloadmullvadvpn-bb6424199455898a0a9b026f70b29fd3cb885ebe.tar.xz
mullvadvpn-bb6424199455898a0a9b026f70b29fd3cb885ebe.zip
Synchronize notification updates to prevent races
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt24
1 files changed, 14 insertions, 10 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt
index dd5de3a532..6a20bcbd7f 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NotificationBanner.kt
@@ -28,17 +28,19 @@ class NotificationBanner : FrameLayout {
}
override fun onAnimationEnd(animation: Animator) {
- if (reversedAnimation) {
- // Banner is now hidden
- val notification = notifications.current
+ synchronized(this@NotificationBanner) {
+ if (reversedAnimation) {
+ // Banner is now hidden
+ val notification = notifications.current
- visibility = View.INVISIBLE
+ visibility = View.INVISIBLE
- if (notification != null) {
- // Notification changed, restart animation
- update(notification)
- reversedAnimation = false
- animation.start()
+ if (notification != null) {
+ // Notification changed, restart animation
+ update(notification)
+ reversedAnimation = false
+ animation.start()
+ }
}
}
}
@@ -70,7 +72,9 @@ class NotificationBanner : FrameLayout {
private var reversedAnimation = false
val notifications = InAppNotificationController { _ ->
- animateChange()
+ synchronized(this@NotificationBanner) {
+ animateChange()
+ }
}
constructor(context: Context) : super(context) {}