本文整理汇总了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);
}