Kotlinify NativeGestureUtil (#43867)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43867

Changelog: [Internal]

As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)).

Reviewed By: alanleedev

Differential Revision: D55750840

fbshipit-source-id: 356828e6fc9c1b4c77e130cce281e5503ffb0d16
This commit is contained in:
Fabrizio Cucci
2024-04-05 13:54:51 -07:00
committed by Facebook GitHub Bot
parent d5dcaf3c1e
commit 2aef4418ea
2 changed files with 17 additions and 22 deletions
@@ -5522,10 +5522,10 @@ public class com/facebook/react/uimanager/events/FabricEventDispatcher : com/fac
public fun unregisterEventEmitter (I)V
}
public class com/facebook/react/uimanager/events/NativeGestureUtil {
public fun <init> ()V
public static fun notifyNativeGestureEnded (Landroid/view/View;Landroid/view/MotionEvent;)V
public static fun notifyNativeGestureStarted (Landroid/view/View;Landroid/view/MotionEvent;)V
public final class com/facebook/react/uimanager/events/NativeGestureUtil {
public static final field INSTANCE Lcom/facebook/react/uimanager/events/NativeGestureUtil;
public static final fun notifyNativeGestureEnded (Landroid/view/View;Landroid/view/MotionEvent;)V
public static final fun notifyNativeGestureStarted (Landroid/view/View;Landroid/view/MotionEvent;)V
}
public class com/facebook/react/uimanager/events/PointerEvent : com/facebook/react/uimanager/events/Event {
@@ -5,17 +5,14 @@
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.uimanager.events;
package com.facebook.react.uimanager.events
import android.view.MotionEvent;
import android.view.View;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.uimanager.RootView;
import com.facebook.react.uimanager.RootViewUtil;
import android.view.MotionEvent
import android.view.View
import com.facebook.react.uimanager.RootViewUtil
/** Utilities for native Views that interpret native gestures (e.g. ScrollView, ViewPager, etc.). */
@Nullsafe(Nullsafe.Mode.LOCAL)
public class NativeGestureUtil {
public object NativeGestureUtil {
/**
* Helper method that should be called when a native view starts a native gesture (e.g. a native
@@ -25,11 +22,10 @@ public class NativeGestureUtil {
* @param view the View starting the native gesture
* @param event the MotionEvent that caused the gesture to be started
*/
public static void notifyNativeGestureStarted(View view, MotionEvent event) {
RootView rootView = RootViewUtil.getRootView(view);
if (rootView != null) {
rootView.onChildStartedNativeGesture(view, event);
}
@JvmStatic
public fun notifyNativeGestureStarted(view: View, event: MotionEvent) {
val rootView = RootViewUtil.getRootView(view)
rootView?.onChildStartedNativeGesture(view, event)
}
/**
@@ -40,10 +36,9 @@ public class NativeGestureUtil {
* @param view the View ending the native gesture
* @param event the MotionEvent that caused the gesture to be ended
*/
public static void notifyNativeGestureEnded(View view, MotionEvent event) {
RootView rootView = RootViewUtil.getRootView(view);
if (rootView != null) {
rootView.onChildEndedNativeGesture(view, event);
}
@JvmStatic
public fun notifyNativeGestureEnded(view: View, event: MotionEvent) {
val rootView = RootViewUtil.getRootView(view)
rootView?.onChildEndedNativeGesture(view, event)
}
}