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

项目:react-native-android-activity    文件:ActivityStarterModule.java   
@ReactMethod
void callJavaScript() {
    Activity activity = getCurrentActivity();
    if (activity != null) {
        MainApplication application = (MainApplication) activity.getApplication();
        ReactNativeHost reactNativeHost = application.getReactNativeHost();
        ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager();
        ReactContext reactContext = reactInstanceManager.getCurrentReactContext();

        if (reactContext != null) {
            CatalystInstance catalystInstance = reactContext.getCatalystInstance();
            WritableNativeArray params = new WritableNativeArray();
            params.pushString("Hello, JavaScript!");
            catalystInstance.callFunction("JavaScriptVisibleToJava", "alert", params);
        }
    }
}
项目:react-native-threads    文件:RNThreadModule.java   
public RNThreadModule(final ReactApplicationContext reactContext, ReactNativeHost reactNativehost, ReactPackage additionalThreadPackages[]) {
  super(reactContext);
  this.reactApplicationContext = reactContext;
  threads = new HashMap<>();
  this.reactNativeHost = reactNativehost;
  this.additionalThreadPackages = additionalThreadPackages;
  reactContext.addLifecycleEventListener(this);
}
项目:react-native-android-activity    文件:MainActivity.java   
/**
 * Demonstrates how to add a custom option to the dev menu.
 * https://stackoverflow.com/a/44882371/3968276
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MainApplication application = (MainApplication) getApplication();
    ReactNativeHost reactNativeHost = application.getReactNativeHost();
    ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager();
    DevSupportManager devSupportManager = reactInstanceManager.getDevSupportManager();
    devSupportManager.addCustomDevOption("Custom dev option", new DevOptionHandler() {
        @Override
        public void onOptionSelected() {
            Toast.makeText(MainActivity.this, "Hello from custom dev option", Toast.LENGTH_SHORT).show();
        }
    });
}
项目: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-background-job    文件:Utils.java   
/** Check whether on not the React Native application is in foreground. */
public static boolean isReactNativeAppInForeground(@NonNull ReactNativeHost reactNativeHost) {
  if (!reactNativeHost.hasInstance()) {
    // If the app was force-stopped the instace will be destroyed. The instance can't be created from a background thread.
    return false;
  }
  ReactContext reactContext = reactNativeHost.getReactInstanceManager().getCurrentReactContext();
  return reactContext != null && reactContext.getLifecycleState() == LifecycleState.RESUMED;
}
项目:FingerPrint-Authentication-With-React-Native-Android    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
}
项目:react-native-nearby    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-camera-android-simple    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-twitterkit    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
}
项目:ReduxSimple    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-collapsing-toolbar    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-system-setting    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-message-compose    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-andorid-shadow    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:yyox    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-gl-model-view    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-gl-model-view    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:ReactNativeAndroidAudioConverter    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-recyclerview-list    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-ethereum    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-android-wear-demo    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-settings    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-tensorflow    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-alert    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
}
项目:react-native-android-material-calendar-view    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-sync-adapter    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-threads    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-threads    文件:RNThreadPackage.java   
public RNThreadPackage(ReactNativeHost reactNativeHost, ReactPackage... additionalThreadPackages) {
    this.reactNativeHost = reactNativeHost;
    this.additionalThreadPackages = additionalThreadPackages;
}
项目:izzati    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:onfido-sdk-react-native-sample-app    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-growingio    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-twilio-chat    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
}
项目:react-native-android-fragment    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
}
项目:rn-crash-reporter    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-call-log    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-sunmi-inner-printer    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:LLphoto    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:react-native-mpush    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
}
项目:react-native-sockets    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
项目:WaveView-RN    文件:MainApplication.java   
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}