com.facebook.react.ReactInstanceManagerBuilder Java Examples

The following examples show how to use com.facebook.react.ReactInstanceManagerBuilder. 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: NavigationReactNativeHost.java    From react-native-navigation with MIT License 6 votes vote down vote up
protected ReactInstanceManager createReactInstanceManager() {
    ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setJSMainModulePath(getJSMainModuleName())
            .setUseDeveloperSupport(getUseDeveloperSupport())
            .setRedBoxHandler(getRedBoxHandler())
            .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
            .setUIImplementationProvider(getUIImplementationProvider())
            .setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
            .setJSIModulesPackage(getJSIModulePackage())
            .setDevBundleDownloadListener(getDevBundleDownloadListener());

    for (ReactPackage reactPackage : getPackages()) {
        builder.addPackage(reactPackage);
    }

    String jsBundleFile = getJSBundleFile();
    if (jsBundleFile != null) {
        builder.setJSBundleFile(jsBundleFile);
    } else {
        builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
    }
    return builder.build();
}
 
Example #2
Source File: NavigationReactNativeHost.java    From react-native-navigation with MIT License 6 votes vote down vote up
protected ReactInstanceManager createReactInstanceManager() {
    ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setJSMainModulePath(getJSMainModuleName())
            .setUseDeveloperSupport(getUseDeveloperSupport())
            .setRedBoxHandler(getRedBoxHandler())
            .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
            .setUIImplementationProvider(getUIImplementationProvider())
            .setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
            .setJSIModulesPackage(getJSIModulePackage())
            .setDevBundleDownloadListener(getDevBundleDownloadListener());

    for (ReactPackage reactPackage : getPackages()) {
        builder.addPackage(reactPackage);
    }

    String jsBundleFile = getJSBundleFile();
    if (jsBundleFile != null) {
        builder.setJSBundleFile(jsBundleFile);
    } else {
        builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
    }
    return builder.build();
}
 
Example #3
Source File: NavigationReactNativeHost.java    From react-native-navigation with MIT License 6 votes vote down vote up
protected ReactInstanceManager createReactInstanceManager() {
    ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setJSMainModulePath(getJSMainModuleName())
            .setUseDeveloperSupport(getUseDeveloperSupport())
            .setRedBoxHandler(getRedBoxHandler())
            .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
            .setUIImplementationProvider(getUIImplementationProvider())
            .setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
            .setDevBundleDownloadListener(getDevBundleDownloadListener());

    for (ReactPackage reactPackage : getPackages()) {
        builder.addPackage(reactPackage);
    }

    String jsBundleFile = getJSBundleFile();
    if (jsBundleFile != null) {
        builder.setJSBundleFile(jsBundleFile);
    } else {
        builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
    }
    return builder.build();
}
 
Example #4
Source File: NavigationReactNativeHost.java    From react-native-navigation with MIT License 6 votes vote down vote up
protected ReactInstanceManager createReactInstanceManager() {
    ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setJSMainModulePath(getJSMainModuleName())
            .setUseDeveloperSupport(getUseDeveloperSupport())
            .setRedBoxHandler(getRedBoxHandler())
            .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
            .setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
            .setJSIModulesPackage(getJSIModulePackage())
            .setDevBundleDownloadListener(getDevBundleDownloadListener());

    for (ReactPackage reactPackage : getPackages()) {
        builder.addPackage(reactPackage);
    }

    String jsBundleFile = getJSBundleFile();
    if (jsBundleFile != null) {
        builder.setJSBundleFile(jsBundleFile);
    } else {
        builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
    }
    return builder.build();
}
 
Example #5
Source File: NavigationReactNativeHost.java    From react-native-navigation with MIT License 6 votes vote down vote up
protected ReactInstanceManager createReactInstanceManager() {
    ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setJSMainModulePath(getJSMainModuleName())
            .setUseDeveloperSupport(getUseDeveloperSupport())
            .setRedBoxHandler(getRedBoxHandler())
            .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
            .setUIImplementationProvider(getUIImplementationProvider())
            .setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
            .setJSIModulesProvider(getJSIModulesProvider())
            .setDevBundleDownloadListener(getDevBundleDownloadListener());

    for (ReactPackage reactPackage : getPackages()) {
        builder.addPackage(reactPackage);
    }

    String jsBundleFile = getJSBundleFile();
    if (jsBundleFile != null) {
        builder.setJSBundleFile(jsBundleFile);
    } else {
        builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
    }
    return builder.build();
}
 
Example #6
Source File: NavigationReactNativeHost.java    From react-native-navigation with MIT License 6 votes vote down vote up
protected ReactInstanceManager createReactInstanceManager() {
    ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setJSMainModulePath(getJSMainModuleName())
            .setUseDeveloperSupport(getUseDeveloperSupport())
            .setRedBoxHandler(getRedBoxHandler())
            .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
            .setUIImplementationProvider(getUIImplementationProvider())
            .setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
            .setJSIModulesPackage(getJSIModulePackage())
            .setDevBundleDownloadListener(getDevBundleDownloadListener());

    for (ReactPackage reactPackage : getPackages()) {
        builder.addPackage(reactPackage);
    }

    String jsBundleFile = getJSBundleFile();
    if (jsBundleFile != null) {
        builder.setJSBundleFile(jsBundleFile);
    } else {
        builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
    }
    return builder.build();
}
 
Example #7
Source File: NavigationReactNativeHost.java    From react-native-navigation with MIT License 6 votes vote down vote up
protected ReactInstanceManager createReactInstanceManager() {
    ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setJSMainModulePath(getJSMainModuleName())
            .setUseDeveloperSupport(getUseDeveloperSupport())
            .setRedBoxHandler(getRedBoxHandler())
            .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
            .setUIImplementationProvider(getUIImplementationProvider())
            .setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
            .setJSIModulesPackage(getJSIModulePackage())
            .setDevBundleDownloadListener(getDevBundleDownloadListener());

    for (ReactPackage reactPackage : getPackages()) {
        builder.addPackage(reactPackage);
    }

    String jsBundleFile = getJSBundleFile();
    if (jsBundleFile != null) {
        builder.setJSBundleFile(jsBundleFile);
    } else {
        builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
    }
    return builder.build();
}
 
Example #8
Source File: QtalkServiceExternalRNViewInstanceManager.java    From imsdk-android with MIT License 5 votes vote down vote up
public static boolean buildBundle(Activity mActivity, String bundleName, String Entrance) {
        boolean is_ok = false;

        try {
            ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
                    .setApplication(mActivity.getApplication())
                    .setJSMainModulePath(Entrance)
                    .addPackage(new MainReactPackage())
                    .addPackage(new QtalkServiceReactPackage(mActivity))
                    .addPackage(new CookieManagerPackage())
                    .addPackage(new SvgPackage())
                    .addPackage(new RNI18nPackage())
                    .setUseDeveloperSupport(CommonConfig.isDebug)
                    .setInitialLifecycleState(LifecycleState.RESUMED);

            String localBundleFile = getLocalBundleFilePath(mActivity, bundleName);

            File file = new File(localBundleFile);
            if (file.exists()) {
                // load from cache
                is_ok = true;
                builder.setJSBundleFile(localBundleFile);
            } else {
//                 load from asset
                is_ok = false;
            }

            mReactInstanceManager = builder.build();


        } catch (Exception e) {
            is_ok = false;
        }

        return is_ok;
    }
 
Example #9
Source File: QtalkServiceRNViewInstanceManager.java    From imsdk-android with MIT License 5 votes vote down vote up
public static boolean buildBundle(Activity activity){
        boolean is_ok = false;

        try {
            ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
                    .setApplication(activity.getApplication())
                    .setJSMainModulePath("index.android")
                    .addPackage(new MainReactPackage())
                    .addPackage(new QtalkServiceReactPackage(activity))
                    .addPackage(new CookieManagerPackage())
                    .addPackage( new SvgPackage())
                    .addPackage(new RNI18nPackage())
                    .setUseDeveloperSupport(CommonConfig.isDebug)
                    .setInitialLifecycleState(LifecycleState.RESUMED);


            String localBundleFile = getLocalBundleFilePath(activity);

            File file = new File(localBundleFile);
            if (file.exists()) {
                // load from cache
                builder.setJSBundleFile(localBundleFile);
            } else {
//                 load from asset
                builder.setBundleAssetName(JS_BUNDLE_NAME);
            }

            mReactInstanceManager = builder.build();

            is_ok = true;
        }catch (Exception e){

        }

        return is_ok;
    }
 
Example #10
Source File: QTalkSearchRNViewInstanceManager.java    From imsdk-android with MIT License 5 votes vote down vote up
public static boolean buildBundle(Application application){
    boolean is_ok = false;

    try {
        ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
                .setApplication(application)
                .setJSMainModulePath("index")
                .addPackage(new MainReactPackage())
                .addPackage(new SearchReactPackage())
                .addPackage( new SvgPackage())
                .addPackage(new RNI18nPackage())
                .setUseDeveloperSupport(CommonConfig.isDebug)
                .setInitialLifecycleState(LifecycleState.RESUMED);

        String localBundleFile = getLocalBundleFilePath(application);

        File file = new File(localBundleFile);
        if (file.exists()) {
            // load from cache
            builder.setJSBundleFile(localBundleFile);
        } else {
            // load from asset
            builder.setBundleAssetName(JS_BUNDLE_NAME);
        }

        mReactInstanceManager = builder.build();

        is_ok = true;
    }catch (Exception e){

    }

    return is_ok;
}
 
Example #11
Source File: QTalkSearchRNViewOldInstanceManager.java    From imsdk-android with MIT License 5 votes vote down vote up
public static boolean buildBundle(Application application) {
    boolean is_ok = false;

    try {
        ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
                .setApplication(application)
                .setJSMainModulePath("index.android")
                .addPackage(new MainReactPackage())
                .addPackage(new SearchReactPackage())
                .addPackage(new SvgPackage())
                .addPackage(new RNI18nPackage())
                .setUseDeveloperSupport(CommonConfig.isDebug)
                .setInitialLifecycleState(LifecycleState.RESUMED);

        String localBundleFile = getLocalBundleFilePath(application);

        File file = new File(localBundleFile);
        if (file.exists()) {
            // load from cache
            builder.setJSBundleFile(localBundleFile);
        } else {
            // load from asset
            builder.setBundleAssetName(JS_BUNDLE_NAME);
        }

        mReactInstanceManager = builder.build();

        is_ok = true;
    } catch (Exception e) {

    }

    return is_ok;
}
 
Example #12
Source File: ReactTestHelper.java    From react-native-GPay with MIT License 4 votes vote down vote up
@Override
public ReactInstanceManagerBuilder getReactInstanceManagerBuilder() {
  return ReactInstanceManager.builder();
}
 
Example #13
Source File: ReactAppTestActivity.java    From react-native-GPay with MIT License 4 votes vote down vote up
public void loadBundle(ReactInstanceSpecForTest spec, String bundleName, boolean useDevSupport) {

    mBridgeIdleSignaler = new ReactBridgeIdleSignaler();

    final ReactInstanceManagerBuilder builder =
        ReactTestHelper.getReactTestFactory()
            .getReactInstanceManagerBuilder()
            .setApplication(getApplication())
            .setBundleAssetName(bundleName);
    if (!spec.getAlternativeReactPackagesForTest().isEmpty()) {
      builder.addPackages(spec.getAlternativeReactPackagesForTest());
    } else {
      builder.addPackage(new MainReactPackage());
    }
    builder
        .addPackage(new InstanceSpecForTestPackage(spec))
        // By not setting a JS module name, we force the bundle to be always loaded from
        // assets, not the devserver, even if dev mode is enabled (such as when testing redboxes).
        // This makes sense because we never run the devserver in tests.
        // .setJSMainModuleName()
        .setUseDeveloperSupport(useDevSupport)
        .setBridgeIdleDebugListener(mBridgeIdleSignaler)
        .setInitialLifecycleState(mLifecycleState)
        .setJSIModulesPackage(
            new JSIModulePackage() {
              @Override
              public List<JSIModuleSpec> getJSIModules(
                  final ReactApplicationContext reactApplicationContext,
                  final JavaScriptContextHolder jsContext) {
                return Arrays.<JSIModuleSpec>asList(
                    new JSIModuleSpec() {
                      @Override
                      public Class<? extends JSIModule> getJSIModuleClass() {
                        return UIManager.class;
                      }

                      @Override
                      public JSIModuleProvider getJSIModuleProvider() {
                        return new JSIModuleProvider() {
                          @Override
                          public FabricUIManager get() {
                            List<ViewManager> viewManagers =
                                mReactInstanceManager.getOrCreateViewManagers(
                                    reactApplicationContext);
                            EventDispatcher eventDispatcher =
                                reactApplicationContext
                                    .getNativeModule(UIManagerModule.class)
                                    .getEventDispatcher();
                            FabricUIManager fabricUIManager =
                                new FabricUIManager(
                                    reactApplicationContext,
                                    new ViewManagerRegistry(viewManagers),
                                    jsContext,
                                    eventDispatcher);
                            new FabricJSCBinding().installFabric(jsContext, fabricUIManager);
                            return fabricUIManager;
                          }
                        };
                      }
                    });
              }
            });

    final CountDownLatch latch = new CountDownLatch(1);
    runOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            mReactInstanceManager = builder.build();
            mReactInstanceManager.onHostResume(
                ReactAppTestActivity.this, ReactAppTestActivity.this);
            latch.countDown();
          }
        });
    try {
      latch.await(1000, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {

      throw new RuntimeException(
          "ReactInstanceManager never finished initializing " + bundleName, e);
    }
  }
 
Example #14
Source File: ReactTestFactory.java    From react-native-GPay with MIT License votes vote down vote up
ReactInstanceManagerBuilder getReactInstanceManagerBuilder();