Initialize Event Emitter as part of UIManagerModule

Reviewed By: achen1

Differential Revision: D8216184

fbshipit-source-id: 3b188804e2dad2b112f566da49a939eb4338713d
This commit is contained in:
David Vacca 2018-05-30 21:49:26 -07:00 committed by Facebook Github Bot
parent 0f10e03dd8
commit 6e359c4589
22 changed files with 43 additions and 50 deletions

View File

@ -1078,8 +1078,6 @@ public class ReactInstanceManager {
ReactMarker.logMarker(CREATE_REACT_CONTEXT_START, jsExecutor.getName()); ReactMarker.logMarker(CREATE_REACT_CONTEXT_START, jsExecutor.getName());
final ReactApplicationContext reactContext = new ReactApplicationContext(mApplicationContext); final ReactApplicationContext reactContext = new ReactApplicationContext(mApplicationContext);
reactContext.setEventDispatcher(new EventDispatcher(reactContext));
NativeModuleCallExceptionHandler exceptionHandler = mNativeModuleCallExceptionHandler != null NativeModuleCallExceptionHandler exceptionHandler = mNativeModuleCallExceptionHandler != null
? mNativeModuleCallExceptionHandler ? mNativeModuleCallExceptionHandler
: mDevSupportManager; : mDevSupportManager;

View File

@ -194,7 +194,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout
return; return;
} }
ReactContext reactContext = mReactInstanceManager.getCurrentReactContext(); ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
EventDispatcher eventDispatcher = reactContext.<EventDispatcher>getEventDispatcher(); EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, eventDispatcher); mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, eventDispatcher);
} }
@ -280,7 +280,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout
return; return;
} }
ReactContext reactContext = mReactInstanceManager.getCurrentReactContext(); ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
EventDispatcher eventDispatcher = reactContext.<EventDispatcher>getEventDispatcher(); EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
mJSTouchDispatcher.handleTouchEvent(event, eventDispatcher); mJSTouchDispatcher.handleTouchEvent(event, eventDispatcher);
} }

View File

@ -39,7 +39,6 @@ public class ReactContext extends ContextWrapper {
private LifecycleState mLifecycleState = LifecycleState.BEFORE_CREATE; private LifecycleState mLifecycleState = LifecycleState.BEFORE_CREATE;
private @Nullable EventDispatcher mEventDispatcher;
private @Nullable CatalystInstance mCatalystInstance; private @Nullable CatalystInstance mCatalystInstance;
private @Nullable LayoutInflater mInflater; private @Nullable LayoutInflater mInflater;
private @Nullable MessageQueueThread mUiMessageQueueThread; private @Nullable MessageQueueThread mUiMessageQueueThread;
@ -351,11 +350,4 @@ public class ReactContext extends ContextWrapper {
return mCatalystInstance.getJavaScriptContextHolder(); return mCatalystInstance.getJavaScriptContextHolder();
} }
public <T extends EventDispatcher> T getEventDispatcher() {
return (T) mEventDispatcher;
}
public void setEventDispatcher(EventDispatcher eventDispatcher) {
mEventDispatcher = eventDispatcher;
}
} }

View File

@ -31,6 +31,7 @@ import com.facebook.react.uimanager.PointerEvents;
import com.facebook.react.uimanager.ReactClippingViewGroup; import com.facebook.react.uimanager.ReactClippingViewGroup;
import com.facebook.react.uimanager.ReactCompoundViewGroup; import com.facebook.react.uimanager.ReactCompoundViewGroup;
import com.facebook.react.uimanager.ReactPointerEventsView; import com.facebook.react.uimanager.ReactPointerEventsView;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.views.image.ImageLoadEvent; import com.facebook.react.views.image.ImageLoadEvent;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
@ -126,7 +127,7 @@ import javax.annotation.Nullable;
} }
ReactContext reactContext = ((ReactContext) view.getContext()); ReactContext reactContext = ((ReactContext) view.getContext());
reactContext.<EventDispatcher>getEventDispatcher().dispatchEvent( reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
new ImageLoadEvent(reactTag, imageLoadEvent)); new ImageLoadEvent(reactTag, imageLoadEvent));
} }
} }

View File

@ -7,7 +7,6 @@
package com.facebook.react.uimanager; package com.facebook.react.uimanager;
import com.facebook.react.bridge.EventDispatcher;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import android.app.Activity; import android.app.Activity;
@ -17,8 +16,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.LifecycleEventListener; import com.facebook.react.bridge.LifecycleEventListener;
//
/** /**
* Wraps {@link ReactContext} with the base {@link Context} passed into the constructor. * Wraps {@link ReactContext} with the base {@link Context} passed into the constructor.
* It provides also a way to start activities using the viewContext to which RN native views belong. * It provides also a way to start activities using the viewContext to which RN native views belong.
@ -56,9 +53,4 @@ public class ThemedReactContext extends ReactContext {
public @Nullable Activity getCurrentActivity() { public @Nullable Activity getCurrentActivity() {
return mReactApplicationContext.getCurrentActivity(); return mReactApplicationContext.getCurrentActivity();
} }
@Override
public <T extends EventDispatcher> T getEventDispatcher() {
return mReactApplicationContext.getEventDispatcher();
}
} }

View File

@ -130,7 +130,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
int minTimeLeftInFrameForNonBatchedOperationMs) { int minTimeLeftInFrameForNonBatchedOperationMs) {
super(reactContext); super(reactContext);
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext); DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext);
mEventDispatcher = reactContext.getEventDispatcher(); mEventDispatcher = new EventDispatcher(reactContext);
mModuleConstants = createConstants(viewManagerResolver); mModuleConstants = createConstants(viewManagerResolver);
mCustomDirectEvents = UIManagerModuleConstants.getDirectEventTypeConstants(); mCustomDirectEvents = UIManagerModuleConstants.getDirectEventTypeConstants();
mUIImplementation = mUIImplementation =
@ -150,7 +150,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
int minTimeLeftInFrameForNonBatchedOperationMs) { int minTimeLeftInFrameForNonBatchedOperationMs) {
super(reactContext); super(reactContext);
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext); DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext);
mEventDispatcher = reactContext.getEventDispatcher(); mEventDispatcher = new EventDispatcher(reactContext);
mCustomDirectEvents = MapBuilder.newHashMap(); mCustomDirectEvents = MapBuilder.newHashMap();
mModuleConstants = createConstants(viewManagersList, null, mCustomDirectEvents); mModuleConstants = createConstants(viewManagersList, null, mCustomDirectEvents);
mUIImplementation = mUIImplementation =
@ -704,10 +704,6 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
mUIImplementation.setViewHierarchyUpdateDebugListener(listener); mUIImplementation.setViewHierarchyUpdateDebugListener(listener);
} }
/**
* This method is deprecated, use {@link ReactContext#getEventDispatcher()}.
*/
@Deprecated
public EventDispatcher getEventDispatcher() { public EventDispatcher getEventDispatcher() {
return mEventDispatcher; return mEventDispatcher;
} }

View File

@ -56,8 +56,7 @@ import javax.annotation.Nullable;
* EVENT_TYPE_ID_MASK = 0x0000ffff00000000 * EVENT_TYPE_ID_MASK = 0x0000ffff00000000
* COALESCING_KEY_MASK = 0xffff000000000000 * COALESCING_KEY_MASK = 0xffff000000000000
*/ */
public class EventDispatcher implements LifecycleEventListener, public class EventDispatcher implements LifecycleEventListener {
com.facebook.react.bridge.EventDispatcher {
private static final Comparator<Event> EVENT_COMPARATOR = new Comparator<Event>() { private static final Comparator<Event> EVENT_COMPARATOR = new Comparator<Event>() {
@Override @Override

View File

@ -10,6 +10,7 @@ import android.widget.CompoundButton;
import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContext;
import com.facebook.react.uimanager.SimpleViewManager; import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewProps; import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
@ -25,7 +26,7 @@ public class ReactCheckBoxManager extends SimpleViewManager<ReactCheckBox> {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
ReactContext reactContext = (ReactContext) buttonView.getContext(); ReactContext reactContext = (ReactContext) buttonView.getContext();
reactContext reactContext
.<EventDispatcher>getEventDispatcher() .getNativeModule(UIManagerModule.class).getEventDispatcher()
.dispatchEvent(new ReactCheckBoxEvent(buttonView.getId(), isChecked)); .dispatchEvent(new ReactCheckBoxEvent(buttonView.getId(), isChecked));
} }
}; };

View File

@ -19,6 +19,7 @@ import com.facebook.react.common.ReactConstants;
import com.facebook.react.module.annotations.ReactModule; import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewGroupManager; import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
@ -51,7 +52,7 @@ public class ReactDrawerLayoutManager extends ViewGroupManager<ReactDrawerLayout
view.setDrawerListener( view.setDrawerListener(
new DrawerEventEmitter( new DrawerEventEmitter(
view, view,
reactContext.<EventDispatcher>getEventDispatcher())); reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()));
} }
@Override @Override

View File

@ -50,6 +50,7 @@ import com.facebook.react.common.build.ReactBuildConfig;
import com.facebook.react.modules.fresco.ReactNetworkImageRequest; import com.facebook.react.modules.fresco.ReactNetworkImageRequest;
import com.facebook.react.uimanager.FloatUtil; import com.facebook.react.uimanager.FloatUtil;
import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.views.imagehelper.ImageSource; import com.facebook.react.views.imagehelper.ImageSource;
import com.facebook.react.views.imagehelper.MultiSourceHelper; import com.facebook.react.views.imagehelper.MultiSourceHelper;
@ -231,7 +232,7 @@ public class ReactImageView extends GenericDraweeView {
if (!shouldNotify) { if (!shouldNotify) {
mControllerListener = null; mControllerListener = null;
} else { } else {
final EventDispatcher mEventDispatcher = ((ReactContext) getContext()).<EventDispatcher>getEventDispatcher(); final EventDispatcher mEventDispatcher = ((ReactContext) getContext()).getNativeModule(UIManagerModule.class).getEventDispatcher();
mControllerListener = new BaseControllerListener<ImageInfo>() { mControllerListener = new BaseControllerListener<ImageInfo>() {
@Override @Override

View File

@ -12,6 +12,7 @@ import com.facebook.react.common.MapBuilder;
import com.facebook.react.module.annotations.ReactModule; import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.LayoutShadowNode; import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewGroupManager; import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
@ -71,7 +72,7 @@ public class ReactModalHostManager extends ViewGroupManager<ReactModalHostView>
ThemedReactContext reactContext, ThemedReactContext reactContext,
final ReactModalHostView view) { final ReactModalHostView view) {
final EventDispatcher dispatcher = final EventDispatcher dispatcher =
reactContext.<EventDispatcher>getEventDispatcher(); reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
view.setOnRequestCloseListener( view.setOnRequestCloseListener(
new ReactModalHostView.OnRequestCloseListener() { new ReactModalHostView.OnRequestCloseListener() {
@Override @Override

View File

@ -370,7 +370,7 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
private EventDispatcher getEventDispatcher() { private EventDispatcher getEventDispatcher() {
ReactContext reactContext = getReactContext(); ReactContext reactContext = getReactContext();
return reactContext.<EventDispatcher>getEventDispatcher(); return reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
} }
} }
} }

View File

@ -19,6 +19,7 @@ import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.SimpleViewManager; import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewProps; import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
@ -86,7 +87,7 @@ public abstract class ReactPickerManager extends SimpleViewManager<ReactPicker>
picker.setOnSelectListener( picker.setOnSelectListener(
new PickerEventEmitter( new PickerEventEmitter(
picker, picker,
reactContext.<EventDispatcher>getEventDispatcher())); reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()));
} }
private static class ReactPickerAdapter extends ArrayAdapter<ReadableMap> { private static class ReactPickerAdapter extends ArrayAdapter<ReadableMap> {

View File

@ -11,6 +11,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
/** /**
@ -68,7 +69,7 @@ public class ReactScrollViewHelper {
} }
ReactContext reactContext = (ReactContext) scrollView.getContext(); ReactContext reactContext = (ReactContext) scrollView.getContext();
reactContext.<EventDispatcher>getEventDispatcher().dispatchEvent( reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
ScrollEvent.obtain( ScrollEvent.obtain(
scrollView.getId(), scrollView.getId(),
scrollEventType, scrollEventType,

View File

@ -19,6 +19,7 @@ import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.uimanager.ReactShadowNodeImpl; import com.facebook.react.uimanager.ReactShadowNodeImpl;
import com.facebook.react.uimanager.SimpleViewManager; import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewProps; import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
@ -107,7 +108,7 @@ public class ReactSliderManager extends SimpleViewManager<ReactSlider> {
@Override @Override
public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) { public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) {
ReactContext reactContext = (ReactContext) seekbar.getContext(); ReactContext reactContext = (ReactContext) seekbar.getContext();
reactContext.<EventDispatcher>getEventDispatcher().dispatchEvent( reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
new ReactSliderEvent( new ReactSliderEvent(
seekbar.getId(), seekbar.getId(),
((ReactSlider) seekbar).toRealProgress(progress), ((ReactSlider) seekbar).toRealProgress(progress),
@ -121,7 +122,7 @@ public class ReactSliderManager extends SimpleViewManager<ReactSlider> {
@Override @Override
public void onStopTrackingTouch(SeekBar seekbar) { public void onStopTrackingTouch(SeekBar seekbar) {
ReactContext reactContext = (ReactContext) seekbar.getContext(); ReactContext reactContext = (ReactContext) seekbar.getContext();
reactContext.<EventDispatcher>getEventDispatcher().dispatchEvent( reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
new ReactSlidingCompleteEvent( new ReactSlidingCompleteEvent(
seekbar.getId(), seekbar.getId(),
((ReactSlider) seekbar).toRealProgress(seekbar.getProgress()))); ((ReactSlider) seekbar).toRealProgress(seekbar.getProgress())));

View File

@ -16,6 +16,7 @@ import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.common.MapBuilder; import com.facebook.react.common.MapBuilder;
import com.facebook.react.module.annotations.ReactModule; import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewGroupManager; import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.ViewProps; import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactProp;
@ -88,7 +89,7 @@ public class SwipeRefreshLayoutManager extends ViewGroupManager<ReactSwipeRefres
new OnRefreshListener() { new OnRefreshListener() {
@Override @Override
public void onRefresh() { public void onRefresh() {
reactContext.<EventDispatcher>getEventDispatcher() reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
.dispatchEvent(new RefreshEvent(view.getId())); .dispatchEvent(new RefreshEvent(view.getId()));
} }
}); });

View File

@ -17,6 +17,7 @@ import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.uimanager.ReactShadowNodeImpl; import com.facebook.react.uimanager.ReactShadowNodeImpl;
import com.facebook.react.uimanager.SimpleViewManager; import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewProps; import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
@ -104,7 +105,7 @@ public class ReactSwitchManager extends SimpleViewManager<ReactSwitch> {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
ReactContext reactContext = (ReactContext) buttonView.getContext(); ReactContext reactContext = (ReactContext) buttonView.getContext();
reactContext.<EventDispatcher>getEventDispatcher().dispatchEvent( reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
new ReactSwitchEvent( new ReactSwitchEvent(
buttonView.getId(), buttonView.getId(),
isChecked)); isChecked));

View File

@ -12,6 +12,7 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputConnectionWrapper; import android.view.inputmethod.InputConnectionWrapper;
import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -64,7 +65,7 @@ class ReactEditTextInputConnectionWrapper extends InputConnectionWrapper {
final ReactEditText editText final ReactEditText editText
) { ) {
super(target, false); super(target, false);
mEventDispatcher = reactContext.<EventDispatcher>getEventDispatcher(); mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
mEditText = editText; mEditText = editText;
} }

View File

@ -27,6 +27,7 @@ import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.UIManager;
import com.facebook.react.common.MapBuilder; import com.facebook.react.common.MapBuilder;
import com.facebook.react.module.annotations.ReactModule; import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.BaseViewManager; import com.facebook.react.uimanager.BaseViewManager;
@ -34,6 +35,7 @@ import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.Spacing; import com.facebook.react.uimanager.Spacing;
import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewDefaults; import com.facebook.react.uimanager.ViewDefaults;
import com.facebook.react.uimanager.ViewProps; import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactProp;
@ -693,7 +695,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
public ReactTextInputTextWatcher( public ReactTextInputTextWatcher(
final ReactContext reactContext, final ReactContext reactContext,
final ReactEditText editText) { final ReactEditText editText) {
mEventDispatcher = reactContext.<EventDispatcher>getEventDispatcher(); mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
mEditText = editText; mEditText = editText;
mPreviousText = null; mPreviousText = null;
} }
@ -751,7 +753,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
new View.OnFocusChangeListener() { new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) { public void onFocusChange(View v, boolean hasFocus) {
EventDispatcher eventDispatcher = EventDispatcher eventDispatcher =
reactContext.<EventDispatcher>getEventDispatcher(); reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
if (hasFocus) { if (hasFocus) {
eventDispatcher.dispatchEvent( eventDispatcher.dispatchEvent(
new ReactTextInputFocusEvent( new ReactTextInputFocusEvent(
@ -788,7 +790,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
// Additionally we always generate a `submit` event. // Additionally we always generate a `submit` event.
EventDispatcher eventDispatcher = EventDispatcher eventDispatcher =
reactContext.<EventDispatcher>getEventDispatcher(); reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
eventDispatcher.dispatchEvent( eventDispatcher.dispatchEvent(
new ReactTextInputSubmitEditingEvent( new ReactTextInputSubmitEditingEvent(
@ -817,7 +819,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
public ReactContentSizeWatcher(ReactEditText editText) { public ReactContentSizeWatcher(ReactEditText editText) {
mEditText = editText; mEditText = editText;
ReactContext reactContext = (ReactContext) editText.getContext(); ReactContext reactContext = (ReactContext) editText.getContext();
mEventDispatcher = reactContext.<EventDispatcher>getEventDispatcher(); mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
} }
@Override @Override
@ -856,7 +858,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
public ReactSelectionWatcher(ReactEditText editText) { public ReactSelectionWatcher(ReactEditText editText) {
mReactEditText = editText; mReactEditText = editText;
ReactContext reactContext = (ReactContext) editText.getContext(); ReactContext reactContext = (ReactContext) editText.getContext();
mEventDispatcher = reactContext.<EventDispatcher>getEventDispatcher(); mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
} }
@Override @Override
@ -888,7 +890,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
public ReactScrollWatcher(ReactEditText editText) { public ReactScrollWatcher(ReactEditText editText) {
mReactEditText = editText; mReactEditText = editText;
ReactContext reactContext = (ReactContext) editText.getContext(); ReactContext reactContext = (ReactContext) editText.getContext();
mEventDispatcher = reactContext.<EventDispatcher>getEventDispatcher(); mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
} }
@Override @Override

View File

@ -19,6 +19,7 @@ import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.common.MapBuilder; import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewGroupManager; import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
@ -117,7 +118,7 @@ public class ReactToolbarManager extends ViewGroupManager<ReactToolbar> {
@Override @Override
protected void addEventEmitters(final ThemedReactContext reactContext, final ReactToolbar view) { protected void addEventEmitters(final ThemedReactContext reactContext, final ReactToolbar view) {
final EventDispatcher mEventDispatcher = reactContext.<EventDispatcher>getEventDispatcher(); final EventDispatcher mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
view.setNavigationOnClickListener( view.setNavigationOnClickListener(
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override

View File

@ -15,6 +15,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContext;
import com.facebook.react.common.ReactConstants; import com.facebook.react.common.ReactConstants;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.uimanager.events.NativeGestureUtil; import com.facebook.react.uimanager.events.NativeGestureUtil;
import java.util.ArrayList; import java.util.ArrayList;
@ -158,7 +159,7 @@ public class ReactViewPager extends ViewPager {
public ReactViewPager(ReactContext reactContext) { public ReactViewPager(ReactContext reactContext) {
super(reactContext); super(reactContext);
mEventDispatcher = reactContext.<EventDispatcher>getEventDispatcher(); mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
mIsCurrentItemFromJs = false; mIsCurrentItemFromJs = false;
setOnPageChangeListener(new PageChangeListener()); setOnPageChangeListener(new PageChangeListener());
setAdapter(new Adapter()); setAdapter(new Adapter());

View File

@ -9,6 +9,7 @@ package com.facebook.react.views.webview;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import com.facebook.react.uimanager.UIManagerModule;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -686,7 +687,7 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
protected static void dispatchEvent(WebView webView, Event event) { protected static void dispatchEvent(WebView webView, Event event) {
ReactContext reactContext = (ReactContext) webView.getContext(); ReactContext reactContext = (ReactContext) webView.getContext();
EventDispatcher eventDispatcher = EventDispatcher eventDispatcher =
reactContext.<EventDispatcher>getEventDispatcher(); reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
eventDispatcher.dispatchEvent(event); eventDispatcher.dispatchEvent(event);
} }
} }