From 2c9b38fc1e6e4bd28253ae58295c0782a25cdc4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20M=C3=A9tais?= Date: Thu, 8 Aug 2019 11:00:59 +0200 Subject: [PATCH] FadableView: Fix crash animationRunning variable is mysteriously null at some point --- .../src/org/videolan/vlc/gui/view/FadableImageView.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vlc-android/src/org/videolan/vlc/gui/view/FadableImageView.kt b/vlc-android/src/org/videolan/vlc/gui/view/FadableImageView.kt index 33170be6b..92c060542 100644 --- a/vlc-android/src/org/videolan/vlc/gui/view/FadableImageView.kt +++ b/vlc-android/src/org/videolan/vlc/gui/view/FadableImageView.kt @@ -11,7 +11,9 @@ import androidx.appcompat.widget.AppCompatImageView import java.util.concurrent.atomic.AtomicBoolean class FadableImageView : AppCompatImageView { - private var animationRunning = AtomicBoolean(false) + //FIXME This field is sometimes null, despite a correct initialization order + // and non-nullable declaration + private var animationRunning : AtomicBoolean? = AtomicBoolean(false) constructor(context: Context) : super(context) @@ -20,10 +22,10 @@ class FadableImageView : AppCompatImageView { constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) private fun fade() { - if (animationRunning.get()) return + if (animationRunning?.get() == true) return alpha = 0f - animationRunning.set(true) - animate().withEndAction { animationRunning.set(false) }.alpha(1f) + animationRunning?.set(true) + animate().withEndAction { animationRunning?.set(false) }.alpha(1f) } fun resetFade() {