List of usage examples for com.facebook.react ReactInstanceManager getCurrentReactContext
@VisibleForTesting
public @Nullable ReactContext getCurrentReactContext()
From source file:com.statex.Util.java
License:Open Source License
public static void sendEvent(@NonNull ReactInstanceManager manager, @NonNull String eventName, @Nullable WritableMap params) {// w ww.j a v a 2 s. c o m ReactContext reactContext = manager.getCurrentReactContext(); if (reactContext != null) { reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, params); } }
From source file:org.jitsi.meet.sdk.JitsiMeetActivityDelegate.java
License:Apache License
/** * {@link Activity} lifecycle method which should be called from * {@code Activity#onPause} so we can do the required internal processing. * * @param activity {@code Activity} being paused. *///w ww . j a v a 2 s . c o m public static void onHostPause(Activity activity) { ReactInstanceManager reactInstanceManager = ReactInstanceManagerHolder.getReactInstanceManager(); if (reactInstanceManager != null) { // Try to avoid a crash because some devices trip on this assert: // https://github.com/facebook/react-native/blob/df4e67fe75d781d1eb264128cadf079989542755/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java#L512 // Why this happens is a mystery wrapped in an enigma. ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); if (activity == reactContext.getCurrentActivity()) { reactInstanceManager.onHostPause(activity); } } }
From source file:org.jitsi.meet.sdk.ReactInstanceManagerHolder.java
License:Apache License
/** * Helper function to send an event to JavaScript. * * @param eventName {@code String} containing the event name. * @param data {@code Object} optional ancillary data for the event. *//* w w w. j a va2s . c om*/ static void emitEvent(String eventName, @Nullable Object data) { ReactInstanceManager reactInstanceManager = ReactInstanceManagerHolder.getReactInstanceManager(); if (reactInstanceManager != null) { ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); if (reactContext != null) { reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, data); } } }