[Android] Fix FadableImageView state reset
Nicolas Pomepuy
git at videolan.org
Mon Dec 2 14:45:07 CET 2019
vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Mon Dec 2 07:37:25 2019 +0100| [51c645cc43ef1acc89a3474d92fc1dfb942e077a] | committer: Geoffrey Métais
Fix FadableImageView state reset
> https://code.videolan.org/videolan/vlc-android/commit/51c645cc43ef1acc89a3474d92fc1dfb942e077a
---
.../org/videolan/vlc/gui/view/FadableImageView.kt | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 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 92c060542..55eed5266 100644
--- a/vlc-android/src/org/videolan/vlc/gui/view/FadableImageView.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/view/FadableImageView.kt
@@ -1,5 +1,6 @@
package org.videolan.vlc.gui.view
+import android.animation.Animator
import android.content.Context
import android.graphics.Bitmap
import android.graphics.drawable.ColorDrawable
@@ -25,12 +26,28 @@ class FadableImageView : AppCompatImageView {
if (animationRunning?.get() == true) return
alpha = 0f
animationRunning?.set(true)
- animate().withEndAction { animationRunning?.set(false) }.alpha(1f)
+ animate().setListener(object : Animator.AnimatorListener {
+ override fun onAnimationRepeat(p0: Animator?) {
+ }
+
+ override fun onAnimationEnd(p0: Animator?) {
+ animationRunning?.set(false)
+ alpha = 1f
+ }
+
+ override fun onAnimationCancel(p0: Animator?) {
+ animationRunning?.set(false)
+ alpha = 1f
+ }
+
+ override fun onAnimationStart(p0: Animator?) {
+ }
+ }).alpha(1f)
}
fun resetFade() {
- animate().cancel()
post {
+ animate().cancel()
alpha = 1f
}
}
More information about the Android
mailing list