Java Code Examples for com.facebook.react.ReactRootView#startReactApplication()

The following examples show how to use com.facebook.react.ReactRootView#startReactApplication() . 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: RNCustomKeyboardKitModule.java    From react-native-custom-keyboard-kit with MIT License 6 votes vote down vote up
private View createCustomKeyboardKit(Activity activity, int tag, String type) {
  RelativeLayout layout = new RelativeLayout(activity);
  rootView = new ReactRootView(this.getReactApplicationContext());
  rootView.setBackgroundColor(Color.WHITE);

  Bundle bundle = new Bundle();
  bundle.putInt("tag", tag);
  bundle.putString("type", type);
  rootView.startReactApplication(
          ((ReactApplication) activity.getApplication()).getReactNativeHost().getReactInstanceManager(),
          "CustomKeyboardKit",
          bundle);

  final float scale = activity.getResources().getDisplayMetrics().density;
  RelativeLayout.LayoutParams lParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Math.round(216*scale));
  lParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
  layout.addView(rootView, lParams);
  // activity.addContentView(layout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
  return layout;
}
 
Example 2
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 3
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 4
Source File: MyFragment.java    From react-native-aztec with GNU General Public License v2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (mReactInstanceManager == null) {
        try {
            mReactInstanceManager = ((SampleRNBaseActivity) getActivity()).getReactInstanceManager();
        } catch (ClassCastException e) {
            throw new ClassCastException(getActivity().toString() + " must extends SampleRNBaseActivity");
        }
    }

    ReactRootView reactRootView = new ReactRootView(getContext());
    reactRootView.startReactApplication(mReactInstanceManager, "example", null);
    return reactRootView;
}
 
Example 5
Source File: ReactFragment.java    From react-native-android-fragment with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    mReactRootView = new ReactRootView(getContext());
    mReactRootView.startReactApplication(
            getReactNativeHost().getReactInstanceManager(),
            mComponentName,
            mLaunchOptions);
    return mReactRootView;
}
 
Example 6
Source File: PreReactRootViewLoader.java    From vinci with Apache License 2.0 5 votes vote down vote up
public static void preLoad(Activity activity, String componentName) {
    if (CACHE.get(componentName) == null) {
        return;
    }
    ReactRootView reactRootView = new ReactRootView(activity);
    reactRootView.startReactApplication(Vinci.getReactNativeHost().getReactInstanceManager(),
            componentName,
            null);
    CACHE.put(componentName, reactRootView);
}
 
Example 7
Source File: ReactPreLoader.java    From react-native-preloader with Apache License 2.0 5 votes vote down vote up
/**
 * Pre-load {@link ReactRootView} to local {@link Map}, you may want to
 * load it in previous activity.
 */
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);
}
 
Example 8
Source File: QTalkSearchActivity.java    From imsdk-android with MIT License 4 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (mReactInstanceManager == null) {
//            if (TextUtils.isEmpty(QtalkNavicationService.getInstance().getNewSerarchUrl())) {
//                mReactInstanceManager = QTalkSearchRNViewOldInstanceManager.getInstanceManager(getApplication());
//            } else {
//            if(QtalkNavicationService.getInstance().getXmppdomain().equals("ejabhost1")){


                if (IMDatabaseManager.getInstance().getFocusSearch()) {
                    mReactInstanceManager = QTalkSearchRNViewOldInstanceManager.getInstanceManager(getApplication());
                } else {
                    mReactInstanceManager = QTalkSearchRNViewInstanceManager.getInstanceManager(getApplication());
                }
//            }else{
//                mReactInstanceManager = QTalkSearchRNViewOldInstanceManager.getInstanceManager(getApplication());
//            }
//            }
        }

        mReactRootView = new ReactRootView(this);
        // render react


//        if (mReactInstanceManager == null) {
//            if (TextUtils.isEmpty(QtalkNavicationService.getInstance().getNewSerarchUrl())) {
////                mReactInstanceManager = QTalkSearchRNViewOldInstanceManager.getInstanceManager(getApplication());
//                mReactRootView.startReactApplication(mReactInstanceManager, QTalkSearchRNViewOldInstanceManager.MODULE, getExtendBundle());

//            } else {
//        if(QtalkNavicationService.getInstance().getXmppdomain().equals("ejabhost1")) {

            if (IMDatabaseManager.getInstance().getFocusSearch()) {
//                    mReactInstanceManager = QTalkSearchRNViewOldInstanceManager.getInstanceManager(getApplication());
                mReactRootView.startReactApplication(mReactInstanceManager, QTalkSearchRNViewOldInstanceManager.MODULE, getExtendBundle());

            } else {
//                    mReactInstanceManager = QTalkSearchRNViewInstanceManager.getInstanceManager(getApplication());
                mReactRootView.startReactApplication(mReactInstanceManager, QTalkSearchRNViewInstanceManager.MODULE, getExtendBundle());

            }
//        }else{
//            mReactRootView.startReactApplication(mReactInstanceManager, QTalkSearchRNViewOldInstanceManager.MODULE, getExtendBundle());
//        }
//            }
//        }

        // set to content
        setContentView(mReactRootView);
    }