mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Support RCTModernEventEmitter+RCTEventEmitter in ViewGroupClickEvent Event class
Summary: Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D26054855 fbshipit-source-id: 9592d854962d53f64d836b8361256cac5c4325df
This commit is contained in:
committed by
Facebook GitHub Bot
parent
70073664ab
commit
aa9c8abd1a
@@ -52,7 +52,8 @@ class ReactClickableSpan extends ClickableSpan implements ReactSpan {
|
||||
EventDispatcher eventDispatcher =
|
||||
UIManagerHelper.getEventDispatcherForReactTag(context, mReactTag);
|
||||
if (eventDispatcher != null) {
|
||||
eventDispatcher.dispatchEvent(new ViewGroupClickEvent(mReactTag));
|
||||
eventDispatcher.dispatchEvent(
|
||||
new ViewGroupClickEvent(UIManagerHelper.getSurfaceId(context), mReactTag));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -239,7 +239,9 @@ public class ReactViewManager extends ReactClippingViewManager<ReactViewGroup> {
|
||||
if (mEventDispatcher == null) {
|
||||
return;
|
||||
}
|
||||
mEventDispatcher.dispatchEvent(new ViewGroupClickEvent(view.getId()));
|
||||
mEventDispatcher.dispatchEvent(
|
||||
new ViewGroupClickEvent(
|
||||
UIManagerHelper.getSurfaceId(view.getContext()), view.getId()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -7,16 +7,22 @@
|
||||
|
||||
package com.facebook.react.views.view;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.uimanager.events.Event;
|
||||
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
||||
|
||||
/** Represents a Click on the ReactViewGroup */
|
||||
public class ViewGroupClickEvent extends Event<ViewGroupClickEvent> {
|
||||
private static final String EVENT_NAME = "topClick";
|
||||
|
||||
@Deprecated
|
||||
public ViewGroupClickEvent(int viewId) {
|
||||
super(viewId);
|
||||
this(-1, viewId);
|
||||
}
|
||||
|
||||
public ViewGroupClickEvent(int surfaceId, int viewId) {
|
||||
super(surfaceId, viewId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,8 +35,9 @@ public class ViewGroupClickEvent extends Event<ViewGroupClickEvent> {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public void dispatch(RCTEventEmitter rctEventEmitter) {
|
||||
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), Arguments.createMap());
|
||||
protected WritableMap getEventData() {
|
||||
return Arguments.createMap();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user