Skip to content

Commit

Permalink
Add emitting view to onChildStartedNativeGesture callback
Browse files Browse the repository at this point in the history
Summary:
Changelog:
[Android][Changed] RootView's onChildStartedNativeGesture now takes the child view as its first argument

Reviewed By: philIip

Differential Revision: D31399515

fbshipit-source-id: b9438f6118e604a04799ef67d0b46303a06d6434
  • Loading branch information
javache authored and facebook-github-bot committed Oct 21, 2021
1 parent e007c8a commit 03e513d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
}

@Override
public void onChildStartedNativeGesture(MotionEvent androidEvent) {
public void onChildStartedNativeGesture(MotionEvent ev) {
if (mReactInstanceManager == null
|| !mIsAttachedToInstance
|| mReactInstanceManager.getCurrentReactContext() == null) {
Expand All @@ -200,10 +200,15 @@ public void onChildStartedNativeGesture(MotionEvent androidEvent) {

if (uiManager != null) {
EventDispatcher eventDispatcher = uiManager.getEventDispatcher();
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, eventDispatcher);
mJSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher);
}
}

@Override
public void onChildStartedNativeGesture(View childView, MotionEvent ev) {
onChildStartedNativeGesture(ev);
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
dispatchJSTouchEvent(ev);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.facebook.react.uimanager;

import android.view.MotionEvent;
import android.view.View;

/** Interface for the root native view of a React native application. */
public interface RootView {
Expand All @@ -16,7 +17,10 @@ public interface RootView {
* Called when a child starts a native gesture (e.g. a scroll in a ScrollView). Should be called
* from the child's onTouchIntercepted implementation.
*/
void onChildStartedNativeGesture(MotionEvent androidEvent);
void onChildStartedNativeGesture(View childView, MotionEvent ev);

/** @deprecated */
void onChildStartedNativeGesture(MotionEvent ev);

void handleException(Throwable t);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public class NativeGestureUtil {
* @param event the MotionEvent that caused the gesture to be started
*/
public static void notifyNativeGestureStarted(View view, MotionEvent event) {
RootViewUtil.getRootView(view).onChildStartedNativeGesture(event);
RootViewUtil.getRootView(view).onChildStartedNativeGesture(view, event);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,13 @@ public boolean onTouchEvent(MotionEvent event) {
}

@Override
public void onChildStartedNativeGesture(MotionEvent androidEvent) {
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, mEventDispatcher);
public void onChildStartedNativeGesture(MotionEvent ev) {
mJSTouchDispatcher.onChildStartedNativeGesture(ev, mEventDispatcher);
}

@Override
public void onChildStartedNativeGesture(View childView, MotionEvent ev) {
mJSTouchDispatcher.onChildStartedNativeGesture(ev, mEventDispatcher);
}

@Override
Expand Down

0 comments on commit 03e513d

Please sign in to comment.