Skip to content

Commit 823f6b7

Browse files
Luna Weifacebook-github-bot
authored andcommitted
NativeGestureUtil.notifyNativeGestureEnded is called
Summary: Changelog: [Internal] - Make sure `onChildEndedNativeGesture` is called for view managers that call `onChildStartedNativeGesture` This affects `JSTouchDispatcher`, `JSPointerDispatcher` as they track what view is reporting native gesturing handling. This is a bug that view managers never shared the fact that they've stopped managing a native gesture. Both `JSTouchDispatcher`, `JSPointerDispatcher` get around this by manually resetting their internal flag on ACTION_DOWN event (we will get rid of this in a later diff) Reviewed By: javache Differential Revision: D38850609 fbshipit-source-id: ef4afb591249bb621f42667608dc1ef20424b65c
1 parent 4352459 commit 823f6b7

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ public void handleMotionEvent(MotionEvent motionEvent, EventDispatcher eventDisp
109109

110110
// First down pointer
111111
if (action == MotionEvent.ACTION_DOWN) {
112-
113-
// Reset mChildHandlingNativeGesture like JSTouchDispatcher does
114-
mChildHandlingNativeGesture = -1;
115112
mPrimaryPointerId = motionEvent.getPointerId(actionIndex);
116113

117114
// Start a "down" coalescing key

ReactAndroid/src/main/java/com/facebook/react/views/drawer/ReactDrawerLayout.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
public static final int DEFAULT_DRAWER_WIDTH = LayoutParams.MATCH_PARENT;
2626
private int mDrawerPosition = Gravity.START;
2727
private int mDrawerWidth = DEFAULT_DRAWER_WIDTH;
28+
private boolean mDragging = false;
2829

2930
public ReactDrawerLayout(ReactContext reactContext) {
3031
super(reactContext);
@@ -35,6 +36,7 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
3536
try {
3637
if (super.onInterceptTouchEvent(ev)) {
3738
NativeGestureUtil.notifyNativeGestureStarted(this, ev);
39+
mDragging = true;
3840
return true;
3941
}
4042
} catch (IllegalArgumentException e) {
@@ -47,6 +49,16 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
4749
return false;
4850
}
4951

52+
@Override
53+
public boolean onTouchEvent(MotionEvent ev) {
54+
int action = ev.getActionMasked();
55+
if (action == MotionEvent.ACTION_UP && mDragging) {
56+
NativeGestureUtil.notifyNativeGestureEnded(this, ev);
57+
mDragging = false;
58+
}
59+
return super.onTouchEvent(ev);
60+
}
61+
5062
/* package */ void openDrawer() {
5163
openDrawer(mDrawerPosition);
5264
}

ReactAndroid/src/main/java/com/facebook/react/views/swiperefresh/ReactSwipeRefreshLayout.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class ReactSwipeRefreshLayout extends SwipeRefreshLayout {
2525
private int mTouchSlop;
2626
private float mPrevTouchX;
2727
private boolean mIntercepted;
28+
private boolean mNativeGestureStarted = false;
2829

2930
public ReactSwipeRefreshLayout(ReactContext reactContext) {
3031
super(reactContext);
@@ -86,6 +87,7 @@ public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
8687
public boolean onInterceptTouchEvent(MotionEvent ev) {
8788
if (shouldInterceptTouchEvent(ev) && super.onInterceptTouchEvent(ev)) {
8889
NativeGestureUtil.notifyNativeGestureStarted(this, ev);
90+
mNativeGestureStarted = true;
8991

9092
// If the pull-to-refresh gesture is interrupted by a parent with its own
9193
// onInterceptTouchEvent then the refresh indicator gets stuck on-screen
@@ -99,6 +101,16 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
99101
return false;
100102
}
101103

104+
@Override
105+
public boolean onTouchEvent(MotionEvent ev) {
106+
int action = ev.getActionMasked();
107+
if (action == MotionEvent.ACTION_UP && mNativeGestureStarted) {
108+
NativeGestureUtil.notifyNativeGestureEnded(this, ev);
109+
mNativeGestureStarted = false;
110+
}
111+
return super.onTouchEvent(ev);
112+
}
113+
102114
/**
103115
* {@link SwipeRefreshLayout} completely bypasses ViewGroup's "disallowIntercept" by overriding
104116
* {@link ViewGroup#onInterceptTouchEvent} and never calling super.onInterceptTouchEvent(). This

0 commit comments

Comments
 (0)