Java 类com.facebook.react.bridge.ReadableArray 实例源码

项目:RNLearn_Project1    文件:ExceptionsManagerModule.java   
private String stackTraceToString(String message, ReadableArray stack) {
  StringBuilder stringBuilder = new StringBuilder(message).append(", stack:\n");
  for (int i = 0; i < stack.size(); i++) {
    ReadableMap frame = stack.getMap(i);
    stringBuilder
        .append(frame.getString("methodName"))
        .append("@")
        .append(stackFrameToModuleId(frame))
        .append(frame.getInt("lineNumber"));
    if (frame.hasKey("column") &&
        !frame.isNull("column") &&
        frame.getType("column") == ReadableType.Number) {
      stringBuilder
          .append(":")
          .append(frame.getInt("column"));
    }
    stringBuilder.append("\n");
  }
  return stringBuilder.toString();
}
项目:RNLearn_Project1    文件:CatalystNativeJSToJavaParametersTestCase.java   
public void testArrayWithMaps() {
  mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnArrayWithMaps();
  waitForBridgeAndUIIdle();

  List<ReadableArray> calls = mRecordingTestModule.getArrayCalls();
  assertEquals(1, calls.size());
  ReadableArray array = calls.get(0);
  assertEquals(2, array.size());

  assertFalse(array.isNull(0));
  ReadableMap m1 = array.getMap(0);
  ReadableMap m2 = array.getMap(1);

  assertEquals("m1v1", m1.getString("m1k1"));
  assertEquals("m1v2", m1.getString("m1k2"));
  assertEquals("m2v1", m2.getString("m2k1"));
}
项目:RNLearn_Project1    文件:NativeViewHierarchyManager.java   
/**
 * 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();
}
项目:RNLearn_Project1    文件:StackTraceHelper.java   
/**
 * Convert a JavaScript stack trace (see {@code parseErrorStack} JS module) to an array of
 * {@link StackFrame}s.
 */
public static StackFrame[] convertJsStackTrace(@Nullable ReadableArray stack) {
  int size = stack != null ? stack.size() : 0;
  StackFrame[] result = new StackFrame[size];
  for (int i = 0; i < size; i++) {
    ReadableMap frame = stack.getMap(i);
    String methodName = frame.getString("methodName");
    String fileName = frame.getString("file");
    int lineNumber = -1;
    if (frame.hasKey(LINE_NUMBER_KEY) && !frame.isNull(LINE_NUMBER_KEY)) {
      lineNumber = frame.getInt(LINE_NUMBER_KEY);
    }
    int columnNumber = -1;
    if (frame.hasKey(COLUMN_KEY) && !frame.isNull(COLUMN_KEY)) {
      columnNumber = frame.getInt(COLUMN_KEY);
    }
    result[i] = new StackFrameImpl(fileName, methodName, lineNumber, columnNumber);
  }
  return result;
}
项目:RNLearn_Project1    文件:CatalystNativeJSToJavaParametersTestCase.java   
public void testArrayWithMaps() {
  mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnArrayWithMaps();
  waitForBridgeAndUIIdle();

  List<ReadableArray> calls = mRecordingTestModule.getArrayCalls();
  assertEquals(1, calls.size());
  ReadableArray array = calls.get(0);
  assertEquals(2, array.size());

  assertFalse(array.isNull(0));
  ReadableMap m1 = array.getMap(0);
  ReadableMap m2 = array.getMap(1);

  assertEquals("m1v1", m1.getString("m1k1"));
  assertEquals("m1v2", m1.getString("m1k2"));
  assertEquals("m2v1", m2.getString("m2k1"));
}
项目:react-native-scandit    文件:ReactBridgeHelpers.java   
public static JSONArray convertArrayToJson(ReadableArray readableArray) throws JSONException {
    JSONArray array = new JSONArray();
    for (int i = 0; i < readableArray.size(); i++) {
        switch (readableArray.getType(i)) {
            case Null:
                break;
            case Boolean:
                array.put(readableArray.getBoolean(i));
                break;
            case Number:
                array.put(readableArray.getDouble(i));
                break;
            case String:
                array.put(readableArray.getString(i));
                break;
            case Map:
                array.put(convertMapToJson(readableArray.getMap(i)));
                break;
            case Array:
                array.put(convertArrayToJson(readableArray.getArray(i)));
                break;
        }
    }
    return array;
}
项目:react-native-fast-image    文件:FastImageViewModule.java   
@ReactMethod
public void preload(final ReadableArray sources) {
    final Activity activity = getCurrentActivity();
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < sources.size(); i++) {
                final ReadableMap source = sources.getMap(i);
                final GlideUrl glideUrl = FastImageViewConverter.glideUrl(source);
                final Priority priority = FastImageViewConverter.priority(source);
                Glide
                        .with(activity.getApplicationContext())
                        .load(glideUrl)
                        .priority(priority)
                        .placeholder(TRANSPARENT_DRAWABLE)
                        .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                        .preload();
            }
        }
    });
}
项目:RNLearn_Project1    文件:NativeViewHierarchyOptimizer.java   
/**
 * Handles a setChildren call.  This is a simplification of handleManagerChildren that only adds
 * children in index order of the childrenTags array
 */
public void handleSetChildren(
  ReactShadowNode nodeToManage,
  ReadableArray childrenTags
) {
  if (!ENABLED) {
    mUIViewOperationQueue.enqueueSetChildren(
      nodeToManage.getReactTag(),
      childrenTags);
    return;
  }

  for (int i = 0; i < childrenTags.size(); i++) {
    ReactShadowNode nodeToAdd = mShadowNodeRegistry.getNode(childrenTags.getInt(i));
    addNodeToNode(nodeToManage, nodeToAdd, i);
  }
}
项目:RNLearn_Project1    文件:StackTraceHelper.java   
/**
 * Convert a JavaScript stack trace (see {@code parseErrorStack} JS module) to an array of
 * {@link StackFrame}s.
 */
public static StackFrame[] convertJsStackTrace(@Nullable ReadableArray stack) {
  int size = stack != null ? stack.size() : 0;
  StackFrame[] result = new StackFrame[size];
  for (int i = 0; i < size; i++) {
    ReadableMap frame = stack.getMap(i);
    String methodName = frame.getString("methodName");
    String fileName = frame.getString("file");
    int lineNumber = -1;
    if (frame.hasKey(LINE_NUMBER_KEY) && !frame.isNull(LINE_NUMBER_KEY)) {
      lineNumber = frame.getInt(LINE_NUMBER_KEY);
    }
    int columnNumber = -1;
    if (frame.hasKey(COLUMN_KEY) && !frame.isNull(COLUMN_KEY)) {
      columnNumber = frame.getInt(COLUMN_KEY);
    }
    result[i] = new StackFrameImpl(fileName, methodName, lineNumber, columnNumber);
  }
  return result;
}
项目:react-native-tabbed-view-pager-android    文件:TabbedViewPagerManager.java   
@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()));
  }
}
项目:react-native-taptargetview    文件:RNTapTargetViewModule.java   
@ReactMethod
public void ShowSequence(final ReadableArray views, final ReadableMap props, final Promise promise) {
    final Activity activity = this.getCurrentActivity();
    final List<TapTarget> targetViews = new ArrayList<TapTarget>();

    for (int i = 0;i < views.size();i++) {
        int view = views.getInt(i);
        targetViews.add(this.generateTapTarget(view, props.getMap(String.valueOf(view))));
    }

    this.getCurrentActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
            TapTargetSequence tapTargetSequence = new TapTargetSequence(activity).targets(targetViews);
            tapTargetSequence.continueOnCancel(true);
            tapTargetSequence.start();
        }
    });

}
项目:react-native-sparkbutton    文件:RNSparkButtonViewManager.java   
@Override
public void receiveCommand(
        final RNSparkButton view,
        int commandType,
        @Nullable ReadableArray args) {
    Assertions.assertNotNull(view);
    Assertions.assertNotNull(args);
    switch (commandType) {
        case COMMAND_PLAY_ANIMATION: {
            view.playAnimation();
            return;
        }

        default:
            throw new IllegalArgumentException(String.format(
                    "Unsupported command %d received by %s.",
                    commandType,
                    getClass().getSimpleName()));
    }
}
项目:RNLearn_Project1    文件:NativeViewHierarchyManager.java   
/**
 * Simplified version of manageChildren that only deals with adding children views
 */
public void setChildren(
  int tag,
  ReadableArray childrenTags) {
  ViewGroup viewToManage = (ViewGroup) mTagsToViews.get(tag);
  ViewGroupManager viewManager = (ViewGroupManager) resolveViewManager(tag);

  for (int i = 0; i < childrenTags.size(); i++) {
    View viewToAdd = mTagsToViews.get(childrenTags.getInt(i));
    if (viewToAdd == null) {
      throw new IllegalViewOperationException(
        "Trying to add unknown view tag: "
          + childrenTags.getInt(i) + "\n detail: " +
          constructSetChildrenErrorMessage(
            viewToManage,
            viewManager,
            childrenTags));
    }
    viewManager.addView(viewToManage, viewToAdd, i);
  }
}
项目:RNLearn_Project1    文件:NativeViewHierarchyManager.java   
/**
 * Simplified version of constructManageChildrenErrorMessage that only deals with adding children
 * views
 */
private static String constructSetChildrenErrorMessage(
  ViewGroup viewToManage,
  ViewGroupManager viewManager,
  ReadableArray childrenTags) {
  ViewAtIndex[] viewsToAdd = new ViewAtIndex[childrenTags.size()];
  for (int i = 0; i < childrenTags.size(); i++) {
    viewsToAdd[i] = new ViewAtIndex(childrenTags.getInt(i), i);
  }
  return constructManageChildrenErrorMessage(
    viewToManage,
    viewManager,
    null,
    viewsToAdd,
    null
  );
}
项目:react-native-android-library-humaniq-api    文件:ModelConverterUtils.java   
private static JSONArray convertArrayToJson(ReadableArray readableArray) throws JSONException {
  JSONArray array = new JSONArray();
  for (int i = 0; i < readableArray.size(); i++) {
    switch (readableArray.getType(i)) {
      case Null:
        break;
      case Boolean:
        array.put(readableArray.getBoolean(i));
        break;
      case Number:
        array.put(readableArray.getDouble(i));
        break;
      case String:
        array.put(readableArray.getString(i));
        break;
      case Map:
        array.put(convertMapToJson(readableArray.getMap(i)));
        break;
      case Array:
        array.put(convertArrayToJson(readableArray.getArray(i)));
        break;
    }
  }
  return array;
}
项目:RNLearn_Project1    文件:CatalystNativeJSToJavaParametersTestCase.java   
public void testGetWrongTypeFromArray() {
  mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class)
      .returnArrayWithStringDoubleIntMapArrayBooleanNull();
  waitForBridgeAndUIIdle();

  List<ReadableArray> calls = mRecordingTestModule.getArrayCalls();
  assertEquals(1, calls.size());
  ReadableArray array = calls.get(0);

  assertUnexpectedTypeExceptionThrown(array, 0, "boolean");
  assertUnexpectedTypeExceptionThrown(array, 1, "string");
  assertUnexpectedTypeExceptionThrown(array, 2, "array");
  assertUnexpectedTypeExceptionThrown(array, 3, "double");
  assertUnexpectedTypeExceptionThrown(array, 4, "map");
  assertUnexpectedTypeExceptionThrown(array, 5, "array");
}
项目:RNLearn_Project1    文件:ReactViewManager.java   
@Override
public void receiveCommand(ReactViewGroup root, int commandId, @Nullable ReadableArray args) {
  switch (commandId) {
    case CMD_HOTSPOT_UPDATE: {
      if (args == null || args.size() != 2) {
        throw new JSApplicationIllegalArgumentException(
            "Illegal number of arguments for 'updateHotspot' command");
      }
      if (Build.VERSION.SDK_INT >= 21) {
        float x = PixelUtil.toPixelFromDIP(args.getDouble(0));
        float y = PixelUtil.toPixelFromDIP(args.getDouble(1));
        root.drawableHotspotChanged(x, y);
      }
      break;
    }
    case CMD_SET_PRESSED: {
      if (args == null || args.size() != 1) {
        throw new JSApplicationIllegalArgumentException(
            "Illegal number of arguments for 'setPressed' command");
      }
      root.setPressed(args.getBoolean(0));
      break;
    }
  }
}
项目:RNLearn_Project1    文件:CatalystNativeJSToJavaParametersTestCase.java   
public void testIntOutOfRangeThrown() {
  mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnArrayWithLargeInts();
  mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnMapWithLargeInts();
  waitForBridgeAndUIIdle();

  assertEquals(1, mRecordingTestModule.getArrayCalls().size());
  assertEquals(1, mRecordingTestModule.getMapCalls().size());

  ReadableArray array = mRecordingTestModule.getArrayCalls().get(0);
  assertNotNull(array);

  ReadableMap map = mRecordingTestModule.getMapCalls().get(0);
  assertNotNull(map);

  assertEquals(ReadableType.Number, array.getType(0));
  assertUnexpectedTypeExceptionThrown(array, 0, "int");
  assertEquals(ReadableType.Number, array.getType(1));
  assertUnexpectedTypeExceptionThrown(array, 1, "int");

  assertEquals(ReadableType.Number, map.getType("first"));
  assertUnexpectedTypeExceptionThrown(map, "first", "int");
  assertEquals(ReadableType.Number, map.getType("second"));
  assertUnexpectedTypeExceptionThrown(map, "second", "int");
}
项目:RNLearn_Project1    文件:FrescoBasedReactTextInlineImageShadowNode.java   
@ReactProp(name = "src")
public void setSource(@Nullable ReadableArray sources) {
  final String source =
    (sources == null || sources.size() == 0) ? null : sources.getMap(0).getString("uri");
  Uri uri = null;
  if (source != null) {
    try {
      uri = Uri.parse(source);
      // Verify scheme is set, so that relative uri (used by static resources) are not handled.
      if (uri.getScheme() == null) {
        uri = null;
      }
    } catch (Exception e) {
      // ignore malformed uri, then attempt to extract resource ID.
    }
    if (uri == null) {
      uri = getResourceDrawableUri(getThemedContext(), source);
    }
  }
  if (uri != mUri) {
    markUpdated();
  }
  mUri = uri;
}
项目:RNLearn_Project1    文件:ReactViewPagerManager.java   
@Override
public void receiveCommand(
    ReactViewPager 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()));
  }
}
项目:RNLearn_Project1    文件:NativeViewHierarchyManager.java   
/**
 * Simplified version of constructManageChildrenErrorMessage that only deals with adding children
 * views
 */
private static String constructSetChildrenErrorMessage(
  ViewGroup viewToManage,
  ViewGroupManager viewManager,
  ReadableArray childrenTags) {
  ViewAtIndex[] viewsToAdd = new ViewAtIndex[childrenTags.size()];
  for (int i = 0; i < childrenTags.size(); i++) {
    viewsToAdd[i] = new ViewAtIndex(childrenTags.getInt(i), i);
  }
  return constructManageChildrenErrorMessage(
    viewToManage,
    viewManager,
    null,
    viewsToAdd,
    null
  );
}
项目:RNLearn_Project1    文件:CatalystNativeJSToJavaParametersTestCase.java   
public void testArrayOutOfBoundsExceptionThrown() {
  mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnArrayWithBasicTypes();
  waitForBridgeAndUIIdle();

  List<ReadableArray> calls = mRecordingTestModule.getArrayCalls();
  assertEquals(1, calls.size());
  ReadableArray array = calls.get(0);
  assertNotNull(array);

  assertArrayOutOfBoundsExceptionThrown(array, -1, "boolean");
  assertArrayOutOfBoundsExceptionThrown(array, -1, "string");
  assertArrayOutOfBoundsExceptionThrown(array, -1, "double");
  assertArrayOutOfBoundsExceptionThrown(array, -1, "int");
  assertArrayOutOfBoundsExceptionThrown(array, -1, "map");
  assertArrayOutOfBoundsExceptionThrown(array, -1, "array");

  assertArrayOutOfBoundsExceptionThrown(array, 10, "boolean");
  assertArrayOutOfBoundsExceptionThrown(array, 10, "string");
  assertArrayOutOfBoundsExceptionThrown(array, 10, "double");
  assertArrayOutOfBoundsExceptionThrown(array, 10, "int");
  assertArrayOutOfBoundsExceptionThrown(array, 10, "map");
  assertArrayOutOfBoundsExceptionThrown(array, 10, "array");
}
项目:RNLearn_Project1    文件:CatalystNativeJSToJavaParametersTestCase.java   
private void assertArrayOutOfBoundsExceptionThrown(
    ReadableArray array,
    int index,
    String typeToAskFor) {
  boolean gotException = false;
  try {
    arrayGetByType(array, index, typeToAskFor);
  } catch (ArrayIndexOutOfBoundsException expected) {
    gotException = true;
  }

  assertTrue(gotException);
}
项目:RNLearn_Project1    文件:InterpolationAnimatedNode.java   
private static double[] fromDoubleArray(ReadableArray ary) {
  double[] res = new double[ary.size()];
  for (int i = 0; i < res.length; i++) {
    res[i] = ary.getDouble(i);
  }
  return res;
}
项目:react-native-mssql    文件:ArrayUtil.java   
public static Object[] toArray(ReadableArray readableArray) {
  Object[] array = new Object[readableArray.size()];

  for (int i = 0; i < readableArray.size(); i++) {
    ReadableType type = readableArray.getType(i);

    switch (type) {
      case Null:
        array[i] = null;
        break;
      case Boolean:
        array[i] = readableArray.getBoolean(i);
        break;
      case Number:
        array[i] = readableArray.getDouble(i);
        break;
      case String:
        array[i] = readableArray.getString(i);
        break;
      case Map:
        array[i] = MapUtil.toMap(readableArray.getMap(i));
        break;
      case Array:
        array[i] = ArrayUtil.toArray(readableArray.getArray(i));
        break;
    }
  }

  return array;
}
项目:react-native-nfc-manager    文件:JsonConvert.java   
public static JSONArray reactToJSON(ReadableArray readableArray) throws JSONException {
    JSONArray jsonArray = new JSONArray();
    for(int i=0; i < readableArray.size(); i++) {
        ReadableType valueType = readableArray.getType(i);
        switch (valueType){
            case Null:
                jsonArray.put(JSONObject.NULL);
                break;
            case Boolean:
                jsonArray.put(readableArray.getBoolean(i));
                break;
            case Number:
                try {
                    jsonArray.put(readableArray.getInt(i));
                } catch(Exception e) {
                    jsonArray.put(readableArray.getDouble(i));
                }
                break;
            case String:
                jsonArray.put(readableArray.getString(i));
                break;
            case Map:
                jsonArray.put(reactToJSON(readableArray.getMap(i)));
                break;
            case Array:
                jsonArray.put(reactToJSON(readableArray.getArray(i)));
                break;
        }
    }
    return jsonArray;
}
项目:RNLearn_Project1    文件:AdditionAnimatedNode.java   
public AdditionAnimatedNode(
    ReadableMap config,
    NativeAnimatedNodesManager nativeAnimatedNodesManager) {
  mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
  ReadableArray inputNodes = config.getArray("input");
  mInputNodes = new int[inputNodes.size()];
  for (int i = 0; i < mInputNodes.length; i++) {
    mInputNodes[i] = inputNodes.getInt(i);
  }
}
项目:RNLearn_Project1    文件:UIViewOperationQueue.java   
public ShowPopupMenuOperation(
    int tag,
    ReadableArray items,
    Callback success) {
  super(tag);
  mItems = items;
  mSuccess = success;
}
项目:RNLearn_Project1    文件:UIViewOperationQueue.java   
public void enqueueShowPopupMenu(
    int reactTag,
    ReadableArray items,
    Callback error,
    Callback success) {
  mOperations.add(new ShowPopupMenuOperation(reactTag, items, success));
}
项目:RNLearn_Project1    文件:NativeViewHierarchyManager.java   
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);
}
项目:react-native-tensorflow    文件:ArrayConverter.java   
public static long[] readableArrayToLongArray(ReadableArray readableArray) {
    long[] arr = new long[readableArray.size()];
    for (int i = 0; i < readableArray.size(); i++) {
        arr[i] = (long)readableArray.getDouble(i);
    }

    return arr;
}
项目:react-native-tensorflow    文件:ArrayConverter.java   
public static int[] readableArrayToIntArray(ReadableArray readableArray) {
    int[] arr = new int[readableArray.size()];
    for (int i = 0; i < readableArray.size(); i++) {
        arr[i] = readableArray.getInt(i);
    }

    return arr;
}
项目:RNLearn_Project1    文件:FlatUIViewOperationQueue.java   
public ViewManagerCommand(
    int reactTag,
    int command,
    @Nullable ReadableArray args) {
  mReactTag = reactTag;
  mCommand = command;
  mArgs = args;
}
项目:RNLearn_Project1    文件:UIManagerModule.java   
/**
 * Find the touch target child native view in  the supplied root view hierarchy, given a react
 * target location.
 *
 * This method is currently used only by Element Inspector DevTool.
 *
 * @param reactTag the tag of the root view to traverse
 * @param point an array containing both X and Y target location
 * @param callback will be called if with the identified child view react ID, and measurement
 *        info. If no view was found, callback will be invoked with no data.
 */
@ReactMethod
public void findSubviewIn(
    final int reactTag,
    final ReadableArray point,
    final Callback callback) {
  mUIImplementation.findSubviewIn(
    reactTag,
    Math.round(PixelUtil.toPixelFromDIP(point.getDouble(0))),
    Math.round(PixelUtil.toPixelFromDIP(point.getDouble(1))),
    callback);
}
项目:RNLearn_Project1    文件:UIManagerModule.java   
/**
 * Interface for fast tracking the initial adding of views.  Children view tags are assumed to be
 * in order
 *
 * @param viewTag the view tag of the parent view
 * @param childrenTags An array of tags to add to the parent in order
 */
@ReactMethod
public void setChildren(
  int viewTag,
  ReadableArray childrenTags) {
  if (DEBUG) {
    FLog.d(
        ReactConstants.TAG,
        "(UIManager.setChildren) tag: " + viewTag + ", children: " + childrenTags);
  }
  mUIImplementation.setChildren(viewTag, childrenTags);
}
项目:react-native-geo-fence    文件:RNGeoFenceModule.java   
/**
 * Adds a list of geofence coordinates to a list to be used for geofencing
 *
 * @param readableArray The array containing the list of geofence readableMaps to be
 *               added to geofence list
 *
 * @param geofenceRadiusInMetres geofence radius in metres
 *
 *
 * @param geofenceExpirationInMilliseconds geofence expiration time in milliseconds
 *
 */
@ReactMethod
@SuppressWarnings("unused")
public void populateGeofenceList(ReadableArray readableArray,
                                 int geofenceRadiusInMetres,
                                 int geofenceExpirationInMilliseconds) {
    if (readableArray != null) {
        for (int i = 0; i < readableArray.size(); i++) {
            ReadableMap geofence = readableArray.getMap(i);
            GlobalReadableMap.add(geofence);
            mGeofenceList.add(new Geofence.Builder()
                    // Set the request ID of the geofence. This is a string to identify this
                    // geofence.
                    .setRequestId(geofence.getString("key"))

                    // Set the circular region of this geofence.
                    .setCircularRegion(
                            geofence.getDouble("latitude"),
                            geofence.getDouble("longitude"),
                            geofenceRadiusInMetres
                    )

                    .setNotificationResponsiveness(20)

                    // Set the expiration duration of the geofence. This geofence gets automatically
                    // removed after this period of time.
                    .setExpirationDuration(geofenceExpirationInMilliseconds)

                    // Set the transition types of interest. Alerts are only generated for these transition
                    .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER |
                            Geofence.GEOFENCE_TRANSITION_EXIT)

                    // Create the geofence.
                    .build());
        }
    }
}
项目:react-native-tensorflow    文件:ArrayConverter.java   
public static ReadableArray intArrayToReadableArray(int[] arr) {
    WritableArray writableArray = new WritableNativeArray();
    for (int i : arr) {
        writableArray.pushInt(i);
    }

    return writableArray;
}
项目:RNLearn_Project1    文件:DebugComponentOwnershipModule.java   
@ReactMethod
public synchronized void receiveOwnershipHierarchy(
    int requestId,
    int tag,
    @Nullable ReadableArray owners) {
  OwnerHierarchyCallback callback = mRequestIdToCallback.get(requestId);
  if (callback == null) {
    throw new JSApplicationCausedNativeException(
        "Got receiveOwnershipHierarchy for invalid request id: " + requestId);
  }
  mRequestIdToCallback.delete(requestId);
  callback.onOwnerHierarchyLoaded(tag, owners);
}
项目:react-native-ir-manager    文件:RNIRManagerModule.java   
@ReactMethod
public void transmit(Integer carrierFrequency, ReadableArray burstsPattern, Promise promise) {
    int[] pattern = new int[burstsPattern.size()];

    for (int i = 0; i < burstsPattern.size(); i++) {
        pattern[i] = burstsPattern.getInt(i);
    }

    try {
        manager.transmit(carrierFrequency, pattern);
        promise.resolve(true);
    } catch (Exception e) {
        promise.reject(e);
    }
}
项目:RNLearn_Project1    文件:AsyncLocalStorageUtil.java   
/**
 * Build the String[] arguments needed for an SQL selection, i.e.:
 *  {a, b, c}
 * to be used in the SQL select statement: WHERE key in (?, ?, ?)
 */
/* package */ static String[] buildKeySelectionArgs(ReadableArray keys, int start, int count) {
  String[] selectionArgs = new String[count];
  for (int keyIndex = 0; keyIndex < count; keyIndex++) {
    selectionArgs[keyIndex] = keys.getString(start + keyIndex);
  }
  return selectionArgs;
}