handle double clicks on volume/brightness controllers too

This commit is contained in:
tibbi 2020-02-20 11:45:51 +01:00
parent 0d7aa81442
commit da8aaa71d0
2 changed files with 31 additions and 13 deletions

View file

@ -174,12 +174,8 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
val gestureDetector = GestureDetector(this, object : GestureDetector.SimpleOnGestureListener() {
override fun onDoubleTap(e: MotionEvent?): Boolean {
val instantWidth = mScreenWidth / 7
val clickedX = e?.rawX ?: 0f
when {
clickedX <= instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, false)
clickedX >= mScreenWidth - instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true)
else -> togglePlayPause()
if (e != null) {
handleDoubleTap(e.rawX)
}
return true
@ -198,10 +194,14 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
if (config.allowVideoGestures) {
video_brightness_controller.initialize(this, slide_info, true, video_player_holder, singleTap = { x, y ->
toggleFullscreen()
}, doubleTap = {x, y ->
doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, false)
})
video_volume_controller.initialize(this, slide_info, false, video_player_holder, singleTap = { x, y ->
toggleFullscreen()
}, doubleTap = {x, y ->
doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true)
})
} else {
video_brightness_controller.beGone()
@ -304,6 +304,15 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
}
}
private fun handleDoubleTap(x: Float) {
val instantWidth = mScreenWidth / 7
when {
x <= instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, false)
x >= mScreenWidth - instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true)
else -> togglePlayPause()
}
}
private fun resumeVideo() {
video_toggle_play_pause.setImageResource(R.drawable.ic_pause_outline)
if (mExoPlayer == null) {

View file

@ -132,13 +132,8 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
}
override fun onDoubleTap(e: MotionEvent?): Boolean {
val viewWidth = width
val instantWidth = viewWidth / 7
val clickedX = e?.rawX ?: 0f
when {
clickedX <= instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, false)
clickedX >= viewWidth - instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true)
else -> togglePlayPause()
if (e != null) {
handleDoubleTap(e.rawX)
}
return true
@ -211,6 +206,8 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
} else {
toggleFullscreen()
}
}, doubleTap = {x, y ->
doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, false)
})
mVolumeSideScroll.initialize(activity!!, slide_info, false, container, singleTap = { x, y ->
@ -219,6 +216,8 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
} else {
toggleFullscreen()
}
}, doubleTap = {x, y ->
doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true)
})
video_surface.onGlobalLayout {
@ -428,6 +427,16 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
listener?.fragmentClicked()
}
private fun handleDoubleTap(x: Float) {
val viewWidth = mView.width
val instantWidth = viewWidth / 7
when {
x <= instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, false)
x >= viewWidth - instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true)
else -> togglePlayPause()
}
}
private fun checkExtendedDetails() {
if (mConfig.showExtendedDetails) {
mView.video_details.apply {