本文整理汇总了Java中com.facebook.react.bridge.UiThreadUtil.isOnUiThread方法的典型用法代码示例。如果您正苦于以下问题:Java UiThreadUtil.isOnUiThread方法的具体用法?Java UiThreadUtil.isOnUiThread怎么用?Java UiThreadUtil.isOnUiThread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.react.bridge.UiThreadUtil
的用法示例。
在下文中一共展示了UiThreadUtil.isOnUiThread方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createForMainThread
import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
/**
* @return a MessageQueueThreadImpl corresponding to Android's main UI thread.
*/
private static MessageQueueThreadImpl createForMainThread(
String name,
QueueThreadExceptionHandler exceptionHandler) {
Looper mainLooper = Looper.getMainLooper();
final MessageQueueThreadImpl mqt =
new MessageQueueThreadImpl(name, mainLooper, exceptionHandler);
if (UiThreadUtil.isOnUiThread()) {
Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY);
MessageQueueThreadRegistry.register(mqt);
} else {
UiThreadUtil.runOnUiThread(
new Runnable() {
@Override
public void run() {
Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY);
MessageQueueThreadRegistry.register(mqt);
}
});
}
return mqt;
}
示例2: addRootView
import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
public void addRootView(
final int tag,
final SizeMonitoringFrameLayout rootView,
final ThemedReactContext themedRootContext) {
if (UiThreadUtil.isOnUiThread()) {
mNativeViewHierarchyManager.addRootView(tag, rootView, themedRootContext);
} else {
final Semaphore semaphore = new Semaphore(0);
mReactApplicationContext.runOnUiQueueThread(
new Runnable() {
@Override
public void run() {
mNativeViewHierarchyManager.addRootView(tag, rootView, themedRootContext);
semaphore.release();
}
});
try {
SoftAssertions.assertCondition(
semaphore.tryAcquire(5000, TimeUnit.MILLISECONDS),
"Timed out adding root view");
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
示例3: onEventDispatch
import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
@Override
public void onEventDispatch(Event event) {
// Only support events dispatched from the UI thread.
if (!UiThreadUtil.isOnUiThread()) {
return;
}
if (!mEventDrivers.isEmpty()) {
// If the event has a different name in native convert it to it's JS name.
String eventName = event.getEventName();
Map<String, String> customEventType = mCustomEventTypes.get(eventName);
if (customEventType != null) {
eventName = customEventType.get("registrationName");
}
List<EventAnimationDriver> driversForKey = mEventDrivers.get(event.getViewTag() + eventName);
if (driversForKey != null) {
for (EventAnimationDriver driver : driversForKey) {
event.dispatch(driver);
mRunUpdateNodeList.add(driver.mValueNode);
}
updateNodes(mRunUpdateNodeList);
mRunUpdateNodeList.clear();
}
}
}