本文整理匯總了Java中com.facebook.react.bridge.LifecycleEventListener類的典型用法代碼示例。如果您正苦於以下問題:Java LifecycleEventListener類的具體用法?Java LifecycleEventListener怎麽用?Java LifecycleEventListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LifecycleEventListener類屬於com.facebook.react.bridge包,在下文中一共展示了LifecycleEventListener類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initializeJavaModule
import com.facebook.react.bridge.LifecycleEventListener; //導入依賴的package包/類
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);
}
}
示例2: init
import com.facebook.react.bridge.LifecycleEventListener; //導入依賴的package包/類
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();
}
});
}
示例3: addLifecycleEventListener
import com.facebook.react.bridge.LifecycleEventListener; //導入依賴的package包/類
@Override
public void addLifecycleEventListener(LifecycleEventListener listener) {
mReactApplicationContext.addLifecycleEventListener(listener);
}
示例4: removeLifecycleEventListener
import com.facebook.react.bridge.LifecycleEventListener; //導入依賴的package包/類
@Override
public void removeLifecycleEventListener(LifecycleEventListener listener) {
mReactApplicationContext.removeLifecycleEventListener(listener);
}