mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add null check for gesture ended notifier
Summary: The `notifyNativeGestureEnded` API is added to notify user gesture ended, so that any optimization we had during handling the gesture can be restored. It's possible that when the gesture finishes, the RootView is already unmounted from the native side. This might happen when user starts a gesture that caused leave of the RN screen, or close the app. Changelog: [Android][Internal] - Avoid NPE for gesture notifier Reviewed By: javache Differential Revision: D35902523 fbshipit-source-id: 9bb5819a53dd053290031eebaae1b8f0318ae534
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1a3eaa5dbf
commit
36c4e42d82
+5
-1
@@ -9,6 +9,7 @@ package com.facebook.react.uimanager.events;
|
||||
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import com.facebook.react.uimanager.RootView;
|
||||
import com.facebook.react.uimanager.RootViewUtil;
|
||||
|
||||
/** Utilities for native Views that interpret native gestures (e.g. ScrollView, ViewPager, etc.). */
|
||||
@@ -35,6 +36,9 @@ public class NativeGestureUtil {
|
||||
* @param event the MotionEvent that caused the gesture to be ended
|
||||
*/
|
||||
public static void notifyNativeGestureEnded(View view, MotionEvent event) {
|
||||
RootViewUtil.getRootView(view).onChildEndedNativeGesture(view, event);
|
||||
RootView rootView = RootViewUtil.getRootView(view);
|
||||
if (rootView != null) {
|
||||
rootView.onChildEndedNativeGesture(view, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user