Merge "NavHandleLongPressInputConsumer now cancels long press detection on intercept." into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
0ddc984353
+12
-4
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user