当前位置: 首页>>代码示例>>Java>>正文


Java UiThreadUtil.isOnUiThread方法代码示例

本文整理汇总了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;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:26,代码来源:MessageQueueThreadImpl.java

示例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);
    }
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:26,代码来源:UIViewOperationQueue.java

示例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();
    }
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:27,代码来源:NativeAnimatedNodesManager.java


注:本文中的com.facebook.react.bridge.UiThreadUtil.isOnUiThread方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。