com.facebook.react.common.LifecycleState Java Examples

The following examples show how to use com.facebook.react.common.LifecycleState. 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: ReactInstanceManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
private void tearDownReactContext(ReactContext reactContext) {
  Log.d(ReactConstants.TAG, "ReactInstanceManager.tearDownReactContext()");
  UiThreadUtil.assertOnUiThread();
  if (mLifecycleState == LifecycleState.RESUMED) {
    reactContext.onHostPause();
  }

  synchronized (mAttachedRootViews) {
    for (ReactRootView rootView : mAttachedRootViews) {
      rootView.removeAllViews();
      rootView.setId(View.NO_ID);
    }
  }

  reactContext.destroy();
  mDevSupportManager.onReactInstanceDestroyed(reactContext);
  mMemoryPressureRouter.removeMemoryPressureListener(reactContext.getCatalystInstance());
}
 
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)
            .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)
            .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 #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())
            .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 #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)
            .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: 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 #9
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 #10
Source File: HeadlessJsTaskContext.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * Start a JS task. Handles invoking {@link AppRegistry#startHeadlessTask} and notifying
 * listeners.
 *
 * @return a unique id representing this task instance.
 */
public synchronized int startTask(final HeadlessJsTaskConfig taskConfig) {
  UiThreadUtil.assertOnUiThread();
  ReactContext reactContext = Assertions.assertNotNull(
    mReactContext.get(),
    "Tried to start a task on a react context that has already been destroyed");
  if (reactContext.getLifecycleState() == LifecycleState.RESUMED &&
    !taskConfig.isAllowedInForeground()) {
    throw new IllegalStateException(
      "Tried to start task " + taskConfig.getTaskKey() +
        " while in foreground, but this is not allowed.");
  }
  final int taskId = mLastTaskId.incrementAndGet();
  mActiveTasks.add(taskId);
  reactContext.getJSModule(AppRegistry.class)
    .startHeadlessTask(taskId, taskConfig.getTaskKey(), taskConfig.getData());
  if (taskConfig.getTimeout() > 0) {
    scheduleTaskTimeout(taskId, taskConfig.getTimeout());
  }
  for (HeadlessJsTaskEventListener listener : mHeadlessJsTaskEventListeners) {
    listener.onHeadlessJsTaskStart(taskId);
  }
  return taskId;
}
 
Example #11
Source File: ReactNativeHost.java    From react-native-GPay with MIT License 6 votes vote down vote up
protected ReactInstanceManager createReactInstanceManager() {
  ReactMarker.logMarker(ReactMarkerConstants.BUILD_REACT_INSTANCE_MANAGER_START);
  ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
    .setApplication(mApplication)
    .setJSMainModulePath(getJSMainModuleName())
    .setUseDeveloperSupport(getUseDeveloperSupport())
    .setRedBoxHandler(getRedBoxHandler())
    .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
    .setUIImplementationProvider(getUIImplementationProvider())
    .setJSIModulesPackage(getJSIModulePackage())
    .setInitialLifecycleState(LifecycleState.BEFORE_CREATE);

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

  String jsBundleFile = getJSBundleFile();
  if (jsBundleFile != null) {
    builder.setJSBundleFile(jsBundleFile);
  } else {
    builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
  }
  ReactInstanceManager reactInstanceManager = builder.build();
  ReactMarker.logMarker(ReactMarkerConstants.BUILD_REACT_INSTANCE_MANAGER_END);
  return reactInstanceManager;
}
 
Example #12
Source File: ReactAppTestActivity.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
protected void onResume() {
  super.onResume();

  mLifecycleState = LifecycleState.RESUMED;

  if (mReactInstanceManager != null) {
    mReactInstanceManager.onHostResume(this, this);
  }
}
 
Example #13
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 #14
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 #15
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 #16
Source File: SampleRNBaseActivity.java    From react-native-aztec with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReactInstanceManager = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setBundleAssetName("index.android.bundle")
            .setJSMainModulePath("index")
            .addPackage(new MainReactPackage())
            .addPackage(new ReactAztecPackage())
            .setUseDeveloperSupport(BuildConfig.DEBUG)
            .setInitialLifecycleState(LifecycleState.RESUMED)
            .build();
}
 
Example #17
Source File: ReactContext.java    From react-native-GPay with MIT License 5 votes vote down vote up
/**
 * Should be called by the hosting Fragment in {@link Fragment#onResume}
 */
public void onHostResume(@Nullable Activity activity) {
  mLifecycleState = LifecycleState.RESUMED;
  mCurrentActivity = new WeakReference(activity);
  ReactMarker.logMarker(ReactMarkerConstants.ON_HOST_RESUME_START);
  for (LifecycleEventListener listener : mLifecycleEventListeners) {
    try {
      listener.onHostResume();
    } catch (RuntimeException e) {
      handleException(e);
    }
  }
  ReactMarker.logMarker(ReactMarkerConstants.ON_HOST_RESUME_END);
}
 
Example #18
Source File: ReactContext.java    From react-native-GPay with MIT License 5 votes vote down vote up
/**
 * Should be called by the hosting Fragment in {@link Fragment#onPause}
 */
public void onHostPause() {
  mLifecycleState = LifecycleState.BEFORE_RESUME;
  ReactMarker.logMarker(ReactMarkerConstants.ON_HOST_PAUSE_START);
  for (LifecycleEventListener listener : mLifecycleEventListeners) {
    try {
      listener.onHostPause();
    } catch (RuntimeException e) {
      handleException(e);
    }
  }
  ReactMarker.logMarker(ReactMarkerConstants.ON_HOST_PAUSE_END);
}
 
Example #19
Source File: Utils.java    From react-native-background-job with MIT License 5 votes vote down vote up
/** Check whether on not the React Native application is in foreground. */
public static boolean isReactNativeAppInForeground(@NonNull ReactNativeHost reactNativeHost) {
  if (!reactNativeHost.hasInstance()) {
    // If the app was force-stopped the instace will be destroyed. The instance can't be created from a background thread.
    return false;
  }
  ReactContext reactContext = reactNativeHost.getReactInstanceManager().getCurrentReactContext();
  return reactContext != null && reactContext.getLifecycleState() == LifecycleState.RESUMED;
}
 
Example #20
Source File: ReactContext.java    From react-native-GPay with MIT License 5 votes vote down vote up
/**
 * Should be called by the hosting Fragment in {@link Fragment#onDestroy}
 */
public void onHostDestroy() {
  UiThreadUtil.assertOnUiThread();
  mLifecycleState = LifecycleState.BEFORE_CREATE;
  for (LifecycleEventListener listener : mLifecycleEventListeners) {
    try {
      listener.onHostDestroy();
    } catch (RuntimeException e) {
      handleException(e);
    }
  }
  mCurrentActivity = null;
}
 
Example #21
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
private synchronized void moveToBeforeResumeLifecycleState() {
  ReactContext currentContext = getCurrentReactContext();
  if (currentContext != null) {
    if (mLifecycleState == LifecycleState.BEFORE_CREATE) {
      currentContext.onHostResume(mCurrentActivity);
      currentContext.onHostPause();
    } else if (mLifecycleState == LifecycleState.RESUMED) {
      currentContext.onHostPause();
    }
  }
  mLifecycleState = LifecycleState.BEFORE_RESUME;
}
 
Example #22
Source File: ReactAppTestActivity.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
protected void onPause() {
  super.onPause();

  mLifecycleState = LifecycleState.BEFORE_RESUME;

  overridePendingTransition(0, 0);

  if (mReactInstanceManager != null) {
    mReactInstanceManager.onHostPause();
  }
}
 
Example #23
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
private synchronized void moveToResumedLifecycleState(boolean force) {
  ReactContext currentContext = getCurrentReactContext();
  if (currentContext != null) {
    // we currently don't have an onCreate callback so we call onResume for both transitions
    if (force ||
        mLifecycleState == LifecycleState.BEFORE_RESUME ||
        mLifecycleState == LifecycleState.BEFORE_CREATE) {
      currentContext.onHostResume(mCurrentActivity);
    }
  }
  mLifecycleState = LifecycleState.RESUMED;
}
 
Example #24
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 #25
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
private synchronized void moveToBeforeCreateLifecycleState() {
  ReactContext currentContext = getCurrentReactContext();
  if (currentContext != null) {
    if (mLifecycleState == LifecycleState.RESUMED) {
      currentContext.onHostPause();
      mLifecycleState = LifecycleState.BEFORE_RESUME;
    }
    if (mLifecycleState == LifecycleState.BEFORE_RESUME) {
      currentContext.onHostDestroy();
    }
  }
  mLifecycleState = LifecycleState.BEFORE_CREATE;
}
 
Example #26
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 4 votes vote down vote up
ReactInstanceManager(
  Context applicationContext,
  @Nullable Activity currentActivity,
  @Nullable DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler,
  JavaScriptExecutorFactory javaScriptExecutorFactory,
  @Nullable JSBundleLoader bundleLoader,
  @Nullable String jsMainModulePath,
  List<ReactPackage> packages,
  boolean useDeveloperSupport,
  @Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
  LifecycleState initialLifecycleState,
  @Nullable UIImplementationProvider mUIImplementationProvider,
  NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler,
  @Nullable RedBoxHandler redBoxHandler,
  boolean lazyViewManagersEnabled,
  @Nullable DevBundleDownloadListener devBundleDownloadListener,
  int minNumShakes,
  int minTimeLeftInFrameForNonBatchedOperationMs,
  @Nullable JSIModulePackage jsiModulePackage,
  @Nullable Map<String, RequestHandler> customPackagerCommandHandlers) {
  Log.d(ReactConstants.TAG, "ReactInstanceManager.ctor()");
  initializeSoLoaderIfNecessary(applicationContext);

  DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(applicationContext);

  mApplicationContext = applicationContext;
  mCurrentActivity = currentActivity;
  mDefaultBackButtonImpl = defaultHardwareBackBtnHandler;
  mJavaScriptExecutorFactory = javaScriptExecutorFactory;
  mBundleLoader = bundleLoader;
  mJSMainModulePath = jsMainModulePath;
  mPackages = new ArrayList<>();
  mUseDeveloperSupport = useDeveloperSupport;
  mDevSupportManager =
      DevSupportManagerFactory.create(
          applicationContext,
          createDevHelperInterface(),
          mJSMainModulePath,
          useDeveloperSupport,
          redBoxHandler,
          devBundleDownloadListener,
          minNumShakes,
          customPackagerCommandHandlers);
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  mLifecycleState = initialLifecycleState;
  mMemoryPressureRouter = new MemoryPressureRouter(applicationContext);
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  synchronized (mPackages) {
    PrinterHolder.getPrinter()
        .logMessage(ReactDebugOverlayTags.RN_CORE, "RNCore: Use Split Packages");
    mPackages.add(
        new CoreModulesPackage(
            this,
            new DefaultHardwareBackBtnHandler() {
              @Override
              public void invokeDefaultOnBackPressed() {
                ReactInstanceManager.this.invokeDefaultOnBackPressed();
              }
            },
            mUIImplementationProvider,
            lazyViewManagersEnabled,
            minTimeLeftInFrameForNonBatchedOperationMs));
    if (mUseDeveloperSupport) {
      mPackages.add(new DebugCorePackage());
    }
    mPackages.addAll(packages);
  }
  mJSIModulePackage = jsiModulePackage;

  // Instantiate ReactChoreographer in UI thread.
  ReactChoreographer.initialize();
  if (mUseDeveloperSupport) {
    mDevSupportManager.startInspector();
  }
}
 
Example #27
Source File: ReactInstanceManagerBuilder.java    From react-native-GPay with MIT License 4 votes vote down vote up
/**
 * Sets the initial lifecycle state of the host. For example, if the host is already resumed at
 * creation time, we wouldn't expect an onResume call until we get an onPause call.
 */
public ReactInstanceManagerBuilder setInitialLifecycleState(
  LifecycleState initialLifecycleState) {
  mInitialLifecycleState = initialLifecycleState;
  return this;
}
 
Example #28
Source File: ReactContext.java    From react-native-GPay with MIT License 4 votes vote down vote up
public LifecycleState getLifecycleState() {
  return mLifecycleState;
}
 
Example #29
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 4 votes vote down vote up
public LifecycleState getLifecycleState() {
  return mLifecycleState;
}
 
Example #30
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 4 votes vote down vote up
private synchronized void moveReactContextToCurrentLifecycleState() {
  if (mLifecycleState == LifecycleState.RESUMED) {
    moveToResumedLifecycleState(true);
  }
}