@Override public void onEventDispatch(Event event) { // Only support events dispatched from the UI thread. if (!UiThreadUtil.isOnUiThread()) { return; } if (!mEventDrivers.isEmpty()) { // If the event has a different name in native convert it to it's JS name. String eventName = event.getEventName(); Map<String, String> customEventType = mCustomEventTypes.get(eventName); if (customEventType != null) { eventName = customEventType.get("registrationName"); } List<EventAnimationDriver> driversForKey = mEventDrivers.get(event.getViewTag() + eventName); if (driversForKey != null) { for (EventAnimationDriver driver : driversForKey) { event.dispatch(driver); mRunUpdateNodeList.add(driver.mValueNode); } updateNodes(mRunUpdateNodeList); mRunUpdateNodeList.clear(); } } }
@Override public boolean onEventDispatch(Event event) { // Only support events dispatched from the UI thread. if (!UiThreadUtil.isOnUiThread()) { return false; } if (!mEventDrivers.isEmpty()) { // If the event has a different name in native convert it to it's JS name. String eventName = event.getEventName(); Map<String, String> customEventType = mCustomEventTypes.get(eventName); if (customEventType != null) { eventName = customEventType.get("registrationName"); } EventAnimationDriver eventDriver = mEventDrivers.get(event.getViewTag() + eventName); if (eventDriver != null) { event.dispatch(eventDriver); mUpdatedNodes.add(eventDriver.mValueNode); return true; } } return false; }
private Event createScrollEvent(final int tag, final double value) { return new Event(tag) { @Override public String getEventName() { return "topScroll"; } @Override public void dispatch(RCTEventEmitter rctEventEmitter) { rctEventEmitter.receiveEvent(tag, "topScroll", JavaOnlyMap.of( "contentOffset", JavaOnlyMap.of("y", value))); } }; }
private static void dispatchEvent(WebView webView, Event event) { ReactContext reactContext = (ReactContext) webView.getContext(); EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher(); eventDispatcher.dispatchEvent(event); }