Example usage for com.facebook.react.jscexecutor JSCExecutorFactory JSCExecutorFactory

List of usage examples for com.facebook.react.jscexecutor JSCExecutorFactory JSCExecutorFactory

Introduction

In this page you can find the example usage for com.facebook.react.jscexecutor JSCExecutorFactory JSCExecutorFactory.

Prototype

public JSCExecutorFactory(String appName, String deviceName) 

Source Link

Usage

From source file:org.jitsi.meet.sdk.ReactInstanceManagerHolder.java

License:Apache License

/**
 * Internal method to initialize the React Native instance manager. We
 * create a single instance in order to load the JavaScript bundle a single
 * time. All {@code ReactRootView} instances will be tied to the one and
 * only {@code ReactInstanceManager}.//  ww w. jav a 2  s.c o m
 *
 * @param activity {@code Activity} current running Activity.
 */
static void initReactInstanceManager(Activity activity) {
    if (reactInstanceManager != null) {
        return;
    }

    SoLoader.init(activity, /* native exopackage */ false);

    List<ReactPackage> packages = new ArrayList<>(Arrays.asList(
            new com.BV.LinearGradient.LinearGradientPackage(), new com.calendarevents.CalendarEventsPackage(),
            new com.corbt.keepawake.KCKeepAwakePackage(), new com.facebook.react.shell.MainReactPackage(),
            new com.horcrux.svg.SvgPackage(), new com.ocetnik.timer.BackgroundTimerPackage(),
            new com.reactnativecommunity.asyncstorage.AsyncStoragePackage(),
            new com.reactnativecommunity.netinfo.NetInfoPackage(),
            new com.reactnativecommunity.webview.RNCWebViewPackage(), new com.rnimmersive.RNImmersivePackage(),
            new com.zmxv.RNSound.RNSoundPackage(), new ReactPackageAdapter() {
                @Override
                public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
                    return ReactInstanceManagerHolder.createNativeModules(reactContext);
                }

                @Override
                public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
                    return ReactInstanceManagerHolder.createViewManagers(reactContext);
                }
            }));

    try {
        Class<?> googlePackageClass = Class.forName("co.apptailor.googlesignin.RNGoogleSigninPackage");
        Constructor constructor = googlePackageClass.getConstructor();
        packages.add((ReactPackage) constructor.newInstance());
    } catch (Exception e) {
        // Ignore any error, the module is not compiled when LIBRE_BUILD is enabled.
    }

    // Keep on using JSC, the jury is out on Hermes.
    JSCExecutorFactory jsFactory = new JSCExecutorFactory("", "");

    reactInstanceManager = ReactInstanceManager.builder().setApplication(activity.getApplication())
            .setCurrentActivity(activity).setBundleAssetName("index.android.bundle")
            .setJSMainModulePath("index.android").setJavaScriptExecutorFactory(jsFactory).addPackages(packages)
            .setUseDeveloperSupport(BuildConfig.DEBUG).setInitialLifecycleState(LifecycleState.RESUMED).build();

    // Disable delta updates on Android, they have caused trouble.
    DevInternalSettings devSettings = (DevInternalSettings) reactInstanceManager.getDevSupportManager()
            .getDevSettings();
    if (devSettings != null) {
        devSettings.setBundleDeltasEnabled(false);
    }

    // Register our uncaught exception handler.
    JitsiMeetUncaughtExceptionHandler.register();
}