Skip to content

Commit 30ffce3

Browse files
committed
fix: android ensure we cancel events correctly
1 parent caad920 commit 30ffce3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

plugin/platforms/android/java/com/nativescript/gesturehandler/PageLayout.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public PageLayout(Context context) {
3030

3131
private boolean mShouldIntercept = false;
3232
private boolean mPassingTouch = false;
33+
private boolean mDispatchToOrchestra = true;
3334

3435
public void setShouldIntercept(boolean value) {
3536
if (GestureHandler.debug) {
@@ -42,6 +43,13 @@ public void setPassingTouch(boolean value) {
4243
this.mPassingTouch = value;
4344
}
4445

46+
public void setDispatchToOrchestra(boolean value) {
47+
if (GestureHandler.debug) {
48+
Log.d("JS", "PageLayout setDispatchToOrchestra " + value);
49+
}
50+
this.mDispatchToOrchestra = value;
51+
}
52+
4553
public GestureHandlerRegistryImpl registry() {
4654
return this.mRegistry;
4755
}
@@ -98,7 +106,7 @@ public boolean dispatchTouchEventToOrchestrator(MotionEvent ev) {
98106
}
99107

100108
public boolean dispatchTouchEvent(MotionEvent ev) {
101-
if (this.dispatchTouchEventToOrchestrator(ev)) {
109+
if (this.mDispatchToOrchestra && this.dispatchTouchEventToOrchestrator(ev)) {
102110
return true;
103111
}
104112
final boolean handled = super.dispatchTouchEvent(ev);

plugin/platforms/android/java/com/nativescript/gesturehandler/RootViewGestureHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ protected void onCancel() {
3535
final long time = SystemClock.uptimeMillis();
3636
final MotionEvent event = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0, 0, 0);
3737
event.setAction(MotionEvent.ACTION_CANCEL);
38-
getView().onTouchEvent(event);
38+
getView().setDispatchToOrchestra(false);
39+
getView().dispatchTouchEvent(event);
40+
getView().setDispatchToOrchestra(true);
3941
}
4042
// public boolean shouldRecognizeSimultaneously(GestureHandler handler) {
4143
// return true;

0 commit comments

Comments
 (0)