Guard against null events passed to onScroll

It appears that on some devices, e1 can be null, which would result in a
crash. This is probably due to manufacturers messing with input handling
of AOSP.
This commit is contained in:
Gaurav Ujjwal 2022-10-04 18:42:47 +05:30
parent 1fe3dedc52
commit 09a4990433

View file

@ -220,8 +220,9 @@ class TouchHandler(private val viewModel: VncViewModel, private val dispatcher:
return true
}
override fun onScroll(e1: MotionEvent, e2: MotionEvent, dX: Float, dY: Float): Boolean {
val startPoint = e1.point()
override fun onScroll(e1: MotionEvent?, e2: MotionEvent, dX: Float, dY: Float): Boolean {
// As weird as it may be, e1 can be null on some devices
val startPoint = e1?.point() ?: return false
val currentPoint = e2.point()
val normalizedDx = -dX * swipeSensitivity
val normalizedDy = -dY * swipeSensitivity