Java 类com.facebook.react.jstasks.HeadlessJsTaskContext 实例源码

项目:RNLearn_Project1    文件:HeadlessJsTaskService.java   
@Override
public void onDestroy() {
  super.onDestroy();

  if (getReactNativeHost().hasInstance()) {
    ReactInstanceManager reactInstanceManager = getReactNativeHost().getReactInstanceManager();
    ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
    if (reactContext != null) {
      HeadlessJsTaskContext headlessJsTaskContext =
        HeadlessJsTaskContext.getInstance(reactContext);
      headlessJsTaskContext.removeTaskEventListener(this);
    }
  }
  if (sWakeLock != null) {
    sWakeLock.release();
  }
}
项目:RNLearn_Project1    文件:HeadlessJsTaskService.java   
@Override
public void onDestroy() {
  super.onDestroy();

  if (getReactNativeHost().hasInstance()) {
    ReactInstanceManager reactInstanceManager = getReactNativeHost().getReactInstanceManager();
    ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
    if (reactContext != null) {
      HeadlessJsTaskContext headlessJsTaskContext =
        HeadlessJsTaskContext.getInstance(reactContext);
      headlessJsTaskContext.removeTaskEventListener(this);
    }
  }
  if (sWakeLock != null) {
    sWakeLock.release();
  }
}
项目:Ironman    文件:HeadlessJsTaskService.java   
@Override
public void onDestroy() {
  super.onDestroy();

  if (getReactNativeHost().hasInstance()) {
    ReactInstanceManager reactInstanceManager = getReactNativeHost().getReactInstanceManager();
    ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
    if (reactContext != null) {
      HeadlessJsTaskContext headlessJsTaskContext =
        HeadlessJsTaskContext.getInstance(reactContext);
      headlessJsTaskContext.removeTaskEventListener(this);
    }
  }
  if (sWakeLock != null) {
    sWakeLock.release();
  }
}
项目:RNLearn_Project1    文件:HeadlessJsTaskSupportModule.java   
@ReactMethod
public void notifyTaskFinished(int taskId) {
  HeadlessJsTaskContext headlessJsTaskContext =
    HeadlessJsTaskContext.getInstance(getReactApplicationContext());
  if (headlessJsTaskContext.isTaskRunning(taskId)) {
    headlessJsTaskContext.finishTask(taskId);
  } else {
    FLog.w(
      HeadlessJsTaskSupportModule.class,
      "Tried to finish non-active task with id %d. Did it time out?",
      taskId);
  }
}
项目:RNLearn_Project1    文件:Timing.java   
@Override
public void initialize() {
  getReactApplicationContext().addLifecycleEventListener(this);
  HeadlessJsTaskContext headlessJsTaskContext =
    HeadlessJsTaskContext.getInstance(getReactApplicationContext());
  headlessJsTaskContext.addTaskEventListener(this);
}
项目:RNLearn_Project1    文件:Timing.java   
@Override
public void onHeadlessJsTaskFinish(int taskId) {
  HeadlessJsTaskContext headlessJsTaskContext =
    HeadlessJsTaskContext.getInstance(getReactApplicationContext());
  if (!headlessJsTaskContext.hasActiveTasks()) {
    isRunningTasks.set(false);
    clearFrameCallback();
    maybeIdleCallback();
  }
}
项目:RNLearn_Project1    文件:Timing.java   
@Override
public void onCatalystInstanceDestroy() {
  clearFrameCallback();
  clearChoreographerIdleCallback();
  HeadlessJsTaskContext headlessJsTaskContext =
    HeadlessJsTaskContext.getInstance(getReactApplicationContext());
  headlessJsTaskContext.removeTaskEventListener(this);
}
项目:RNLearn_Project1    文件:Timing.java   
private void clearFrameCallback() {
  HeadlessJsTaskContext headlessJsTaskContext =
    HeadlessJsTaskContext.getInstance(getReactApplicationContext());
  if (mFrameCallbackPosted && isPaused.get() &&
    !headlessJsTaskContext.hasActiveTasks()) {
    Assertions.assertNotNull(mReactChoreographer).removeFrameCallback(
        ReactChoreographer.CallbackType.TIMERS_EVENTS,
        mTimerFrameCallback);
    mFrameCallbackPosted = false;
  }
}
项目:RNLearn_Project1    文件:HeadlessJsTaskSupportModule.java   
@ReactMethod
public void notifyTaskFinished(int taskId) {
  HeadlessJsTaskContext headlessJsTaskContext =
    HeadlessJsTaskContext.getInstance(getReactApplicationContext());
  if (headlessJsTaskContext.isTaskRunning(taskId)) {
    headlessJsTaskContext.finishTask(taskId);
  } else {
    FLog.w(
      HeadlessJsTaskSupportModule.class,
      "Tried to finish non-active task with id %d. Did it time out?",
      taskId);
  }
}
项目:RNLearn_Project1    文件:Timing.java   
@Override
public void initialize() {
  getReactApplicationContext().addLifecycleEventListener(this);
  HeadlessJsTaskContext headlessJsTaskContext =
    HeadlessJsTaskContext.getInstance(getReactApplicationContext());
  headlessJsTaskContext.addTaskEventListener(this);
}
项目:RNLearn_Project1    文件:Timing.java   
@Override
public void onHeadlessJsTaskFinish(int taskId) {
  HeadlessJsTaskContext headlessJsTaskContext =
    HeadlessJsTaskContext.getInstance(getReactApplicationContext());
  if (!headlessJsTaskContext.hasActiveTasks()) {
    isRunningTasks.set(false);
    clearFrameCallback();
    maybeIdleCallback();
  }
}
项目:RNLearn_Project1    文件:Timing.java   
@Override
public void onCatalystInstanceDestroy() {
  clearFrameCallback();
  clearChoreographerIdleCallback();
  HeadlessJsTaskContext headlessJsTaskContext =
    HeadlessJsTaskContext.getInstance(getReactApplicationContext());
  headlessJsTaskContext.removeTaskEventListener(this);
}
项目:RNLearn_Project1    文件:Timing.java   
private void clearFrameCallback() {
  HeadlessJsTaskContext headlessJsTaskContext =
    HeadlessJsTaskContext.getInstance(getReactApplicationContext());
  if (mFrameCallbackPosted && isPaused.get() &&
    !headlessJsTaskContext.hasActiveTasks()) {
    Assertions.assertNotNull(mReactChoreographer).removeFrameCallback(
        ReactChoreographer.CallbackType.TIMERS_EVENTS,
        mTimerFrameCallback);
    mFrameCallbackPosted = false;
  }
}
项目:Ironman    文件:Timing.java   
@Override
public void initialize() {
  // Safe to acquire choreographer here, as initialize() is invoked from UI thread.
  mReactChoreographer = ReactChoreographer.getInstance();
  getReactApplicationContext().addLifecycleEventListener(this);
  HeadlessJsTaskContext headlessJsTaskContext =
    HeadlessJsTaskContext.getInstance(getReactApplicationContext());
  headlessJsTaskContext.addTaskEventListener(this);
}
项目:Ironman    文件:Timing.java   
@Override
public void onHeadlessJsTaskFinish(int taskId) {
  HeadlessJsTaskContext headlessJsTaskContext =
    HeadlessJsTaskContext.getInstance(getReactApplicationContext());
  if (!headlessJsTaskContext.hasActiveTasks()) {
    isRunningTasks.set(false);
    clearChoreographerCallback();
    maybeClearChoreographerIdleCallback();
  }
}
项目:Ironman    文件:Timing.java   
@Override
public void onCatalystInstanceDestroy() {
  clearChoreographerCallback();
  clearChoreographerIdleCallback();
  HeadlessJsTaskContext headlessJsTaskContext =
    HeadlessJsTaskContext.getInstance(getReactApplicationContext());
  headlessJsTaskContext.removeTaskEventListener(this);
}
项目:Ironman    文件:Timing.java   
private void clearChoreographerCallback() {
  HeadlessJsTaskContext headlessJsTaskContext =
    HeadlessJsTaskContext.getInstance(getReactApplicationContext());
  if (mFrameCallbackPosted && isPaused.get() &&
    !headlessJsTaskContext.hasActiveTasks()) {
    Assertions.assertNotNull(mReactChoreographer).removeFrameCallback(
        ReactChoreographer.CallbackType.TIMERS_EVENTS,
        mTimerFrameCallback);
    mFrameCallbackPosted = false;
  }
}
项目:RNLearn_Project1    文件:HeadlessJsTaskService.java   
private void invokeStartTask(ReactContext reactContext, HeadlessJsTaskConfig taskConfig) {
  HeadlessJsTaskContext headlessJsTaskContext = HeadlessJsTaskContext.getInstance(reactContext);
  headlessJsTaskContext.addTaskEventListener(this);
  int taskId = headlessJsTaskContext.startTask(taskConfig);
  mActiveTasks.add(taskId);
}
项目:RNLearn_Project1    文件:HeadlessJsTaskService.java   
private void invokeStartTask(ReactContext reactContext, HeadlessJsTaskConfig taskConfig) {
  HeadlessJsTaskContext headlessJsTaskContext = HeadlessJsTaskContext.getInstance(reactContext);
  headlessJsTaskContext.addTaskEventListener(this);
  int taskId = headlessJsTaskContext.startTask(taskConfig);
  mActiveTasks.add(taskId);
}
项目:Ironman    文件:HeadlessJsTaskSupportModule.java   
@ReactMethod
public void notifyTaskFinished(int taskId) {
  HeadlessJsTaskContext headlessJsTaskContext =
    HeadlessJsTaskContext.getInstance(getReactApplicationContext());
  headlessJsTaskContext.finishTask(taskId);
}
项目:Ironman    文件:HeadlessJsTaskService.java   
private void invokeStartTask(ReactContext reactContext, HeadlessJsTaskConfig taskConfig) {
  HeadlessJsTaskContext headlessJsTaskContext = HeadlessJsTaskContext.getInstance(reactContext);
  headlessJsTaskContext.addTaskEventListener(this);
  int taskId = headlessJsTaskContext.startTask(taskConfig);
  mActiveTasks.add(taskId);
}
项目:react-native-background-geolocation    文件:RNBackgroundGeolocationEventReceiver.java   
private void invokeStartTask(ReactContext reactContext, final HeadlessJsTaskConfig taskConfig) {
    final HeadlessJsTaskContext headlessJsTaskContext = HeadlessJsTaskContext.getInstance(reactContext);
    headlessJsTaskContext.addTaskEventListener(this);

    mActiveTaskContext = headlessJsTaskContext;

    UiThreadUtil.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            int taskId = headlessJsTaskContext.startTask(taskConfig);
        }
    });



}