Example usage for com.facebook.react ReactRootView ReactRootView

List of usage examples for com.facebook.react ReactRootView ReactRootView

Introduction

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

Prototype

public ReactRootView(Context context) 

Source Link

Usage

From source file:com.github.markzhai.react.preloader.MrReactActivity.java

License:Apache License

/**
 * A subclass may override this method if it needs to use a custom {@link ReactRootView}.
 *///  w w  w . j ava  2 s.com
protected ReactRootView createRootView() {
    return new ReactRootView(this);
}

From source file:com.github.markzhai.react.preloader.ReactPreLoader.java

License:Apache License

/**
 * Pre-load {@link ReactRootView} to local {@link Map}, you may want to
 * load it in previous activity.//from   w w w .  j  ava 2 s .  c  o  m
 */
public static void init(Activity activity, ReactInfo reactInfo) {
    if (CACHE_VIEW_MAP.get(reactInfo.getMainComponentName()) != null) {
        return;
    }
    ReactRootView rootView = new ReactRootView(new MutableContextWrapper(activity));
    rootView.startReactApplication(
            ((ReactApplication) activity.getApplication()).getReactNativeHost().getReactInstanceManager(),
            reactInfo.getMainComponentName(), reactInfo.getLaunchOptions());
    CACHE_VIEW_MAP.put(reactInfo.getMainComponentName(), rootView);
}

From source file:com.lighters.demos.reactnative.ToastRnActivity.java

License:Apache License

@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 ToastExampleReactPackage())
            .setUseDeveloperSupport(BuildConfig.DEBUG)
            //.setUseDeveloperSupport(false)
            .setInitialLifecycleState(LifecycleState.RESUMED)
            //.setUseOldBridge(true) // uncomment this line if your app crashes
            .build();//from  w w  w.  j  av  a  2s.  c o  m
    mReactRootView.startReactApplication(mReactInstanceManager, "HelloWorld", null);

    setContentView(mReactRootView);
}

From source file:com.publicradionative.MainActivity.java

License:Apache License

@Override
public 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 VectorIconsPackage())
            .addPackage(new ProjectModulesPackage(this)).setUseDeveloperSupport(BuildConfig.DEBUG)
            .setInitialLifecycleState(LifecycleState.RESUMED).build();

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

    setContentView(mReactRootView);//  ww w  .ja v  a  2s  .com
}

From source file:com.socialdisasters.other.MainActivity.java

License:Open Source License

@Override
public 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()).setUseDeveloperSupport(BuildConfig.DEBUG)
            .setInitialLifecycleState(LifecycleState.RESUMED).build();
    mReactRootView.startReactApplication(mReactInstanceManager, "HelloWorld", null);
    setContentView(mReactRootView);/*  w  w w . j  a  va  2  s .  c o  m*/
}

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

License:Apache License

/**
 * Creates the {@code ReactRootView} for the given app name with the given
 * props. Once created it's set as the view of this {@code FrameLayout}.
 *
 * @param appName - The name of the "app" (in React Native terms) to load.
 * @param props - The React Component props to pass to the app.
 *///from  w w  w  . ja  v a2 s. co m
public void createReactRootView(String appName, @Nullable Bundle props) {
    if (props == null) {
        props = new Bundle();
    }

    props.putString("externalAPIScope", externalAPIScope);

    if (reactRootView == null) {
        reactRootView = new ReactRootView(getContext());
        reactRootView.startReactApplication(ReactInstanceManagerHolder.getReactInstanceManager(), appName,
                props);
        reactRootView.setBackgroundColor(BACKGROUND_COLOR);
        addView(reactRootView);
    } else {
        reactRootView.setAppProperties(props);
    }
}