diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/EventAnimationDriver.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/EventAnimationDriver.java index edc92c238c3bc3..91dd128c243fc7 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/EventAnimationDriver.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/EventAnimationDriver.java @@ -14,11 +14,13 @@ import com.facebook.react.bridge.UnexpectedNativeTypeException; import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; -import com.facebook.react.uimanager.events.RCTEventEmitter; +import com.facebook.react.uimanager.events.EventCategoryDef; +import com.facebook.react.uimanager.events.RCTModernEventEmitter; +import com.facebook.react.uimanager.events.TouchEvent; import java.util.List; /** Handles updating a {@link ValueAnimatedNode} when an event gets dispatched. */ -/* package */ class EventAnimationDriver implements RCTEventEmitter { +/* package */ class EventAnimationDriver implements RCTModernEventEmitter { private List mEventPath; /* package */ ValueAnimatedNode mValueNode; /* package */ String mEventName; @@ -33,7 +35,39 @@ public EventAnimationDriver( } @Override - public void receiveEvent(int targetTag, String eventName, @Nullable WritableMap event) { + public void receiveEvent(int targetReactTag, String eventName, @Nullable WritableMap event) { + receiveEvent(-1, targetReactTag, eventName, event); + } + + @Override + public void receiveEvent( + int surfaceId, int targetTag, String eventName, @Nullable WritableMap event) { + // We assume this event can't be coalesced. `customCoalesceKey` has no meaning in Fabric. + receiveEvent(surfaceId, targetTag, eventName, false, 0, event, EventCategoryDef.UNSPECIFIED); + } + + @Override + public void receiveTouches( + String eventName, WritableArray touches, WritableArray changedIndices) { + throw new UnsupportedOperationException( + "receiveTouches is not support by native animated events"); + } + + @Override + public void receiveTouches(TouchEvent touchEvent) { + throw new UnsupportedOperationException( + "receiveTouches is not support by native animated events"); + } + + @Override + public void receiveEvent( + int surfaceId, + int targetTag, + String eventName, + boolean canCoalesceEvent, + int customCoalesceKey, + @Nullable WritableMap event, + @EventCategoryDef int category) { if (event == null) { throw new IllegalArgumentException("Native animated events must have event data."); } @@ -79,10 +113,4 @@ public void receiveEvent(int targetTag, String eventName, @Nullable WritableMap mValueNode.mValue = currArray.getDouble(lastIndex); } } - - @Override - public void receiveTouches( - String eventName, WritableArray touches, WritableArray changedIndices) { - throw new RuntimeException("receiveTouches is not support by native animated events"); - } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java index efe2872b9c599a..4c3e81288ec900 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java @@ -603,7 +603,7 @@ private void handleEvent(Event event) { if (matchSpec.match(driver.mViewTag, driver.mEventName)) { foundAtLeastOneDriver = true; stopAnimationsForNode(driver.mValueNode); - event.dispatch(driver); + event.dispatchModern(driver); mRunUpdateNodeList.add(driver.mValueNode); } }