Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c246bc9b authored by Mady Mellor's avatar Mady Mellor
Browse files

Only removeCallbacksAndMessages if the handler exists

Test: none / couldn't repro locally
Bug: 302034566
Change-Id: I3e7af60414c907dcbdb0da241d915a06bf5b1615
parent 5722cd9a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ abstract class RelativeTouchListener : View.OnTouchListener {
                viewPositionOnTouchDown.set(v.translationX, v.translationY)

                performedLongClick = false
                v.handler.postDelayed({
                v.handler?.postDelayed({
                    if (v.isLongClickable) {
                        performedLongClick = v.performLongClick()
                    }
@@ -122,7 +122,7 @@ abstract class RelativeTouchListener : View.OnTouchListener {
            MotionEvent.ACTION_MOVE -> {
                if (!movedEnough && hypot(dx, dy) > touchSlop && !performedLongClick) {
                    movedEnough = true
                    v.handler.removeCallbacksAndMessages(null)
                    v.handler?.removeCallbacksAndMessages(null)
                }

                if (movedEnough) {
@@ -138,7 +138,7 @@ abstract class RelativeTouchListener : View.OnTouchListener {
                } else if (!performedLongClick) {
                    v.performClick()
                } else {
                    v.handler.removeCallbacksAndMessages(null)
                    v.handler?.removeCallbacksAndMessages(null)
                }

                velocityTracker.clear()
@@ -146,7 +146,7 @@ abstract class RelativeTouchListener : View.OnTouchListener {
            }

            MotionEvent.ACTION_CANCEL -> {
                v.handler.removeCallbacksAndMessages(null)
                v.handler?.removeCallbacksAndMessages(null)
                velocityTracker.clear()
                movedEnough = false
            }