improve when the buttons show

This commit is contained in:
Bnyro 2022-07-17 12:02:49 +02:00
parent 506b97536a
commit a705b29b95

View File

@ -984,6 +984,7 @@ class PlayerFragment : Fragment() {
private fun enableDoubleTapToSeek() {
val seekIncrement =
PreferenceHelper.getString(requireContext(), "seek_increment", "5")?.toLong()!! * 1000
val hideDoubleTapOverlayDelay = 700L
// enable rewind button
@ -991,11 +992,14 @@ class PlayerFragment : Fragment() {
context,
object : SimpleOnGestureListener() {
override fun onDoubleTap(e: MotionEvent): Boolean {
binding.rewindBTN.visibility = View.VISIBLE
exoPlayer.seekTo(exoPlayer.currentPosition - seekIncrement)
Handler(Looper.getMainLooper()).postDelayed({
binding.rewindBTN.visibility = View.INVISIBLE
}, hideDoubleTapOverlayDelay)
// show the rewind button
binding.rewindBTN.apply {
visibility = View.VISIBLE
removeCallbacks(hideRewindButtonRunnable)
postDelayed(hideRewindButtonRunnable, hideDoubleTapOverlayDelay)
}
return super.onDoubleTap(e)
}
@ -1017,12 +1021,15 @@ class PlayerFragment : Fragment() {
context,
object : SimpleOnGestureListener() {
override fun onDoubleTap(e: MotionEvent): Boolean {
binding.forwardBTN.visibility = View.VISIBLE
exoPlayer.seekTo(exoPlayer.currentPosition + seekIncrement)
Handler(Looper.getMainLooper()).postDelayed({
binding.forwardBTN.visibility = View.INVISIBLE
}, hideDoubleTapOverlayDelay)
return super.onSingleTapConfirmed(e)
// show the forward button
binding.forwardBTN.apply {
visibility = View.VISIBLE
removeCallbacks(hideForwardButtonRunnable)
postDelayed(hideForwardButtonRunnable, hideDoubleTapOverlayDelay)
}
return super.onDoubleTap(e)
}
override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
@ -1039,6 +1046,9 @@ class PlayerFragment : Fragment() {
}
}
private val hideForwardButtonRunnable = Runnable { binding.forwardBTN.visibility = View.GONE }
private val hideRewindButtonRunnable = Runnable { binding.rewindBTN.visibility = View.GONE }
private fun disableDoubleTapToSeek() {
// disable fast forward and rewind by double tapping
binding.forwardFL.visibility = View.GONE