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


Java UiThreadUtil.assertOnUiThread方法代码示例

本文整理汇总了Java中com.facebook.react.bridge.UiThreadUtil.assertOnUiThread方法的典型用法代码示例。如果您正苦于以下问题:Java UiThreadUtil.assertOnUiThread方法的具体用法?Java UiThreadUtil.assertOnUiThread怎么用?Java UiThreadUtil.assertOnUiThread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.react.bridge.UiThreadUtil的用法示例。


在下文中一共展示了UiThreadUtil.assertOnUiThread方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dropView

import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
/**
 * Releases all references to given native View.
 */
protected void dropView(View view) {
  UiThreadUtil.assertOnUiThread();
  if (!mRootTags.get(view.getId())) {
    // For non-root views we notify viewmanager with {@link ViewManager#onDropInstance}
    resolveViewManager(view.getId()).onDropViewInstance(view);
  }
  ViewManager viewManager = mTagsToViewManagers.get(view.getId());
  if (view instanceof ViewGroup && viewManager instanceof ViewGroupManager) {
    ViewGroup viewGroup = (ViewGroup) view;
    ViewGroupManager viewGroupManager = (ViewGroupManager) viewManager;
    for (int i = viewGroupManager.getChildCount(viewGroup) - 1; i >= 0; i--) {
      View child = viewGroupManager.getChildAt(viewGroup, i);
      if (mTagsToViews.get(child.getId()) != null) {
        dropView(child);
      }
    }
    viewGroupManager.removeAllViews(viewGroup);
  }
  mTagsToViews.remove(view.getId());
  mTagsToViewManagers.remove(view.getId());
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:25,代码来源:NativeViewHierarchyManager.java

示例2: startTask

import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
/**
 * Start a JS task. Handles invoking {@link AppRegistry#startHeadlessTask} and notifying
 * listeners.
 *
 * @return a unique id representing this task instance.
 */
public synchronized int startTask(final HeadlessJsTaskConfig taskConfig) {
  UiThreadUtil.assertOnUiThread();
  ReactContext reactContext = Assertions.assertNotNull(
    mReactContext.get(),
    "Tried to start a task on a react context that has already been destroyed");
  if (reactContext.getLifecycleState() == LifecycleState.RESUMED &&
    !taskConfig.isAllowedInForeground()) {
    throw new IllegalStateException(
      "Tried to start task " + taskConfig.getTaskKey() +
        " while in foreground, but this is not allowed.");
  }
  final int taskId = mLastTaskId.incrementAndGet();
  mActiveTasks.add(taskId);
  reactContext.getJSModule(AppRegistry.class)
    .startHeadlessTask(taskId, taskConfig.getTaskKey(), taskConfig.getData());
  if (taskConfig.getTimeout() > 0) {
    scheduleTaskTimeout(taskId, taskConfig.getTimeout());
  }
  for (HeadlessJsTaskEventListener listener : mHeadlessJsTaskEventListeners) {
    listener.onHeadlessJsTaskStart(taskId);
  }
  return taskId;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:30,代码来源:HeadlessJsTaskContext.java

示例3: handleReloadJS

import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
@Override
public void handleReloadJS() {
  UiThreadUtil.assertOnUiThread();

  // dismiss redbox if exists
  if (mRedBoxDialog != null) {
    mRedBoxDialog.dismiss();
  }

  if (mDevSettings.isRemoteJSDebugEnabled()) {
    mDevLoadingViewController.showForRemoteJSEnabled();
    mDevLoadingViewVisible = true;
    reloadJSInProxyMode();
  } else {
    String bundleURL =
      mDevServerHelper.getDevServerBundleURL(Assertions.assertNotNull(mJSAppBundleName));
    reloadJSFromServer(bundleURL);
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:20,代码来源:DevSupportManagerImpl.java

示例4: measure

import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
/**
 * Returns true on success, false on failure. If successful, after calling, output buffer will be
 * {x, y, width, height}.
 */
public void measure(int tag, int[] outputBuffer) {
  UiThreadUtil.assertOnUiThread();
  View v = mTagsToViews.get(tag);
  if (v == null) {
    throw new NoSuchNativeViewException("No native view for " + tag + " currently exists");
  }

  View rootView = (View) RootViewUtil.getRootView(v);
  // It is possible that the RootView can't be found because this view is no longer on the screen
  // and has been removed by clipping
  if (rootView == null) {
    throw new NoSuchNativeViewException("Native view " + tag + " is no longer on screen");
  }
  rootView.getLocationInWindow(outputBuffer);
  int rootX = outputBuffer[0];
  int rootY = outputBuffer[1];

  v.getLocationInWindow(outputBuffer);

  outputBuffer[0] = outputBuffer[0] - rootX;
  outputBuffer[1] = outputBuffer[1] - rootY;
  outputBuffer[2] = v.getWidth();
  outputBuffer[3] = v.getHeight();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:29,代码来源:NativeViewHierarchyManager.java

示例5: showPopupMenu

import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
/**
 * Show a {@link PopupMenu}.
 *
 * @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
 *        needs to be the tag of a native view (shadow views can not be anchors)
 * @param items the menu items as an array of strings
 * @param success will be called with the position of the selected item as the first argument, or
 *        no arguments if the menu is dismissed
 */
public void showPopupMenu(int reactTag, ReadableArray items, Callback success) {
  UiThreadUtil.assertOnUiThread();
  View anchor = mTagsToViews.get(reactTag);
  if (anchor == null) {
    throw new JSApplicationIllegalArgumentException("Could not find view with tag " + reactTag);
  }
  PopupMenu popupMenu = new PopupMenu(getReactContextForView(reactTag), anchor);

  Menu menu = popupMenu.getMenu();
  for (int i = 0; i < items.size(); i++) {
    menu.add(Menu.NONE, Menu.NONE, i, items.getString(i));
  }

  PopupMenuCallbackHandler handler = new PopupMenuCallbackHandler(success);
  popupMenu.setOnMenuItemClickListener(handler);
  popupMenu.setOnDismissListener(handler);

  popupMenu.show();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:29,代码来源:NativeViewHierarchyManager.java

示例6: postFrameCallback

import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
public void postFrameCallback(CallbackType type, ChoreographerCompat.FrameCallback frameCallback) {
  UiThreadUtil.assertOnUiThread();
  mCallbackQueues[type.getOrder()].addLast(frameCallback);
  mTotalCallbacks++;
  Assertions.assertCondition(mTotalCallbacks > 0);
  if (!mHasPostedCallback) {
    mChoreographer.postFrameCallback(mReactChoreographerDispatcher);
    mHasPostedCallback = true;
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:11,代码来源:ReactChoreographer.java

示例7: onHostResume

import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
@Override
public void onHostResume() {
  UiThreadUtil.assertOnUiThread();
  if (mRCTEventEmitter == null) {
    mRCTEventEmitter = mReactContext.getJSModule(RCTEventEmitter.class);
  }
  mCurrentFrameCallback.maybePost();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:9,代码来源:EventDispatcher.java

示例8: getInstance

import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
public static ReactChoreographer getInstance() {
  UiThreadUtil.assertOnUiThread();
  if (sInstance == null) {
    sInstance = new ReactChoreographer();
  }
  return sInstance;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:8,代码来源:ReactChoreographer.java

示例9: updateViewExtraData

import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
public void updateViewExtraData(int tag, Object extraData) {
  UiThreadUtil.assertOnUiThread();

  ViewManager viewManager = resolveViewManager(tag);
  View viewToUpdate = resolveView(tag);
  viewManager.updateExtraData(viewToUpdate, extraData);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:8,代码来源:NativeViewHierarchyManager.java

示例10: DeviceEventManagerModule

import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
public DeviceEventManagerModule(
    ReactApplicationContext reactContext,
    final DefaultHardwareBackBtnHandler backBtnHandler) {
  super(reactContext);
  mInvokeDefaultBackPressRunnable = new Runnable() {
    @Override
    public void run() {
      UiThreadUtil.assertOnUiThread();
      backBtnHandler.invokeDefaultOnBackPressed();
    }
  };
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:13,代码来源:DeviceEventManagerModule.java

示例11: removeRootView

import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
public void removeRootView(int rootViewTag) {
  UiThreadUtil.assertOnUiThread();
  if (!mRootTags.get(rootViewTag)) {
      SoftAssertions.assertUnreachable(
          "View with tag " + rootViewTag + " is not registered as a root view");
  }
  View rootView = mTagsToViews.get(rootViewTag);
  dropView(rootView);
  mRootTags.delete(rootViewTag);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:11,代码来源:NativeViewHierarchyManager.java

示例12: updateProperties

import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
public void updateProperties(int tag, ReactStylesDiffMap props) {
  UiThreadUtil.assertOnUiThread();

  try {
    ViewManager viewManager = resolveViewManager(tag);
    View viewToUpdate = resolveView(tag);
    viewManager.updateProperties(viewToUpdate, props);
  } catch (IllegalViewOperationException e) {
    Log.e(TAG, "Unable to update properties for view tag " + tag, e);
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:12,代码来源:NativeViewHierarchyManager.java

示例13: createView

import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
public void createView(
    ThemedReactContext themedContext,
    int tag,
    String className,
    @Nullable ReactStylesDiffMap initialProps) {
  UiThreadUtil.assertOnUiThread();
  SystraceMessage.beginSection(
      Systrace.TRACE_TAG_REACT_VIEW,
      "NativeViewHierarchyManager_createView")
      .arg("tag", tag)
      .arg("className", className)
      .flush();
  try {
    ViewManager viewManager = mViewManagers.get(className);

    View view = viewManager.createView(themedContext, mJSResponderHandler);
    mTagsToViews.put(tag, view);
    mTagsToViewManagers.put(tag, viewManager);

    // Use android View id field to store React tag. This is possible since we don't inflate
    // React views from layout xmls. Thus it is easier to just reuse that field instead of
    // creating another (potentially much more expensive) mapping from view to React tag
    view.setId(tag);
    if (initialProps != null) {
      viewManager.updateProperties(view, initialProps);
    }
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_VIEW);
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:31,代码来源:NativeViewHierarchyManager.java

示例14: removeFrameCallback

import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
public void removeFrameCallback(CallbackType type, ChoreographerCompat.FrameCallback frameCallback) {
  UiThreadUtil.assertOnUiThread();
  if (mCallbackQueues[type.getOrder()].removeFirstOccurrence(frameCallback)) {
    mTotalCallbacks--;
    maybeRemoveFrameCallback();
  } else {
    FLog.e(ReactConstants.TAG, "Tried to remove non-existent frame callback");
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:10,代码来源:ReactChoreographer.java

示例15: dispatchCommand

import com.facebook.react.bridge.UiThreadUtil; //导入方法依赖的package包/类
public void dispatchCommand(int reactTag, int commandId, @Nullable ReadableArray args) {
  UiThreadUtil.assertOnUiThread();
  View view = mTagsToViews.get(reactTag);
  if (view == null) {
    throw new IllegalViewOperationException("Trying to send command to a non-existing view " +
        "with tag " + reactTag);
  }

  ViewManager viewManager = resolveViewManager(reactTag);
  viewManager.receiveCommand(view, commandId, args);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:12,代码来源:NativeViewHierarchyManager.java


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