Java 类com.facebook.react.ReactApplication 实例源码

项目:react-native-async-storage-dev-menu-item    文件:AsyncStorageDevMenuItemModule.java   
@ReactMethod
public void initialize() {
  ReactApplication application = (ReactApplication)getReactApplicationContext()
    .getCurrentActivity()
    .getApplication();

  DevSupportManager devSupportManager = application
    .getReactNativeHost()
    .getReactInstanceManager()
    .getDevSupportManager();

  devSupportManager.addCustomDevOption("Log AsyncStorage", new DevOptionHandler() {
      @Override
      public void onOptionSelected() {
        getReactApplicationContext()
          .getJSModule(RCTNativeAppEventEmitter.class)
          .emit("LogAsyncStorage", null);
      }
  });
}
项目:react-native-restart    文件:ReactNativeRestart.java   
private ReactInstanceManager resolveInstanceManager() throws NoSuchFieldException, IllegalAccessException {
    ReactInstanceManager instanceManager = getReactInstanceManager();
    if (instanceManager != null) {
        return instanceManager;
    }

    final Activity currentActivity = getCurrentActivity();
    if (currentActivity == null) {
        return null;
    }

    ReactApplication reactApplication = (ReactApplication) currentActivity.getApplication();
    instanceManager = reactApplication.getReactNativeHost().getReactInstanceManager();

    return instanceManager;
}
项目:react-native-devsettings-android    文件:DevSettingsModule.java   
public DevSettingsModule(ReactApplicationContext context) {
    super(context);

    reactContext = context;
    rnHost = ((ReactApplication) context.getApplicationContext())
      .getReactNativeHost();
    instanceManager = rnHost.getReactInstanceManager();
    useDeveloperSupport = rnHost.getUseDeveloperSupport();
    if (useDeveloperSupport) {
        devManager = ((DevSupportManagerImpl) instanceManager.getDevSupportManager());
    }
}
项目:react-native-background-job    文件:ReactNativeEventStarter.java   
@Nullable @Override protected HeadlessJsTaskConfig getTaskConfig(Intent intent) {
  Log.d(LOG_TAG, "getTaskConfig() called with: intent = [" + intent + "]");
  Bundle extras = intent.getExtras();
  boolean allowExecutionInForeground = extras.getBoolean("allowExecutionInForeground", false);
  long timeout = extras.getLong("timeout", 2000);
  // For task with quick execution period additional check is required
  ReactNativeHost reactNativeHost =
      ((ReactApplication) getApplicationContext()).getReactNativeHost();
  boolean appInForeground = Utils.isReactNativeAppInForeground(reactNativeHost);
  if (appInForeground && !allowExecutionInForeground) {
    return null;
  }
  return new HeadlessJsTaskConfig(intent.getStringExtra("jobKey"), Arguments.fromBundle(extras),
      timeout, allowExecutionInForeground);
}
项目:react-native-sentry    文件:RNSentryModule.java   
public RNSentryModule(ReactApplicationContext reactContext, ReactApplication reactApplication) {
    super(reactContext);
    this.reactContext = reactContext;
    this.reactApplication = reactApplication;
    RNSentryModule.extra = new WritableNativeMap();
    RNSentryModule.packageInfo = getPackageInfo(reactContext);
}
项目:react-native-preloader    文件:ReactPreLoader.java   
/**
 * Pre-load {@link ReactRootView} to local {@link Map}, you may want to
 * load it in previous activity.
 */
public static void init(Activity activity, ReactInfo reactInfo) {
    if (CACHE_VIEW_MAP.get(reactInfo.getMainComponentName()) != null) {
        return;
    }
    ReactRootView rootView = new ReactRootView(new MutableContextWrapper(activity));
    rootView.startReactApplication(
            ((ReactApplication) activity.getApplication()).getReactNativeHost().getReactInstanceManager(),
            reactInfo.getMainComponentName(),
            reactInfo.getLaunchOptions());
    CACHE_VIEW_MAP.put(reactInfo.getMainComponentName(), rootView);
}
项目:react-native-notifications    文件:GcmToken.java   
protected void sendTokenToJS() {
    final ReactInstanceManager instanceManager = ((ReactApplication) mAppContext).getReactNativeHost().getReactInstanceManager();
    final ReactContext reactContext = instanceManager.getCurrentReactContext();

    // Note: Cannot assume react-context exists cause this is an async dispatched service.
    if (reactContext != null && reactContext.hasActiveCatalystInstance()) {
        reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(TOKEN_RECEIVED_EVENT_NAME, sToken);
    }
}
项目:react-native-update    文件:RCTUpdate.java   
private ReactInstanceManager resolveInstanceManager() throws NoSuchFieldException, IllegalAccessException {
    ReactInstanceManager instanceManager;
    final Activity currentActivity = getCurrentActivity();
    if (currentActivity == null) {
        return null;
    }

    ReactApplication reactApplication = (ReactApplication) currentActivity.getApplication();
    instanceManager = reactApplication.getReactNativeHost().getReactInstanceManager();

    return instanceManager;
}
项目:react-native-workers    文件:WorkerModule.java   
private ReactInstanceManager getReactInstanceManager() {
    ReactApplication reactApplication = (ReactApplication)getCurrentActivity().getApplication();
    return reactApplication.getReactNativeHost().getReactInstanceManager();
}
项目:react-native-background-job    文件:ReactNativeEventStarter.java   
ReactNativeEventStarter(@NonNull Context context) {
  this.context = context;
  reactNativeHost = ((ReactApplication) context.getApplicationContext()).getReactNativeHost();
}
项目:react-native-sentry    文件:RNSentryPackage.java   
public RNSentryPackage(ReactApplication reactApplication) {
    this.reactApplication = reactApplication;
}
项目:react-native-sentry    文件:RNSentryPackage.java   
public ReactApplication getReactApplication() {
    return reactApplication;
}
项目:react-native-sentry    文件:RNSentryModule.java   
public ReactApplication getReactApplication() {
    return reactApplication;
}
项目:react-native-notifications    文件:GcmToken.java   
protected GcmToken(Context appContext) {
    if (!(appContext instanceof ReactApplication)) {
        throw new IllegalStateException("Application instance isn't a react-application");
    }
    mAppContext = appContext;
}
项目:react-native-android-fragment    文件:ReactFragment.java   
/**
 * Get the {@link ReactNativeHost} used by this app. By default, assumes
 * {@link Activity#getApplication()} is an instance of {@link ReactApplication} and calls
 * {@link ReactApplication#getReactNativeHost()}. Override this method if your application class
 * does not implement {@code ReactApplication} or you simply have a different mechanism for
 * storing a {@code ReactNativeHost}, e.g. as a static field somewhere.
 */
protected ReactNativeHost getReactNativeHost() {
    return ((ReactApplication) getActivity().getApplication()).getReactNativeHost();
}
项目:react-native-preloader    文件:MrReactActivity.java   
/**
 * Get the {@link ReactNativeHost} used by this app. By default, assumes {@link #getApplication()}
 * is an instance of {@link ReactApplication} and calls
 * {@link ReactApplication#getReactNativeHost()}. Override this method if your application class
 * does not implement {@code ReactApplication} or you simply have a different mechanism for
 * storing a {@code ReactNativeHost}, e.g. as a static field somewhere.
 */
protected ReactNativeHost getReactNativeHost() {
    return ((ReactApplication) getApplication()).getReactNativeHost();
}