From 03e513de41bf60f071eacbbb9604c83605abf625 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Thu, 21 Oct 2021 03:42:03 -0700 Subject: [PATCH] Add emitting view to onChildStartedNativeGesture callback 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 --- .../src/main/java/com/facebook/react/ReactRootView.java | 9 +++++++-- .../main/java/com/facebook/react/uimanager/RootView.java | 6 +++++- .../react/uimanager/events/NativeGestureUtil.java | 2 +- .../facebook/react/views/modal/ReactModalHostView.java | 9 +++++++-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 5bfdf9aafd8..e92289a5f1d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -184,7 +184,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { } @Override - public void onChildStartedNativeGesture(MotionEvent androidEvent) { + public void onChildStartedNativeGesture(MotionEvent ev) { if (mReactInstanceManager == null || !mIsAttachedToInstance || mReactInstanceManager.getCurrentReactContext() == null) { @@ -200,10 +200,15 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { 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); diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/RootView.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/RootView.java index 94eef5e1ceb..6188a241962 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/RootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/RootView.java @@ -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 { @@ -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); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/NativeGestureUtil.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/NativeGestureUtil.java index 7323a48ed42..7b79013960b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/NativeGestureUtil.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/NativeGestureUtil.java @@ -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); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java index 561b96d13ba..7d272250bd1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java @@ -528,8 +528,13 @@ public class ReactModalHostView extends ViewGroup } @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