diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index ac0401caf..1c2882958 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -57,6 +57,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView private @Nullable String mJSModuleName; private @Nullable Bundle mLaunchOptions; private @Nullable KeyboardListener mKeyboardListener; + private @Nullable OnGenericMotionListener mOnGenericMotionListener; private boolean mWasMeasured = false; private boolean mAttachScheduled = false; private boolean mIsAttachedToWindow = false; @@ -121,6 +122,10 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class) .getEventDispatcher(); mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, eventDispatcher); + // Hook for containers or fragments to get informed of the on touch events to perform actions. + if (mOnGenericMotionListener != null) { + mOnGenericMotionListener.onGenericMotion(this, androidEvent); + } } @Override @@ -138,6 +143,10 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView return true; } + public void setOnGenericMotionListener(OnGenericMotionListener listener) { + mOnGenericMotionListener = listener; + } + private void dispatchJSTouchEvent(MotionEvent event) { if (mReactInstanceManager == null || !mIsAttachedToInstance || mReactInstanceManager.getCurrentReactContext() == null) {