com.facebook.react.bridge.JavaScriptExecutorFactory#com.facebook.infer.annotation.Assertions源码实例Demo

下面列出了com.facebook.react.bridge.JavaScriptExecutorFactory#com.facebook.infer.annotation.Assertions 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public void receiveCommand(RNAGSMapView mapView, int command, ReadableArray args) {
    Assertions.assertNotNull(mapView);
    Assertions.assertNotNull(args);
    switch (command) {
        case SHOW_CALLOUT: mapView.showCallout(args.getMap(0));return;
        case CENTER_MAP: mapView.centerMap(args.getArray(0));return;
        case ADD_GRAPHICS_OVERLAY: mapView.addGraphicsOverlay(args.getMap(0));return;
        case REMOVE_GRAPHICS_OVERLAY: mapView.removeGraphicsOverlay(args.getString(0));return;
        case ADD_POINTS_TO_OVERLAY: mapView.addPointsToOverlay(args.getMap(0));return;
        case REMOVE_POINTS_FROM_OVERLAY: mapView.removePointsFromOverlay(args.getMap(0));return;
        case UPDATE_POINTS_IN_GRAPHICS_OVERLAY: mapView.updatePointsInGraphicsOverlay(args.getMap(0));return;
        case ROUTE_GRAPHICS_OVERLAY: mapView.routeGraphicsOverlay(args.getMap(0));return;
        case SET_ROUTE_IS_VISIBLE: mapView.setRouteIsVisible(args.getBoolean(0));return;
        case DISPOSE: mapView.onHostDestroy();
    }
}
 
源代码2 项目: buck   文件: NdkCxxPlatforms.java
private NdkCxxToolchainPaths(
    ProjectFilesystem filesystem,
    Path ndkRoot,
    String ndkVersion,
    NdkCxxPlatformTargetConfiguration targetConfiguration,
    String hostName,
    NdkCxxRuntime cxxRuntime,
    boolean strict,
    boolean unifiedHeaders) {
  this.filesystem = filesystem;
  this.cachedPaths = new HashMap<>();
  this.strict = strict;
  this.unifiedHeaders = unifiedHeaders;

  this.targetConfiguration = targetConfiguration;
  this.hostName = hostName;
  this.cxxRuntime = cxxRuntime;
  this.ndkRoot = ndkRoot;
  this.ndkVersion = ndkVersion;
  this.ndkMajorVersion = getNdkMajorVersion(ndkVersion);

  Assertions.assertCondition(ndkMajorVersion > 0, "Unknown ndk version: " + ndkVersion);
}
 
protected int canvasExtent(int dstExtent, int srcExtent, int defaultExtent) {
  if (mResizeCanvasTo == null) {
    return defaultExtent;
  }

  if ("dstImage".equals(mResizeCanvasTo)) {
    return dstExtent;
  }

  if ("srcImage".equals(mResizeCanvasTo)) {
    return srcExtent;
  }

  if ("MIN".equals(mResizeCanvasTo)) {
    return Math.min(dstExtent, srcExtent);
  }

  if ("MAX".equals(mResizeCanvasTo)) {
    return Math.max(dstExtent, srcExtent);
  }

  throw Assertions.assertUnreachable(
    "ImageFilterKit: invalid property 'resizeCanvasTo' - " + mResizeCanvasTo
  );
}
 
@Override
public void receiveCommand(RN3DView view, int commandType, @Nullable ReadableArray args) {
  Assertions.assertNotNull(view);
  Assertions.assertNotNull(args);
  switch (commandType) {
    case COMMAND_START_ANIMATION: {
      view.setPlay(true);
      return;
    }
    case COMMAND_STOP_ANIMATION: {
      view.setPlay(false);
      return;
    }
    case COMMAND_SET_PROGRESS: {
      view.setProgress((float)args.getDouble(0));
      return;
    }
    default:
      throw new IllegalArgumentException(String.format(
              "Unsupported command %d received by %s.",
              commandType,
              getClass().getSimpleName()));
  }
}
 
@Nullable
Postprocessor createSingular(
  @Nullable String name,
  int width,
  int height,
  @Nullable JSONObject config,
  @Nonnull Context context
) {
  @Nullable CreateSingular filter = mSingulars.get(name);

  Assertions.assertCondition(
    filter != null,
    "ImageFilterKit: Can't find '" + name + "' filter in registry."
  );

  return filter != null ? filter.create(width, height, config, context) : null;
}
 
public void setConfig(@Nullable String config) {
  try {
    mConfig = config != null ? new JSONObject(config) : null;
  } catch (JSONException exc) {
    Assertions.assertCondition(
      false,
      "ImageFilterKit: Bad config - " + exc.getMessage()
    );
  }

  if (mIsReady) {
    sendJSEvent(ImageFilterEvent.ON_FILTERING_START, null);
    reset();
    runFilterPipeline();
  }
}
 
源代码7 项目: react-native-aztec   文件: ReactAztecManager.java
@Override
public void receiveCommand(final ReactAztecText parent, int commandType, @Nullable ReadableArray args) {
    Assertions.assertNotNull(parent);
    if (commandType == COMMAND_NOTIFY_APPLY_FORMAT) {
        final String format = args.getString(0);
        Log.d(TAG, String.format("Apply format: %s", format));
        parent.applyFormat(format);
        return;
    } else if (commandType == mFocusTextInputCommandCode) {
        parent.requestFocusFromJS();
        return;
    } else if (commandType == mBlurTextInputCommandCode) {
        parent.clearFocusFromJS();
        return;
    }
    super.receiveCommand(parent, commandType, args);
}
 
protected ReactInstanceManager createReactInstanceManager() {
    ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setJSMainModulePath(getJSMainModuleName())
            .setUseDeveloperSupport(getUseDeveloperSupport())
            .setRedBoxHandler(getRedBoxHandler())
            .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
            .setUIImplementationProvider(getUIImplementationProvider())
            .setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
            .setJSIModulesPackage(getJSIModulePackage())
            .setDevBundleDownloadListener(getDevBundleDownloadListener());

    for (ReactPackage reactPackage : getPackages()) {
        builder.addPackage(reactPackage);
    }

    String jsBundleFile = getJSBundleFile();
    if (jsBundleFile != null) {
        builder.setJSBundleFile(jsBundleFile);
    } else {
        builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
    }
    return builder.build();
}
 
源代码9 项目: react-native-GPay   文件: ReactEditText.java
public ReactEditText(Context context) {
  super(context);
  setFocusableInTouchMode(false);

  mReactBackgroundManager = new ReactViewBackgroundManager(this);
  mInputMethodManager = (InputMethodManager)
      Assertions.assertNotNull(getContext().getSystemService(Context.INPUT_METHOD_SERVICE));
  mDefaultGravityHorizontal =
      getGravity() & (Gravity.HORIZONTAL_GRAVITY_MASK | Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK);
  mDefaultGravityVertical = getGravity() & Gravity.VERTICAL_GRAVITY_MASK;
  mNativeEventCount = 0;
  mMostRecentEventCount = 0;
  mIsSettingTextFromJS = false;
  mIsJSSettingFocus = false;
  mBlurOnSubmit = null;
  mDisableFullscreen = false;
  mListeners = null;
  mTextWatcherDelegator = null;
  mStagedInputType = getInputType();
  mKeyListener = new InternalKeyListener();
  mScrollWatcher = null;
}
 
源代码10 项目: react-native-GPay   文件: EventDispatcher.java
/**
 * Sends the given Event to JS, coalescing eligible events if JS is backed up.
 */
public void dispatchEvent(Event event) {
  Assertions.assertCondition(event.isInitialized(), "Dispatched event hasn't been initialized");

  for (EventDispatcherListener listener : mListeners) {
    listener.onEventDispatch(event);
  }

  synchronized (mEventsStagingLock) {
    mEventStaging.add(event);
    Systrace.startAsyncFlow(
        Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
        event.getEventName(),
        event.getUniqueID());
  }
  if (mReactEventEmitter != null) {
    // If the host activity is paused, the frame callback may not be currently
    // posted. Ensure that it is so that this event gets delivered promptly.
    mCurrentFrameCallback.maybePostFromNonUI();
  } else {
    // No JS application has started yet, or resumed. This can happen when a ReactRootView is
    // added to view hierarchy, but ReactContext creation has not completed yet. In this case, any
    // touch event dispatch will hit this codepath, and we simply queue them so that they
    // are dispatched once ReactContext creation completes and JS app is running.
  }
}
 
源代码11 项目: react-native-GPay   文件: ReactShadowNodeImpl.java
@Override
public void removeAndDisposeAllChildren() {
  if (getChildCount() == 0) {
    return;
  }

  int decrease = 0;
  for (int i = getChildCount() - 1; i >= 0; i--) {
    if (mYogaNode != null && !isYogaLeafNode()) {
      mYogaNode.removeChildAt(i);
    }
    ReactShadowNodeImpl toRemove = getChildAt(i);
    toRemove.mParent = null;
    toRemove.dispose();

    decrease += toRemove.isLayoutOnly() ? toRemove.getTotalNativeChildren() : 1;
  }
  Assertions.assertNotNull(mChildren).clear();
  markUpdated();

  mTotalNativeChildren -= decrease;
  updateNativeChildrenCountInParent(-decrease);
}
 
源代码12 项目: react-native-GPay   文件: UIImplementation.java
private void measureLayoutRelativeToVerifiedAncestor(
    ReactShadowNode node,
    ReactShadowNode ancestor,
    int[] outputBuffer) {
  int offsetX = 0;
  int offsetY = 0;
  if (node != ancestor) {
    offsetX = Math.round(node.getLayoutX());
    offsetY = Math.round(node.getLayoutY());
    ReactShadowNode current = node.getParent();
    while (current != ancestor) {
      Assertions.assertNotNull(current);
      assertNodeDoesNotNeedCustomLayoutForChildren(current);
      offsetX += Math.round(current.getLayoutX());
      offsetY += Math.round(current.getLayoutY());
      current = current.getParent();
    }
    assertNodeDoesNotNeedCustomLayoutForChildren(ancestor);
  }

  outputBuffer[0] = offsetX;
  outputBuffer[1] = offsetY;
  outputBuffer[2] = node.getScreenWidth();
  outputBuffer[3] = node.getScreenHeight();
}
 
protected ReactInstanceManager createReactInstanceManager() {
    ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setJSMainModulePath(getJSMainModuleName())
            .setUseDeveloperSupport(getUseDeveloperSupport())
            .setRedBoxHandler(getRedBoxHandler())
            .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
            .setUIImplementationProvider(getUIImplementationProvider())
            .setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
            .setJSIModulesPackage(getJSIModulePackage())
            .setDevBundleDownloadListener(getDevBundleDownloadListener());

    for (ReactPackage reactPackage : getPackages()) {
        builder.addPackage(reactPackage);
    }

    String jsBundleFile = getJSBundleFile();
    if (jsBundleFile != null) {
        builder.setJSBundleFile(jsBundleFile);
    } else {
        builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
    }
    return builder.build();
}
 
源代码14 项目: react-native-GPay   文件: ReactViewGroup.java
void removeViewWithSubviewClippingEnabled(View view) {
  Assertions.assertCondition(mRemoveClippedSubviews);
  Assertions.assertNotNull(mClippingRect);
  Assertions.assertNotNull(mAllChildren);
  view.removeOnLayoutChangeListener(mChildrenLayoutChangeListener);
  int index = indexOfChildInAllChildren(view);
  if (isChildInViewGroup(mAllChildren[index])) {
    int childIndexOffset = 0;
    for (int i = 0; i < index; i++) {
      if (!isChildInViewGroup(mAllChildren[i])) {
        childIndexOffset++;
      }
    }
    super.removeViewsInLayout(index - childIndexOffset, 1);
  }
  removeFromArray(index);
}
 
源代码15 项目: react-native-GPay   文件: ReactViewGroup.java
private void addInArray(View child, int index) {
  View[] children = Assertions.assertNotNull(mAllChildren);
  final int count = mAllChildrenCount;
  final int size = children.length;
  if (index == count) {
    if (size == count) {
      mAllChildren = new View[size + ARRAY_CAPACITY_INCREMENT];
      System.arraycopy(children, 0, mAllChildren, 0, size);
      children = mAllChildren;
    }
    children[mAllChildrenCount++] = child;
  } else if (index < count) {
    if (size == count) {
      mAllChildren = new View[size + ARRAY_CAPACITY_INCREMENT];
      System.arraycopy(children, 0, mAllChildren, 0, index);
      System.arraycopy(children, index, mAllChildren, index + 1, count - index);
      children = mAllChildren;
    } else {
      System.arraycopy(children, index, children, index + 1, count - index);
    }
    children[index] = child;
    mAllChildrenCount++;
  } else {
    throw new IndexOutOfBoundsException("index=" + index + " count=" + count);
  }
}
 
protected ReactInstanceManager createReactInstanceManager() {
    ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setJSMainModulePath(getJSMainModuleName())
            .setUseDeveloperSupport(getUseDeveloperSupport())
            .setRedBoxHandler(getRedBoxHandler())
            .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
            .setUIImplementationProvider(getUIImplementationProvider())
            .setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
            .setJSIModulesProvider(getJSIModulesProvider())
            .setDevBundleDownloadListener(getDevBundleDownloadListener());

    for (ReactPackage reactPackage : getPackages()) {
        builder.addPackage(reactPackage);
    }

    String jsBundleFile = getJSBundleFile();
    if (jsBundleFile != null) {
        builder.setJSBundleFile(jsBundleFile);
    } else {
        builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
    }
    return builder.build();
}
 
源代码17 项目: react-native-GPay   文件: UIImplementation.java
/**
 * Invoked by React to create a new node with a given tag, class name and properties.
 */
public void createView(int tag, String className, int rootViewTag, ReadableMap props) {
  ReactShadowNode cssNode = createShadowNode(className);
  ReactShadowNode rootNode = mShadowNodeRegistry.getNode(rootViewTag);
  Assertions.assertNotNull(rootNode, "Root node with tag " + rootViewTag + " doesn't exist");
  cssNode.setReactTag(tag);
  cssNode.setViewClassName(className);
  cssNode.setRootTag(rootNode.getReactTag());
  cssNode.setThemedContext(rootNode.getThemedContext());

  mShadowNodeRegistry.addNode(cssNode);

  ReactStylesDiffMap styles = null;
  if (props != null) {
    styles = new ReactStylesDiffMap(props);
    cssNode.updateProperties(styles);
  }

  handleCreateView(cssNode, rootViewTag, styles);
}
 
源代码18 项目: react-native-GPay   文件: UIImplementation.java
private void assertNodeDoesNotNeedCustomLayoutForChildren(ReactShadowNode node) {
  ViewManager viewManager = Assertions.assertNotNull(mViewManagers.get(node.getViewClass()));
  ViewGroupManager viewGroupManager;
  if (viewManager instanceof ViewGroupManager) {
    viewGroupManager = (ViewGroupManager) viewManager;
  } else {
    throw new IllegalViewOperationException("Trying to use view " + node.getViewClass() +
        " as a parent, but its Manager doesn't extends ViewGroupManager");
  }
  if (viewGroupManager != null && viewGroupManager.needsCustomLayoutForChildren()) {
    throw new IllegalViewOperationException(
        "Trying to measure a view using measureLayout/measureLayoutRelativeToParent relative to" +
            " an ancestor that requires custom layout for it's children (" + node.getViewClass() +
            "). Use measure instead.");
  }
}
 
@Override
public void receiveCommand(SketchViewContainer root, int commandId, @Nullable ReadableArray args) {
  Assertions.assertNotNull(root);

  switch (commandId) {
    case COMMAND_CLEAR_SKETCH:
      root.sketchView.clear();
      return;
    case COMMAND_CHANGE_TOOL:
      Assertions.assertNotNull(args);
      int toolId = args.getInt(0);
      root.sketchView.setToolType(toolId);
      return;
    case COMMAND_SAVE_SKETCH:
      try {
        SketchFile sketchFile = root.saveToLocalCache();
        onSaveSketch(root, sketchFile);
        return;
      } catch (IOException e) {
        e.printStackTrace();
      }
    default:
      throw new IllegalArgumentException(String.format(Locale.ENGLISH, "Unsupported command %d.", commandId));
  }
}
 
源代码20 项目: react-native-GPay   文件: ReactShadowNodeImpl.java
@Override
public ReactShadowNodeImpl mutableCopy(long instanceHandle) {
  ReactShadowNodeImpl copy = copy();
  Assertions.assertCondition(
      getClass() == copy.getClass(),
      "Copied shadow node must use the same class");
  copy.mInstanceHandle = instanceHandle;
  if (mYogaNode != null) {
    copy.mYogaNode = mYogaNode.clone();
    copy.mYogaNode.setData(copy);
  } else {
    // Virtual ReactShadowNode do not have a YogaNode associated
    copy.mYogaNode = null;
  }
  copy.mTotalNativeChildren = mTotalNativeChildren;
  copy.mNativeChildren = copyChildren(mNativeChildren);
  copy.mChildren = copyChildren(mChildren);

  return copy;
}
 
源代码21 项目: react-native-shake   文件: CustomShakeDetector.java
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
  if (sensorEvent.timestamp - mLastTimestamp < MIN_TIME_BETWEEN_SAMPLES_NS) {
    return;
  }

  Assertions.assertNotNull(mTimestamps);
  Assertions.assertNotNull(mMagnitudes);

  float ax = sensorEvent.values[0];
  float ay = sensorEvent.values[1];
  float az = sensorEvent.values[2];

  mLastTimestamp = sensorEvent.timestamp;
  mTimestamps[mCurrentIndex] = sensorEvent.timestamp;
  mMagnitudes[mCurrentIndex] = Math.sqrt(ax * ax + ay * ay + az * az);

  maybeDispatchShake(sensorEvent.timestamp);

  mCurrentIndex = (mCurrentIndex + 1) % MAX_SAMPLES;
}
 
源代码22 项目: react-native-GPay   文件: HeadlessJsTaskContext.java
/**
 * Finish a JS task. Doesn't actually stop the task on the JS side, only removes it from the list
 * of active tasks and notifies listeners. A task can only be finished once.
 *
 * @param taskId the unique id returned by {@link #startTask}.
 */
public synchronized void finishTask(final int taskId) {
  Assertions.assertCondition(
    mActiveTasks.remove(taskId),
    "Tried to finish non-existent task with id " + taskId + ".");
  Runnable timeout = mTaskTimeouts.get(taskId);
  if (timeout != null) {
    mHandler.removeCallbacks(timeout);
    mTaskTimeouts.remove(taskId);
  }
  UiThreadUtil.runOnUiThread(new Runnable() {
    @Override
    public void run() {
      for (HeadlessJsTaskEventListener listener : mHeadlessJsTaskEventListeners) {
        listener.onHeadlessJsTaskFinish(taskId);
      }
    }
  });
}
 
@Override public void receiveCommand(TabbedViewPager viewPager, int commandType,
    @Nullable ReadableArray args) {
  Assertions.assertNotNull(viewPager);
  Assertions.assertNotNull(args);
  switch (commandType) {
    case COMMAND_SET_PAGE: {
      viewPager.setCurrentItemFromJs(args.getInt(0), true);
      return;
    }
    case COMMAND_SET_PAGE_WITHOUT_ANIMATION: {
      viewPager.setCurrentItemFromJs(args.getInt(0), false);
      return;
    }
    default:
      throw new IllegalArgumentException(
          String.format("Unsupported command %d received by %s.", commandType,
              getClass().getSimpleName()));
  }
}
 
源代码24 项目: react-native-GPay   文件: CatalystInstanceImpl.java
/**
 * Initialize all the native modules
 */
@VisibleForTesting
@Override
public void initialize() {
  Log.d(ReactConstants.TAG, "CatalystInstanceImpl.initialize()");
  Assertions.assertCondition(
      !mInitialized,
      "This catalyst instance has already been initialized");
  // We assume that the instance manager blocks on running the JS bundle. If
  // that changes, then we need to set mAcceptCalls just after posting the
  // task that will run the js bundle.
  Assertions.assertCondition(
      mAcceptCalls,
      "RunJSBundle hasn't completed.");
  mInitialized = true;
  mNativeModulesQueueThread.runOnQueue(new Runnable() {
    @Override
    public void run() {
      mNativeModuleRegistry.notifyJSInstanceInitialized();
    }
  });
}
 
源代码25 项目: react-native-GPay   文件: JSTouchDispatcher.java
private void dispatchCancelEvent(MotionEvent androidEvent, EventDispatcher eventDispatcher) {
  // This means the gesture has already ended, via some other CANCEL or UP event. This is not
  // expected to happen very often as it would mean some child View has decided to intercept the
  // touch stream and start a native gesture only upon receiving the UP/CANCEL event.
  if (mTargetTag == -1) {
    FLog.w(
      ReactConstants.TAG,
      "Can't cancel already finished gesture. Is a child View trying to start a gesture from " +
        "an UP/CANCEL event?");
    return;
  }

  Assertions.assertCondition(
    !mChildIsHandlingNativeGesture,
    "Expected to not have already sent a cancel for this gesture");
  Assertions.assertNotNull(eventDispatcher).dispatchEvent(
    TouchEvent.obtain(
      mTargetTag,
      TouchEventType.CANCEL,
      androidEvent,
      mGestureStartTime,
      mTargetCoordinates[0],
      mTargetCoordinates[1],
      mTouchEventCoalescingKeyHelper));
}
 
源代码26 项目: react-native-GPay   文件: ReadableNativeMap.java
private HashMap<String,Object> getLocalMap() {
  // Fast return for the common case
  if (mLocalMap != null) {
    return mLocalMap;
  }
  // Check and when necessary get keys atomicaly
  synchronized (this) {
    if (mKeys == null) {
      mKeys = Assertions.assertNotNull(importKeys());
      mJniCallCounter++;
    }
    if (mLocalMap == null) {
      Object[] values = Assertions.assertNotNull(importValues());
      mJniCallCounter++;
      mLocalMap = new HashMap<>();
      for(int i = 0; i< mKeys.length; i++) {
        mLocalMap.put(mKeys[i], values[i]);
      }
    }
  }
  return mLocalMap;
}
 
源代码27 项目: react-native-GPay   文件: ReadableNativeMap.java
private HashMap<String,ReadableType> getLocalTypeMap() {
  // Fast and non-blocking return for common case
  if (mLocalTypeMap != null) {
    return mLocalTypeMap;
  }
  // Check and when necessary get keys
  synchronized (this) {
    if (mKeys == null) {
      mKeys = Assertions.assertNotNull(importKeys());
      mJniCallCounter++;
    }
    // check that no other thread has already updated
    if (mLocalTypeMap == null) {
      Object[] types = Assertions.assertNotNull(importTypes());
      mJniCallCounter++;
      mLocalTypeMap = new HashMap<>();
      for(int i = 0; i< mKeys.length; i++) {
        mLocalTypeMap.put(mKeys[i], (ReadableType) types[i]);
      }
    }
  }
  return mLocalTypeMap;
}
 
源代码28 项目: react-native-GPay   文件: ReactShadowNodeImpl.java
@Override
public ReactShadowNodeImpl mutableCopyWithNewChildren(long instanceHandle) {
  ReactShadowNodeImpl copy = copy();
  copy.mInstanceHandle = instanceHandle;
  Assertions.assertCondition(
      getClass() == copy.getClass(),
      "Copied shadow node must use the same class");
  if (mYogaNode != null) {
    copy.mYogaNode = mYogaNode.cloneWithNewChildren();
    copy.mYogaNode.setData(copy);
  } else {
    // Virtual ReactShadowNode do not have a YogaNode associated
    copy.mYogaNode = null;
  }
  copy.mNativeChildren = null;
  copy.mChildren = null;
  copy.mTotalNativeChildren = 0;
  return copy;
}
 
源代码29 项目: react-native-GPay   文件: HeadlessJsTaskContext.java
/**
 * 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;
}
 
源代码30 项目: react-native-GPay   文件: TouchEvent.java
@Override
public boolean canCoalesce() {
  // We can coalesce move events but not start/end events. Coalescing move events should probably
  // append historical move data like MotionEvent batching does. This is left as an exercise for
  // the reader.
  switch (Assertions.assertNotNull(mTouchEventType)) {
    case START:
    case END:
    case CANCEL:
      return false;
    case MOVE:
      return true;
    default:
      throw new RuntimeException("Unknown touch event type: " + mTouchEventType);
  }
}