com.facebook.react.bridge.LifecycleEventListener Java Examples

The following examples show how to use com.facebook.react.bridge.LifecycleEventListener. 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: NearbyConnectionModule.java    From react-native-google-nearby-connection with MIT License 6 votes vote down vote up
private void setLifecycleListeners() {

        this.reactContext.addLifecycleEventListener(new LifecycleEventListener() {
            @Override
            public void onHostResume() {
                logW("onHostResume");
                onResume();
            }

            @Override
            public void onHostPause() {
                logW("onHostPause");
                onPause();
            }

            @Override
            public void onHostDestroy() {
				logW("onHostDestroy");
                onDestroy();
            }
        });
    }
 
Example #2
Source File: ReactIntegrationTestCase.java    From react-native-GPay with MIT License 6 votes vote down vote up
protected static void initializeJavaModule(final BaseJavaModule javaModule) {
  final Semaphore semaphore = new Semaphore(0);
  UiThreadUtil.runOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          javaModule.initialize();
          if (javaModule instanceof LifecycleEventListener) {
            ((LifecycleEventListener) javaModule).onHostResume();
          }
          semaphore.release();
        }
      });
  try {
    SoftAssertions.assertCondition(
        semaphore.tryAcquire(5000, TimeUnit.MILLISECONDS),
        "Timed out initializing timing module");
  } catch (InterruptedException e) {
    throw new RuntimeException(e);
  }
}
 
Example #3
Source File: ThemedReactContext.java    From react-native-GPay with MIT License 4 votes vote down vote up
@Override
public void addLifecycleEventListener(LifecycleEventListener listener) {
  mReactApplicationContext.addLifecycleEventListener(listener);
}
 
Example #4
Source File: ThemedReactContext.java    From react-native-GPay with MIT License 4 votes vote down vote up
@Override
public void removeLifecycleEventListener(LifecycleEventListener listener) {
  mReactApplicationContext.removeLifecycleEventListener(listener);
}