Merge "NavHandleLongPressInputConsumer now cancels long press detection on intercept." into main

This commit is contained in:
Andreas Agvard
2023-11-06 08:43:28 +00:00
committed by Android (Google) Code Review
@@ -67,6 +67,18 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer {
@Override
public void onMotionEvent(MotionEvent ev) {
if (mDelegate.allowInterceptByParent()) {
handleMotionEvent(ev);
} else if (MAIN_EXECUTOR.getHandler().hasCallbacks(mTriggerLongPress)) {
cancelLongPress();
}
if (mState != STATE_ACTIVE) {
mDelegate.onMotionEvent(ev);
}
}
private void handleMotionEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN -> {
if (mCurrentDownEvent != null) {
@@ -101,10 +113,6 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer {
MAIN_EXECUTOR.getHandler().removeCallbacks(mTriggerLongPress);
MAIN_EXECUTOR.getHandler().post(mTriggerLongPress);
}
if (mState != STATE_ACTIVE) {
mDelegate.onMotionEvent(ev);
}
}
private void triggerLongPress() {