[Android] Launch HUD hiding timer after the animation is completed

Nicolas Pomepuy git at videolan.org
Tue Apr 12 08:13:46 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Apr  8 11:13:17 2022 +0200| [a4e7bc91f40936ef8ec8cd1f20878aa695a2f817] | committer: Duncan McNamara

Launch HUD hiding timer after the animation is completed

Fixes #2315

> https://code.videolan.org/videolan/vlc-android/commit/a4e7bc91f40936ef8ec8cd1f20878aa695a2f817
---

 .../vlc/gui/video/VideoPlayerOverlayDelegate.kt         | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
index f459d7f73..7c6ca3a77 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
@@ -414,7 +414,10 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
                 }
                 if (!isBookmarkShown()) dimStatusBar(false)
 
-                enterAnimate(arrayOf(hudBinding.progressOverlay, hudBackground), 100.dp.toFloat())
+                enterAnimate(arrayOf(hudBinding.progressOverlay, hudBackground), 100.dp.toFloat()) {
+                    if (overlayTimeout != VideoPlayerActivity.OVERLAY_INFINITE)
+                        player.handler.sendMessageDelayed(player.handler.obtainMessage(VideoPlayerActivity.FADE_OUT), overlayTimeout.toLong())
+                }
                 enterAnimate(arrayOf(hudRightBinding.hudRightOverlay, hudRightBackground), -100.dp.toFloat())
 
                 hingeArrowLeft.animate().alpha(1F)
@@ -423,10 +426,12 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
                 if (!player.displayManager.isPrimary)
                     overlayBackground.setVisible()
                 updateOverlayPausePlay(true)
+            } else {
+                if (overlayTimeout != VideoPlayerActivity.OVERLAY_INFINITE)
+                    player.handler.sendMessageDelayed(player.handler.obtainMessage(VideoPlayerActivity.FADE_OUT), overlayTimeout.toLong())
             }
             player.handler.removeMessages(VideoPlayerActivity.FADE_OUT)
-            if (overlayTimeout != VideoPlayerActivity.OVERLAY_INFINITE)
-                player.handler.sendMessageDelayed(player.handler.obtainMessage(VideoPlayerActivity.FADE_OUT), overlayTimeout.toLong())
+
         }
     }
 
@@ -455,11 +460,13 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
         }
     }
 
-    private fun enterAnimate(views: Array<View?>, translationStart: Float) = views.forEach { view ->
+    private fun enterAnimate(views: Array<View?>, translationStart: Float, endListener:(()->Unit)? = null) = views.forEach { view ->
         view.setVisible()
         view?.alpha = 0f
         view?.translationY = translationStart
-        view?.animate()?.alpha(1F)?.translationY(0F)?.setDuration(150L)?.setListener(null)
+        view?.animate()?.alpha(1F)?.translationY(0F)?.setDuration(150L)?.setListener(null)?.withEndAction {
+            endListener?.invoke()
+        }
     }
 
     private fun exitAnimate(views: Array<View?>, translationEnd: Float) = views.forEach { view ->



More information about the Android mailing list