SystemUI: SeekBarViewModel: Proper MotionEvent handling
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
This commit is contained in:
committed by
Zabuka_zuzu
parent
1d314faeaf
commit
6b67a3665c
@@ -309,7 +309,7 @@ constructor(
|
||||
|
||||
/** Call to clean up any resources. */
|
||||
@AnyThread
|
||||
fun onDestroy() =
|
||||
fun onDestroy() {
|
||||
bgExecutor.execute {
|
||||
controller = null
|
||||
playbackState = null
|
||||
@@ -318,6 +318,11 @@ constructor(
|
||||
scrubbingChangeListener = null
|
||||
enabledChangeListener = null
|
||||
}
|
||||
firstMotionEvent?.recycle()
|
||||
lastMotionEvent?.recycle()
|
||||
firstMotionEvent = null
|
||||
lastMotionEvent = null
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private fun checkPlaybackPosition() {
|
||||
@@ -531,6 +536,8 @@ constructor(
|
||||
// Indicates if the gesture should go to the seek bar or if it should be intercepted.
|
||||
private var shouldGoToSeekBar = false
|
||||
|
||||
private fun MotionEvent.safeCopy(): MotionEvent = MotionEvent.obtain(this)
|
||||
|
||||
/**
|
||||
* Decide which touch events to intercept before they reach the seek bar.
|
||||
*
|
||||
@@ -552,7 +559,8 @@ constructor(
|
||||
}
|
||||
detector.onTouchEvent(event)
|
||||
// Store the last motion event done on seekbar.
|
||||
viewModel.lastMotionEvent = event.copy()
|
||||
viewModel.lastMotionEvent?.recycle()
|
||||
viewModel.lastMotionEvent = event.safeCopy()
|
||||
return !shouldGoToSeekBar
|
||||
}
|
||||
|
||||
@@ -598,7 +606,8 @@ constructor(
|
||||
bar.parent?.requestDisallowInterceptTouchEvent(true)
|
||||
}
|
||||
// Store the first motion event done on seekbar.
|
||||
viewModel.firstMotionEvent = event.copy()
|
||||
viewModel.firstMotionEvent?.recycle()
|
||||
viewModel.firstMotionEvent = event.safeCopy()
|
||||
return shouldGoToSeekBar
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user