Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.UIManagerHelper;
import com.facebook.react.uimanager.common.UIManagerType;
import com.facebook.react.uimanager.common.ViewUtil;
import com.facebook.react.uimanager.events.Event;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.uimanager.events.EventDispatcherListener;
Expand Down Expand Up @@ -570,7 +571,9 @@ private void handleEvent(Event event) {
return;
}
UIManager uiManager =
UIManagerHelper.getUIManager(mReactApplicationContext, event.getUIManagerType());
UIManagerHelper.getUIManager(
mReactApplicationContext,
ViewUtil.getUIManagerType(event.getViewTag(), event.getSurfaceId()));
if (uiManager == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.common.SystemClock;
import com.facebook.react.uimanager.IllegalViewOperationException;
import com.facebook.react.uimanager.common.UIManagerType;
import com.facebook.react.uimanager.common.ViewUtil;

/**
* A UI event that can be dispatched to JS.
Expand All @@ -35,7 +33,6 @@ public abstract class Event<T extends Event> {
private static int sUniqueID = 0;

private boolean mInitialized;
private @UIManagerType int mUIManagerType;
private int mSurfaceId;
private int mViewTag;
private long mTimestampMs;
Expand Down Expand Up @@ -70,7 +67,6 @@ protected void init(int surfaceId, int viewTag) {
protected void init(int surfaceId, int viewTag, long timestampMs) {
mSurfaceId = surfaceId;
mViewTag = viewTag;
mUIManagerType = ViewUtil.getUIManagerType(viewTag, surfaceId);
mTimestampMs = timestampMs;
mInitialized = true;
}
Expand Down Expand Up @@ -139,10 +135,6 @@ public void onDispose() {}
onDispose();
}

public final @UIManagerType int getUIManagerType() {
return mUIManagerType;
}

/** @return the name of this event as registered in JS */
public abstract String getEventName();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void dispatch(RCTEventEmitter rctEventEmitter) {
boolean shouldCopy = mPointersEventData.size() > 1;
for (WritableMap pointerEventData : mPointersEventData) {
WritableMap eventData = shouldCopy ? pointerEventData.copy() : pointerEventData;
rctEventEmitter.receiveEvent(this.getViewTag(), mEventName, eventData);
rctEventEmitter.receiveEvent(getViewTag(), mEventName, eventData);
}
return;
}
Expand Down Expand Up @@ -173,7 +173,7 @@ private List<WritableMap> createW3CPointerEvents() {

ArrayList<WritableMap> w3cPointerEvents = new ArrayList<>();
for (int index = 0; index < mMotionEvent.getPointerCount(); index++) {
w3cPointerEvents.add(this.createW3CPointerEvent(index));
w3cPointerEvents.add(createW3CPointerEvent(index));
}

return w3cPointerEvents;
Expand Down Expand Up @@ -215,8 +215,8 @@ private WritableMap createW3CPointerEvent(int index) {
pointerEvent.putDouble("offsetX", PixelUtil.toDIPFromPixel(offsetCoords[0]));
pointerEvent.putDouble("offsetY", PixelUtil.toDIPFromPixel(offsetCoords[1]));

pointerEvent.putInt("target", this.getViewTag());
pointerEvent.putDouble("timestamp", this.getTimestampMs());
pointerEvent.putInt("target", getViewTag());
pointerEvent.putDouble("timestamp", getTimestampMs());

pointerEvent.putInt("detail", 0);
pointerEvent.putDouble("tiltX", 0);
Expand Down Expand Up @@ -252,7 +252,7 @@ private List<WritableMap> createPointersEventData() {
// Cases where all pointer info is relevant
case PointerEventHelper.POINTER_MOVE:
case PointerEventHelper.POINTER_CANCEL:
pointersEventData = this.createW3CPointerEvents();
pointersEventData = createW3CPointerEvents();
break;
// Cases where only the "active" pointer info is relevant
case PointerEventHelper.POINTER_ENTER:
Expand Down Expand Up @@ -296,8 +296,8 @@ public void dispatchModern(RCTModernEventEmitter rctEventEmitter) {
for (WritableMap pointerEventData : mPointersEventData) {
WritableMap eventData = shouldCopy ? pointerEventData.copy() : pointerEventData;
rctEventEmitter.receiveEvent(
this.getSurfaceId(),
this.getViewTag(),
getSurfaceId(),
getViewTag(),
mEventName,
mCoalescingKey != UNSET_COALESCING_KEY,
mCoalescingKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public void receiveTouches(
@Override
public void receiveTouches(TouchEvent event) {
int reactTag = event.getViewTag();
@UIManagerType int uiManagerType = event.getUIManagerType();
@UIManagerType
int uiManagerType = ViewUtil.getUIManagerType(event.getViewTag(), event.getSurfaceId());
if (uiManagerType == UIManagerType.FABRIC && mFabricEventEmitter != null) {
mFabricEventEmitter.receiveTouches(event);
} else if (uiManagerType == UIManagerType.DEFAULT && getEventEmitter(reactTag) != null) {
Expand Down