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); } }
public void init(ReactContext reactContext) { mReactContext = reactContext; reactContext.addLifecycleEventListener(new LifecycleEventListener() { @Override public void onHostResume() { Log.d(LOGTAG, "onHostResume"); switchToVisible(); } @Override public void onHostPause() { Log.d(LOGTAG, "onHostPause"); switchToInvisible(); } @Override public void onHostDestroy() { Log.d(LOGTAG, "onHostDestroy"); switchToInvisible(); } }); }
@Override public void addLifecycleEventListener(LifecycleEventListener listener) { mReactApplicationContext.addLifecycleEventListener(listener); }
@Override public void removeLifecycleEventListener(LifecycleEventListener listener) { mReactApplicationContext.removeLifecycleEventListener(listener); }