com.facebook.react.ReactInstanceManager Java Examples

The following examples show how to use com.facebook.react.ReactInstanceManager. 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: MainActivity.java    From react-native-android-activity with MIT License 7 votes vote down vote up
/**
 * Demonstrates how to add a custom option to the dev menu.
 * https://stackoverflow.com/a/44882371/3968276
 * This only works from the debug build with dev options enabled.
 */
@Override
@CallSuper
protected void onCreate(@Nullable 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() {
            if (NotificationManagerCompat.from(MainActivity.this).areNotificationsEnabled()) {
                Toast.makeText(MainActivity.this, CUSTOM_DEV_OPTION_MESSAGE, Toast.LENGTH_LONG).show();
            } else {
                AlertDialog dialog = new AlertDialog.Builder(MainActivity.this).create();
                dialog.setTitle("Dev option");
                dialog.setMessage(CUSTOM_DEV_OPTION_MESSAGE);
                dialog.show();
            }
        }
    });
}
 
Example #2
Source File: BackgroundService.java    From react-native-gcm-android with MIT License 6 votes vote down vote up
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.d(TAG, "onStartCommand");

    mReactInstanceManager = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setBundleAssetName("index.android.bundle")
            .setJSMainModuleName("index.android")
            .addPackage(new MainReactPackage())
            .addPackage(new GcmPackage(intent))
            .addPackage(new NotificationPackage(null))
            .setUseDeveloperSupport(getBuildConfigDEBUG())
            .setInitialLifecycleState(LifecycleState.RESUMED)
            .build();
    mReactInstanceManager.createReactContextInBackground();

    return START_NOT_STICKY;
}
 
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)
            .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 #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())
            .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 #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)
            .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: ActivityStarterModule.java    From react-native-android-activity with MIT License 6 votes vote down vote up
@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!");

            // AFAIK, this approach to communicate from Java to JavaScript is officially undocumented.
            // Use at own risk; prefer events.
            // Note: Here we call 'alert', which shows UI. If this is done from an activity that
            // doesn't forward lifecycle events to React Native, it wouldn't work.
            catalystInstance.callFunction("JavaScriptVisibleToJava", "alert", params);
        }
    }
}
 
Example #7
Source File: ReactFragment.java    From react-native-android-fragment with Apache License 2.0 6 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();
    if (mReactRootView != null) {
        mReactRootView.unmountReactApplication();
        mReactRootView = null;
    }
    if (getReactNativeHost().hasInstance()) {
        ReactInstanceManager reactInstanceMgr = getReactNativeHost().getReactInstanceManager();

        // onDestroy may be called on a ReactFragment after another ReactFragment has been
        // created and resumed with the same React Instance Manager. Make sure we only clean up
        // host's React Instance Manager if no other React Fragment is actively using it.
        if (reactInstanceMgr.getLifecycleState() != LifecycleState.RESUMED) {
            reactInstanceMgr.onHostDestroy(getActivity());
            getReactNativeHost().clear();
        }
    }
}
 
Example #8
Source File: ExternalComponentViewControllerTest.java    From react-native-navigation with MIT License 6 votes vote down vote up
@Override
public void beforeEach() {
    componentCreator = spy(new FragmentCreatorMock());
    activity = newActivity();
    ec = createExternalComponent();
    reactInstanceManager = Mockito.mock(ReactInstanceManager.class);
    emitter = Mockito.mock(EventEmitter.class);
    childRegistry = new ChildControllersRegistry();
    uut = spy(new ExternalComponentViewController(activity,
            childRegistry,
            "fragmentId",
            new Presenter(activity, Options.EMPTY),
            ec,
            componentCreator,
            reactInstanceManager,
            emitter,
            new ExternalComponentPresenter(),
            new Options())
    );
}
 
Example #9
Source File: RestartModule.java    From react-native-restart with MIT License 6 votes vote down vote up
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;
}
 
Example #10
Source File: JsLoaderUtil.java    From MetroExample with Apache License 2.0 6 votes vote down vote up
public static void createReactContext(Application application, ReactContextCallBack callBack) {
    if (jsState.isDev) {
        if(callBack != null) callBack.onInitialized();
        return;
    }
    final ReactInstanceManager manager = getReactIM(application);
    if (!manager.hasStartedCreatingInitialContext()) {
        manager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
            @Override
            public void onReactContextInitialized(ReactContext context) {
                if (callBack != null) callBack.onInitialized();
                manager.removeReactInstanceEventListener(this);
            }
        });
        manager.createReactContextInBackground();
    } else {
        if (callBack != null) callBack.onInitialized();
    }
}
 
Example #11
Source File: RCTUpdate.java    From react-native-update with MIT License 6 votes vote down vote up
private void setJSBundle(ReactInstanceManager instanceManager, String latestJSBundleFile) throws IllegalAccessException {
    try {
        JSBundleLoader latestJSBundleLoader;
        if (latestJSBundleFile.toLowerCase().startsWith("assets://")) {
            latestJSBundleLoader = JSBundleLoader.createAssetLoader(getReactApplicationContext(), latestJSBundleFile, false);
        } else {
            latestJSBundleLoader = JSBundleLoader.createFileLoader(latestJSBundleFile);
        }

        Field bundleLoaderField = instanceManager.getClass().getDeclaredField("mBundleLoader");
        bundleLoaderField.setAccessible(true);
        bundleLoaderField.set(instanceManager, latestJSBundleLoader);
    } catch (Exception e) {
        throw new IllegalAccessException("Could not setJSBundle");
    }
}
 
Example #12
Source File: MainActivity.java    From react-native-android-audio-streaming-aac with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReactRootView = new ReactRootView(this);

    mReactInstanceManager = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setBundleAssetName("index.android.bundle")
            .setJSMainModuleName("index.android")
            .addPackage(new MainReactPackage())
            .addPackage(new AACStreamingPackage(MainActivity.class))      // <------- add package
            .setUseDeveloperSupport(BuildConfig.DEBUG)
            .setInitialLifecycleState(LifecycleState.RESUMED)
            .build();

    mReactRootView.startReactApplication(mReactInstanceManager, "example", null);

    setContentView(mReactRootView);
}
 
Example #13
Source File: MainActivity.java    From rn-camera-roll with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReactRootView = new ReactRootView(this);

    mReactInstanceManager = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setBundleAssetName("index.android.bundle")
            .setJSMainModuleName("index.android")
            .addPackage(new MainReactPackage())

            // Add Camera Roll for android
            .addPackage(new CameraRollPackage())
            .setUseDeveloperSupport(BuildConfig.DEBUG)
            .setInitialLifecycleState(LifecycleState.RESUMED)
            .build();

    mReactRootView.startReactApplication(mReactInstanceManager, "example", null);

    setContentView(mReactRootView);
}
 
Example #14
Source File: RootPresenter.java    From react-native-navigation with MIT License 6 votes vote down vote up
public void setRoot(ViewController root, Options defaultOptions, CommandListener listener, ReactInstanceManager reactInstanceManager) {
    layoutDirectionApplier.apply(root, defaultOptions, reactInstanceManager);
    rootLayout.addView(root.getView(), matchParentWithBehaviour(new BehaviourDelegate(root)));
    Options options = root.resolveCurrentOptions(defaultOptions);
    root.setWaitForRender(options.animations.setRoot.waitForRender);
    if (options.animations.setRoot.waitForRender.isTrue()) {
        root.getView().setAlpha(0);
        root.addOnAppearedListener(() -> {
            if (root.isDestroyed()) {
                listener.onError("Could not set root - Waited for the view to become visible but it was destroyed");
            } else {
                root.getView().setAlpha(1);
                animateSetRootAndReportSuccess(root, listener, options);
            }
        });
    } else {
        animateSetRootAndReportSuccess(root, listener, options);
    }
}
 
Example #15
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 #16
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 #17
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 #18
Source File: NavigationModule.java    From react-native-navigation with MIT License 6 votes vote down vote up
public NavigationModule(ReactApplicationContext reactContext, ReactInstanceManager reactInstanceManager, JSONParser jsonParser, LayoutFactory layoutFactory) {
    super(reactContext);
    this.reactInstanceManager = reactInstanceManager;
    this.jsonParser = jsonParser;
    this.layoutFactory = layoutFactory;
    reactContext.addLifecycleEventListener(new LifecycleEventListenerAdapter() {
        @Override
        public void onHostResume() {
            eventEmitter = new EventEmitter(reactContext);
            navigator().setEventEmitter(eventEmitter);
            layoutFactory.init(
                    activity(),
                    eventEmitter,
                    navigator().getChildRegistry(),
                    ((NavigationApplication) activity().getApplication()).getExternalComponents()
            );
        }
    });
}
 
Example #19
Source File: QtalkServiceExternalRNViewInstanceManager.java    From imsdk-android with MIT License 6 votes vote down vote up
public static ReactInstanceManager getInstanceManager(Activity mActivity, String bundleName, String Entrance) {

        if(lastBundleName.equals(bundleName)){
            if (mReactInstanceManager == null && !buildBundle(mActivity, bundleName, Entrance)) {
                // build error
                mReactInstanceManager = null;
            }
        }else{
            buildBundle(mActivity, bundleName, Entrance);
            lastBundleName = bundleName;
        }


//        if (mReactInstanceManager == null && !buildBundle(mActivity, bundleName, Entrance)) {
//            // build error
//            mReactInstanceManager = null;
//        }

        return mReactInstanceManager;
    }
 
Example #20
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 #21
Source File: QTalkSearchRNViewInstanceManager.java    From imsdk-android with MIT License 5 votes vote down vote up
public static ReactInstanceManager getInstanceManager(Application application){

        if(mReactInstanceManager == null && !buildBundle(application)){
            // build error
        }

        return mReactInstanceManager;
    }
 
Example #22
Source File: QTalkSearchRNViewOldInstanceManager.java    From imsdk-android with MIT License 5 votes vote down vote up
public static ReactInstanceManager getInstanceManager(Application application) {

        if (mReactInstanceManager == null && !buildBundle(application)) {
            // build error
        }
        ;

        return mReactInstanceManager;
    }
 
Example #23
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 #24
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 #25
Source File: ReactView.java    From react-native-navigation with MIT License 5 votes vote down vote up
public ReactView(final Context context, ReactInstanceManager reactInstanceManager, String componentId, String componentName) {
	super(context);
	this.reactInstanceManager = reactInstanceManager;
	this.componentId = componentId;
	this.componentName = componentName;
	jsTouchDispatcher = new JSTouchDispatcher(this);
}
 
Example #26
Source File: RootPresenterTest.java    From react-native-navigation with MIT License 5 votes vote down vote up
@Override
public void beforeEach() {
    reactInstanceManager = Mockito.mock(ReactInstanceManager.class);
    Activity activity = newActivity();
    rootContainer = new CoordinatorLayout(activity);
    root = new SimpleViewController(activity, new ChildControllersRegistry(), "child1", new Options());
    animator = spy(createAnimator(activity));
    layoutDirectionApplier = Mockito.mock(LayoutDirectionApplier.class);
    uut = new RootPresenter(animator, layoutDirectionApplier);
    uut.setRootContainer(rootContainer);
    defaultOptions = new Options();
}
 
Example #27
Source File: ExternalComponentViewController.java    From react-native-navigation with MIT License 5 votes vote down vote up
public ExternalComponentViewController(Activity activity, ChildControllersRegistry childRegistry, String id, Presenter presenter, ExternalComponent externalComponent, ExternalComponentCreator componentCreator, ReactInstanceManager reactInstanceManager, EventEmitter emitter, ExternalComponentPresenter externalComponentPresenter, Options initialOptions) {
    super(activity, childRegistry, id, presenter, initialOptions);
    this.externalComponent = externalComponent;
    this.componentCreator = componentCreator;
    this.reactInstanceManager = reactInstanceManager;
    this.emitter = emitter;
    this.presenter = externalComponentPresenter;
}
 
Example #28
Source File: Navigator.java    From react-native-navigation with MIT License 5 votes vote down vote up
public void setRoot(final ViewController viewController, CommandListener commandListener, ReactInstanceManager reactInstanceManager) {
    previousRoot = root;
    modalStack.destroy();
    final boolean removeSplashView = isRootNotCreated();
    if (isRootNotCreated()) getView();
    root = viewController;
    rootPresenter.setRoot(root, defaultOptions, new CommandListenerAdapter(commandListener) {
        @Override
        public void onSuccess(String childId) {
            if (removeSplashView) contentLayout.removeViewAt(0);
            destroyPreviousRoot();
            super.onSuccess(childId);
        }
    }, reactInstanceManager);
}
 
Example #29
Source File: LayoutDirectionApplier.java    From react-native-navigation with MIT License 5 votes vote down vote up
public void apply(ViewController root, Options options, ReactInstanceManager instanceManager) {
    if (options.layout.direction.hasValue() && instanceManager.getCurrentReactContext() != null) {
        root.getActivity().getWindow().getDecorView().setLayoutDirection(options.layout.direction.get());
        I18nUtil.getInstance().allowRTL(instanceManager.getCurrentReactContext(), options.layout.direction.isRtl());
        I18nUtil.getInstance().forceRTL(instanceManager.getCurrentReactContext(), options.layout.direction.isRtl());
    }
}
 
Example #30
Source File: LayoutFactoryTest.java    From react-native-navigation with MIT License 5 votes vote down vote up
@Override
public void beforeEach() {
    uut = new LayoutFactory(mock(ReactInstanceManager.class));
    uut.init(
            newActivity(),
            Mockito.mock(EventEmitter.class),
            new ChildControllersRegistry(),
            new HashMap<>()
    );
}