当前位置: 首页>>代码示例>>Java>>正文


Java LifecycleState类代码示例

本文整理汇总了Java中com.facebook.react.common.LifecycleState的典型用法代码示例。如果您正苦于以下问题:Java LifecycleState类的具体用法?Java LifecycleState怎么用?Java LifecycleState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LifecycleState类属于com.facebook.react.common包,在下文中一共展示了LifecycleState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializePage

import com.facebook.react.common.LifecycleState; //导入依赖的package包/类
private void initializePage() {
    mReactRootView = new ReactRootView(this);
    mReactInstanceManager = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setBundleAssetName("index.android.bundle")
            .setJSMainModuleName("index.android")
            .addPackage(new MainReactPackage())
            .addPackage(new ImageIntentPackage())
            .setUseDeveloperSupport(BuildConfig.DEBUG)
            .setInitialLifecycleState(LifecycleState.RESUMED)
            .build();
    mReactRootView.startReactApplication(mReactInstanceManager, "Clarifai", null);

    setContentView(com.sonnylab.imageintent.R.layout.activity_main);
    ((RelativeLayout) findViewById(com.sonnylab.imageintent.R.id.view_container)).addView(mReactRootView);
}
 
开发者ID:sonnylazuardi,项目名称:react-native-image-intent,代码行数:17,代码来源:MainActivity.java

示例2: createReactInstanceManager

import com.facebook.react.common.LifecycleState; //导入依赖的package包/类
@Override
protected ReactInstanceManager createReactInstanceManager() {
    ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setJSMainModuleName(getJSMainModuleName())
            .setUseDeveloperSupport(getUseDeveloperSupport())
            .setRedBoxHandler(getRedBoxHandler())
            .setUIImplementationProvider(getUIImplementationProvider())
            .setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
            .setNativeModuleCallExceptionHandler(
                    new ReadingNativeModuleCallExceptionHandler());

    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();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:25,代码来源:MainApplication.java

示例3: createReactInstanceManager

import com.facebook.react.common.LifecycleState; //导入依赖的package包/类
protected ReactInstanceManager createReactInstanceManager() {
  ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
    .setApplication(mApplication)
    .setJSMainModuleName(getJSMainModuleName())
    .setUseDeveloperSupport(getUseDeveloperSupport())
    .setRedBoxHandler(getRedBoxHandler())
    .setUIImplementationProvider(getUIImplementationProvider())
    .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()));
  }
  return builder.build();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:22,代码来源:ReactNativeHost.java

示例4: startTask

import com.facebook.react.common.LifecycleState; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:30,代码来源:HeadlessJsTaskContext.java

示例5: onCreate

import com.facebook.react.common.LifecycleState; //导入依赖的package包/类
@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())
        .setUseDeveloperSupport(BuildConfig.DEBUG)
        .setInitialLifecycleState(LifecycleState.RESUMED)
        .addPackage(new NativeActivityPackage())
        //.setUseOldBridge(true) // uncomment this line if your app crashes
        .build();
    mReactRootView.startReactApplication(mReactInstanceManager, "HelloWorld", null);

    setContentView(mReactRootView);
}
 
开发者ID:haiyangjiajian,项目名称:TestRNIntegrationNative,代码行数:20,代码来源:ReactActivity.java

示例6: createReactInstanceManager

import com.facebook.react.common.LifecycleState; //导入依赖的package包/类
protected ReactInstanceManager createReactInstanceManager() {
  ReactInstanceManager.Builder builder = ReactInstanceManager.builder()
    .setApplication(mApplication)
    .setJSMainModuleName(getJSMainModuleName())
    .setUseDeveloperSupport(getUseDeveloperSupport())
    .setRedBoxHandler(getRedBoxHandler())
    .setUIImplementationProvider(getUIImplementationProvider())
    .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()));
  }
  return builder.build();
}
 
开发者ID:Right-Men,项目名称:Ironman,代码行数:22,代码来源:ReactNativeHost.java

示例7: startTask

import com.facebook.react.common.LifecycleState; //导入依赖的package包/类
/**
 * 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();
  if (mReactContext.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();
  mReactContext.getJSModule(AppRegistry.class)
    .startHeadlessTask(taskId, taskConfig.getTaskKey(), taskConfig.getData());
  if (taskConfig.getTimeout() > 0) {
    scheduleTaskTimeout(taskId, taskConfig.getTimeout());
  }
  mActiveTasks.add(taskId);
  for (HeadlessJsTaskEventListener listener : mHeadlessJsTaskEventListeners) {
    listener.onHeadlessJsTaskStart(taskId);
  }
  return taskId;
}
 
开发者ID:Right-Men,项目名称:Ironman,代码行数:27,代码来源:HeadlessJsTaskContext.java

示例8: onHostResume

import com.facebook.react.common.LifecycleState; //导入依赖的package包/类
/**
 * Should be called by the hosting Fragment in {@link Fragment#onResume}
 */
public void onHostResume(@Nullable Activity activity) {
  UiThreadUtil.assertOnUiThread();
  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);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:18,代码来源:ReactContext.java

示例9: onHostPause

import com.facebook.react.common.LifecycleState; //导入依赖的package包/类
/**
 * Should be called by the hosting Fragment in {@link Fragment#onPause}
 */
public void onHostPause() {
  UiThreadUtil.assertOnUiThread();
  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);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:17,代码来源:ReactContext.java

示例10: onHostDestroy

import com.facebook.react.common.LifecycleState; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:16,代码来源:ReactContext.java

示例11: moveToResumedLifecycleState

import com.facebook.react.common.LifecycleState; //导入依赖的package包/类
private void moveToResumedLifecycleState(boolean force) {
  if (mCurrentReactContext != 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) {
      mCurrentReactContext.onHostResume(mCurrentActivity);
    }
  }
  mLifecycleState = LifecycleState.RESUMED;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:12,代码来源:ReactInstanceManager.java

示例12: moveToBeforeResumeLifecycleState

import com.facebook.react.common.LifecycleState; //导入依赖的package包/类
private void moveToBeforeResumeLifecycleState() {
  if (mCurrentReactContext != null) {
    if (mLifecycleState == LifecycleState.BEFORE_CREATE) {
      mCurrentReactContext.onHostResume(mCurrentActivity);
      mCurrentReactContext.onHostPause();
    } else if (mLifecycleState == LifecycleState.RESUMED) {
      mCurrentReactContext.onHostPause();
    }
  }
  mLifecycleState = LifecycleState.BEFORE_RESUME;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:12,代码来源:ReactInstanceManager.java

示例13: moveToBeforeCreateLifecycleState

import com.facebook.react.common.LifecycleState; //导入依赖的package包/类
private void moveToBeforeCreateLifecycleState() {
  if (mCurrentReactContext != null) {
    if (mLifecycleState == LifecycleState.RESUMED) {
      mCurrentReactContext.onHostPause();
      mLifecycleState = LifecycleState.BEFORE_RESUME;
    }
    if (mLifecycleState == LifecycleState.BEFORE_RESUME) {
      mCurrentReactContext.onHostDestroy();
    }
  }
  mLifecycleState = LifecycleState.BEFORE_CREATE;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:13,代码来源:ReactInstanceManager.java

示例14: tearDownReactContext

import com.facebook.react.common.LifecycleState; //导入依赖的package包/类
private void tearDownReactContext(ReactContext reactContext) {
  UiThreadUtil.assertOnUiThread();
  if (mLifecycleState == LifecycleState.RESUMED) {
    reactContext.onHostPause();
  }
  for (ReactRootView rootView : mAttachedRootViews) {
    detachViewFromInstance(rootView, reactContext.getCatalystInstance());
  }
  reactContext.destroy();
  mDevSupportManager.onReactInstanceDestroyed(reactContext);
  mMemoryPressureRouter.removeMemoryPressureListener(reactContext.getCatalystInstance());
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:13,代码来源:ReactInstanceManager.java

示例15: onPause

import com.facebook.react.common.LifecycleState; //导入依赖的package包/类
@Override
protected void onPause() {
  super.onPause();

  mLifecycleState = LifecycleState.BEFORE_RESUME;

  overridePendingTransition(0, 0);

  if (mReactInstanceManager != null) {
    mReactInstanceManager.onHostPause();
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:13,代码来源:ReactAppTestActivity.java


注:本文中的com.facebook.react.common.LifecycleState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。