com.facebook.react.bridge.JavaScriptExecutorFactory Java Examples

The following examples show how to use com.facebook.react.bridge.JavaScriptExecutorFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
@ThreadConfined(UI)
private void recreateReactContextInBackground(
  JavaScriptExecutorFactory jsExecutorFactory,
  JSBundleLoader jsBundleLoader) {
  Log.d(ReactConstants.TAG, "ReactInstanceManager.recreateReactContextInBackground()");
  UiThreadUtil.assertOnUiThread();

  final ReactContextInitParams initParams = new ReactContextInitParams(
    jsExecutorFactory,
    jsBundleLoader);
  if (mCreateReactContextThread == null) {
    runCreateReactContextOnNewThread(initParams);
  } else {
    mPendingReactContextInitParams = initParams;
  }
}
 
Example #2
Source File: ReactContextBuilder.java    From react-native-threads with MIT License 5 votes vote down vote up
private JavaScriptExecutorFactory getJSExecutorFactory() {
    try {
        String appName = Uri.encode(parentContext.getPackageName());
        String deviceName = Uri.encode(getFriendlyDeviceName());
        // If JSC is included, use it as normal
        SoLoader.loadLibrary("jscexecutor");
        return new JSCExecutorFactory(appName, deviceName);
    } catch (UnsatisfiedLinkError jscE) {
        // Otherwise use Hermes
        return new HermesExecutorFactory();
    }
}
 
Example #3
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 4 votes vote down vote up
public ReactContextInitParams(
    JavaScriptExecutorFactory jsExecutorFactory,
    JSBundleLoader jsBundleLoader) {
  mJsExecutorFactory = Assertions.assertNotNull(jsExecutorFactory);
  mJsBundleLoader = Assertions.assertNotNull(jsBundleLoader);
}
 
Example #4
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 4 votes vote down vote up
public JavaScriptExecutorFactory getJsExecutorFactory() {
  return mJsExecutorFactory;
}
 
Example #5
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 4 votes vote down vote up
ReactInstanceManager(
  Context applicationContext,
  @Nullable Activity currentActivity,
  @Nullable DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler,
  JavaScriptExecutorFactory javaScriptExecutorFactory,
  @Nullable JSBundleLoader bundleLoader,
  @Nullable String jsMainModulePath,
  List<ReactPackage> packages,
  boolean useDeveloperSupport,
  @Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
  LifecycleState initialLifecycleState,
  @Nullable UIImplementationProvider mUIImplementationProvider,
  NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler,
  @Nullable RedBoxHandler redBoxHandler,
  boolean lazyViewManagersEnabled,
  @Nullable DevBundleDownloadListener devBundleDownloadListener,
  int minNumShakes,
  int minTimeLeftInFrameForNonBatchedOperationMs,
  @Nullable JSIModulePackage jsiModulePackage,
  @Nullable Map<String, RequestHandler> customPackagerCommandHandlers) {
  Log.d(ReactConstants.TAG, "ReactInstanceManager.ctor()");
  initializeSoLoaderIfNecessary(applicationContext);

  DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(applicationContext);

  mApplicationContext = applicationContext;
  mCurrentActivity = currentActivity;
  mDefaultBackButtonImpl = defaultHardwareBackBtnHandler;
  mJavaScriptExecutorFactory = javaScriptExecutorFactory;
  mBundleLoader = bundleLoader;
  mJSMainModulePath = jsMainModulePath;
  mPackages = new ArrayList<>();
  mUseDeveloperSupport = useDeveloperSupport;
  mDevSupportManager =
      DevSupportManagerFactory.create(
          applicationContext,
          createDevHelperInterface(),
          mJSMainModulePath,
          useDeveloperSupport,
          redBoxHandler,
          devBundleDownloadListener,
          minNumShakes,
          customPackagerCommandHandlers);
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  mLifecycleState = initialLifecycleState;
  mMemoryPressureRouter = new MemoryPressureRouter(applicationContext);
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  synchronized (mPackages) {
    PrinterHolder.getPrinter()
        .logMessage(ReactDebugOverlayTags.RN_CORE, "RNCore: Use Split Packages");
    mPackages.add(
        new CoreModulesPackage(
            this,
            new DefaultHardwareBackBtnHandler() {
              @Override
              public void invokeDefaultOnBackPressed() {
                ReactInstanceManager.this.invokeDefaultOnBackPressed();
              }
            },
            mUIImplementationProvider,
            lazyViewManagersEnabled,
            minTimeLeftInFrameForNonBatchedOperationMs));
    if (mUseDeveloperSupport) {
      mPackages.add(new DebugCorePackage());
    }
    mPackages.addAll(packages);
  }
  mJSIModulePackage = jsiModulePackage;

  // Instantiate ReactChoreographer in UI thread.
  ReactChoreographer.initialize();
  if (mUseDeveloperSupport) {
    mDevSupportManager.startInspector();
  }
}
 
Example #6
Source File: ReactInstanceManagerBuilder.java    From react-native-GPay with MIT License 4 votes vote down vote up
/**
 * Factory for desired implementation of JavaScriptExecutor.
 */
public ReactInstanceManagerBuilder setJavaScriptExecutorFactory(
  @Nullable JavaScriptExecutorFactory javaScriptExecutorFactory) {
  mJavaScriptExecutorFactory = javaScriptExecutorFactory;
  return this;
}
 
Example #7
Source File: ReactNativeHost.java    From react-native-GPay with MIT License 2 votes vote down vote up
/**
 * Get the {@link JavaScriptExecutorFactory}.  Override this to use a custom
 * Executor.
 */
protected @Nullable JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
  return null;
}