From 5d419ea88ad1064eca129952c6d145cd0fe72a5e Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 21 Oct 2018 18:28:13 +0200 Subject: [PATCH] hide the video play/pause button faster --- .../gallery/fragments/VideoFragment.kt | 18 +++++++----------- .../gallery/helpers/Constants.kt | 2 ++ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt index d6fddb039..ef35bc1fe 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -30,9 +30,7 @@ import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.PanoramaVideoActivity import com.simplemobiletools.gallery.activities.VideoActivity import com.simplemobiletools.gallery.extensions.* -import com.simplemobiletools.gallery.helpers.MEDIUM -import com.simplemobiletools.gallery.helpers.MediaSideScroll -import com.simplemobiletools.gallery.helpers.PATH +import com.simplemobiletools.gallery.helpers.* import com.simplemobiletools.gallery.models.Medium import kotlinx.android.synthetic.main.pager_video_item.view.* import java.io.File @@ -40,8 +38,6 @@ import java.io.File class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, SeekBar.OnSeekBarChangeListener { private val PROGRESS = "progress" private val MIN_SKIP_LENGTH = 2000 - private val HIDE_PAUSE_DELAY = 2000L - private val PLAY_PAUSE_VISIBLE_ALPHA = 0.8f private var mTextureView: TextureView? = null private var mCurrTimeView: TextView? = null @@ -50,7 +46,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S private var mExoPlayer: SimpleExoPlayer? = null private var mVideoSize = Point(0, 0) private var mTimerHandler = Handler() - private var mHidePauseHandler = Handler() + private var mHidePlayPauseHandler = Handler() private var mIsPlaying = false private var mIsDragged = false @@ -394,7 +390,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S return mIsPlaying = !mIsPlaying - mHidePauseHandler.removeCallbacksAndMessages(null) + mHidePlayPauseHandler.removeCallbacksAndMessages(null) if (mIsPlaying) { playVideo() } else { @@ -440,10 +436,10 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S } private fun schedulePlayPauseFadeOut() { - mHidePauseHandler.removeCallbacksAndMessages(null) - mHidePauseHandler.postDelayed({ + mHidePlayPauseHandler.removeCallbacksAndMessages(null) + mHidePlayPauseHandler.postDelayed({ mView!!.video_play_outline.animate().alpha(0f).start() - }, HIDE_PAUSE_DELAY) + }, HIDE_PLAY_PAUSE_DELAY) } private fun videoEnded() = mExoPlayer?.currentPosition ?: 0 >= mExoPlayer?.duration ?: 0 @@ -499,7 +495,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S releaseExoPlayer() mSeekBar?.progress = 0 mTimerHandler.removeCallbacksAndMessages(null) - mHidePauseHandler.removeCallbacksAndMessages(null) + mHidePlayPauseHandler.removeCallbacksAndMessages(null) mTextureView = null } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt index 8c0c7b15d..79a0b37f7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -86,6 +86,8 @@ const val SHOW_TEMP_HIDDEN_DURATION = 300000L const val CLICK_MAX_DURATION = 150 const val DRAG_THRESHOLD = 8 const val MONTH_MILLISECONDS = MONTH_SECONDS * 1000L +const val HIDE_PLAY_PAUSE_DELAY = 500L +const val PLAY_PAUSE_VISIBLE_ALPHA = 0.8f const val DIRECTORY = "directory" const val MEDIUM = "medium"