Java Code Examples for com.facebook.react.bridge.ReadableMap.getArray()

The following are Jave code examples for showing how to use getArray() of the com.facebook.react.bridge.ReadableMap class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: react-native-webrtc   File: WebRTCModule.java   Source Code and License Vote up 6 votes
/**
 * Retreives "sourceId" constraint value.
 * @param mediaConstraints a <tt>ReadableMap</tt> which represents "GUM"
 * constraints argument
 * @return String value of "sourceId" optional "GUM" constraint or
 * <tt>null</tt> if not specified in the given map.
 */
private String getSourceIdConstraint(ReadableMap mediaConstraints) {
    if (mediaConstraints.hasKey("optional")
            && mediaConstraints.getType("optional") == ReadableType.Array) {
        ReadableArray optional = mediaConstraints.getArray("optional");

        for (int i = 0, size = optional.size(); i < size; i++) {
            if (optional.getType(i) == ReadableType.Map) {
                ReadableMap option = optional.getMap(i);

                if (option.hasKey("sourceId")
                        && option.getType("sourceId") == ReadableType.String) {
                    return option.getString("sourceId");
                }
            }
        }
    }
    return null;
}
 
Example 2
Project: RNLearn_Project1   File: CameraRollManager.java   Source Code and License Vote up 6 votes
/**
 * Get photos from {@link MediaStore.Images}, most recent first.
 *
 * @param params a map containing the following keys:
 *        <ul>
 *          <li>first (mandatory): a number representing the number of photos to fetch</li>
 *          <li>
 *            after (optional): a cursor that matches page_info[end_cursor] returned by a
 *            previous call to {@link #getPhotos}
 *          </li>
 *          <li>groupName (optional): an album name</li>
 *          <li>
 *            mimeType (optional): restrict returned images to a specific mimetype (e.g.
 *            image/jpeg)
 *          </li>
 *        </ul>
 * @param promise the Promise to be resolved when the photos are loaded; for a format of the
 *        parameters passed to this callback, see {@code getPhotosReturnChecker} in CameraRoll.js
 */
@ReactMethod
public void getPhotos(final ReadableMap params, final Promise promise) {
  int first = params.getInt("first");
  String after = params.hasKey("after") ? params.getString("after") : null;
  String groupName = params.hasKey("groupName") ? params.getString("groupName") : null;
  ReadableArray mimeTypes = params.hasKey("mimeTypes")
      ? params.getArray("mimeTypes")
      : null;
  if (params.hasKey("groupTypes")) {
    throw new JSApplicationIllegalArgumentException("groupTypes is not supported on Android");
  }

  new GetPhotosTask(
        getReactApplicationContext(),
        first,
        after,
        groupName,
        mimeTypes,
        promise)
        .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example 3
Project: RNLearn_Project1   File: CameraRollManager.java   Source Code and License Vote up 6 votes
/**
 * Get photos from {@link MediaStore.Images}, most recent first.
 *
 * @param params a map containing the following keys:
 *        <ul>
 *          <li>first (mandatory): a number representing the number of photos to fetch</li>
 *          <li>
 *            after (optional): a cursor that matches page_info[end_cursor] returned by a
 *            previous call to {@link #getPhotos}
 *          </li>
 *          <li>groupName (optional): an album name</li>
 *          <li>
 *            mimeType (optional): restrict returned images to a specific mimetype (e.g.
 *            image/jpeg)
 *          </li>
 *        </ul>
 * @param promise the Promise to be resolved when the photos are loaded; for a format of the
 *        parameters passed to this callback, see {@code getPhotosReturnChecker} in CameraRoll.js
 */
@ReactMethod
public void getPhotos(final ReadableMap params, final Promise promise) {
  int first = params.getInt("first");
  String after = params.hasKey("after") ? params.getString("after") : null;
  String groupName = params.hasKey("groupName") ? params.getString("groupName") : null;
  ReadableArray mimeTypes = params.hasKey("mimeTypes")
      ? params.getArray("mimeTypes")
      : null;
  if (params.hasKey("groupTypes")) {
    throw new JSApplicationIllegalArgumentException("groupTypes is not supported on Android");
  }

  new GetPhotosTask(
        getReactApplicationContext(),
        first,
        after,
        groupName,
        mimeTypes,
        promise)
        .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example 4
Project: react-native-webrtc   File: WebRTCModule.java   Source Code and License Vote up 5 votes
private List<PeerConnection.IceServer> createIceServers(ReadableArray iceServersArray) {
    final int size = (iceServersArray == null) ? 0 : iceServersArray.size();
    List<PeerConnection.IceServer> iceServers = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        ReadableMap iceServerMap = iceServersArray.getMap(i);
        boolean hasUsernameAndCredential = iceServerMap.hasKey("username") && iceServerMap.hasKey("credential");
        if (iceServerMap.hasKey("url")) {
            if (hasUsernameAndCredential) {
                iceServers.add(new PeerConnection.IceServer(iceServerMap.getString("url"), iceServerMap.getString("username"), iceServerMap.getString("credential")));
            } else {
                iceServers.add(new PeerConnection.IceServer(iceServerMap.getString("url")));
            }
        } else if (iceServerMap.hasKey("urls")) {
            switch (iceServerMap.getType("urls")) {
                case String:
                    if (hasUsernameAndCredential) {
                        iceServers.add(new PeerConnection.IceServer(iceServerMap.getString("urls"), iceServerMap.getString("username"), iceServerMap.getString("credential")));
                    } else {
                        iceServers.add(new PeerConnection.IceServer(iceServerMap.getString("urls")));
                    }
                    break;
                case Array:
                    ReadableArray urls = iceServerMap.getArray("urls");
                    for (int j = 0; j < urls.size(); j++) {
                        String url = urls.getString(j);
                        if (hasUsernameAndCredential) {
                            iceServers.add(new PeerConnection.IceServer(url,iceServerMap.getString("username"), iceServerMap.getString("credential")));
                        } else {
                            iceServers.add(new PeerConnection.IceServer(url));
                        }
                    }
                    break;
            }
        }
    }
    return iceServers;
}
 
Example 5
Project: react-native-webrtc   File: WebRTCModule.java   Source Code and License Vote up 5 votes
/**
 * Parses mandatory and optional "GUM" constraints described by a specific
 * <tt>ReadableMap</tt>.
 *
 * @param constraints A <tt>ReadableMap</tt> which represents a JavaScript
 * object specifying the constraints to be parsed into a
 * <tt>MediaConstraints</tt> instance.
 * @return A new <tt>MediaConstraints</tt> instance initialized with the
 * mandatory and optional constraint keys and values specified by
 * <tt>constraints</tt>.
 */
private MediaConstraints parseMediaConstraints(ReadableMap constraints) {
    MediaConstraints mediaConstraints = new MediaConstraints();

    if (constraints.hasKey("mandatory")
            && constraints.getType("mandatory") == ReadableType.Map) {
        parseConstraints(
                constraints.getMap("mandatory"),
                mediaConstraints.mandatory);
    } else {
        Log.d(TAG, "mandatory constraints are not a map");
    }

    if (constraints.hasKey("optional")
            && constraints.getType("optional") == ReadableType.Array) {
        ReadableArray optional = constraints.getArray("optional");

        for (int i = 0, size = optional.size(); i < size; i++) {
            if (optional.getType(i) == ReadableType.Map) {
                parseConstraints(
                        optional.getMap(i),
                        mediaConstraints.optional);
            }
        }
    } else {
        Log.d(TAG, "optional constraints are not an array");
    }

    return mediaConstraints;
}
 
Example 6
Project: RNLearn_Project1   File: CatalystNativeJSToJavaParametersTestCase.java   Source Code and License Vote up 5 votes
public void testMapParameterWithArrays() throws InterruptedException {
  mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnMapWithArrays();
  waitForBridgeAndUIIdle();

  List<ReadableMap> calls = mRecordingTestModule.getMapCalls();
  assertEquals(1, calls.size());
  ReadableMap map = calls.get(0);
  assertNotNull(map);

  ReadableArray arrayParameter;
  assertTrue(map.hasKey("empty"));
  arrayParameter = map.getArray("empty");
  assertNotNull(arrayParameter);
  assertEquals(0, arrayParameter.size());

  assertTrue(map.hasKey("ints"));
  assertFalse(map.isNull("ints"));
  arrayParameter = map.getArray("ints");
  assertNotNull(arrayParameter);
  assertEquals(2, arrayParameter.size());
  assertEquals(43, arrayParameter.getInt(0));
  assertEquals(44, arrayParameter.getInt(1));

  assertTrue(map.hasKey("mixed"));
  arrayParameter = map.getArray("mixed");
  assertNotNull(arrayParameter);
  assertEquals(3, arrayParameter.size());
  assertEquals(77, arrayParameter.getInt(0));
  assertEquals("string", arrayParameter.getString(1));
  ReadableArray nestedArray = arrayParameter.getArray(2);
  assertEquals(2, nestedArray.size());
}
 
Example 7
Project: RNLearn_Project1   File: DivisionAnimatedNode.java   Source Code and License Vote up 5 votes
public DivisionAnimatedNode(
    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);
  }
}
 
Example 8
Project: RNLearn_Project1   File: MultiplicationAnimatedNode.java   Source Code and License Vote up 5 votes
public MultiplicationAnimatedNode(
    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);
  }
}
 
Example 9
Project: RNLearn_Project1   File: FrameBasedAnimationDriver.java   Source Code and License Vote up 5 votes
FrameBasedAnimationDriver(ReadableMap config) {
  ReadableArray frames = config.getArray("frames");
  int numberOfFrames = frames.size();
  mFrames = new double[numberOfFrames];
  for (int i = 0; i < numberOfFrames; i++) {
    mFrames[i] = frames.getDouble(i);
  }
  mToValue = config.getDouble("toValue");
  mIterations = config.hasKey("iterations") ? config.getInt("iterations") : 1;
  mCurrentLoop = 1;
  mHasFinished = mIterations == 0;
}
 
Example 10
Project: RNLearn_Project1   File: AdditionAnimatedNode.java   Source Code and License Vote up 5 votes
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);
  }
}
 
Example 11
Project: RNLearn_Project1   File: NativeAnimatedNodesManager.java   Source Code and License Vote up 5 votes
public void addAnimatedEventToView(int viewTag, String eventName, ReadableMap eventMapping) {
  int nodeTag = eventMapping.getInt("animatedValueTag");
  AnimatedNode node = mAnimatedNodes.get(nodeTag);
  if (node == null) {
    throw new JSApplicationIllegalArgumentException("Animated node with tag " + nodeTag +
      " does not exists");
  }
  if (!(node instanceof ValueAnimatedNode)) {
    throw new JSApplicationIllegalArgumentException("Animated node connected to event should be" +
      "of type " + ValueAnimatedNode.class.getName());
  }

  ReadableArray path = eventMapping.getArray("nativeEventPath");
  List<String> pathList = new ArrayList<>(path.size());
  for (int i = 0; i < path.size(); i++) {
    pathList.add(path.getString(i));
  }

  EventAnimationDriver event = new EventAnimationDriver(pathList, (ValueAnimatedNode) node);
  String key = viewTag + eventName;
  if (mEventDrivers.containsKey(key)) {
    mEventDrivers.get(key).add(event);
  } else {
    List<EventAnimationDriver> drivers = new ArrayList<>(1);
    drivers.add(event);
    mEventDrivers.put(key, drivers);
  }
}
 
Example 12
Project: RNLearn_Project1   File: DivisionAnimatedNode.java   Source Code and License Vote up 5 votes
public DivisionAnimatedNode(
    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);
  }
}
 
Example 13
Project: RNLearn_Project1   File: CatalystNativeJSToJavaParametersTestCase.java   Source Code and License Vote up 5 votes
public void testMapParameterWithArrays() throws InterruptedException {
  mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnMapWithArrays();
  waitForBridgeAndUIIdle();

  List<ReadableMap> calls = mRecordingTestModule.getMapCalls();
  assertEquals(1, calls.size());
  ReadableMap map = calls.get(0);
  assertNotNull(map);

  ReadableArray arrayParameter;
  assertTrue(map.hasKey("empty"));
  arrayParameter = map.getArray("empty");
  assertNotNull(arrayParameter);
  assertEquals(0, arrayParameter.size());

  assertTrue(map.hasKey("ints"));
  assertFalse(map.isNull("ints"));
  arrayParameter = map.getArray("ints");
  assertNotNull(arrayParameter);
  assertEquals(2, arrayParameter.size());
  assertEquals(43, arrayParameter.getInt(0));
  assertEquals(44, arrayParameter.getInt(1));

  assertTrue(map.hasKey("mixed"));
  arrayParameter = map.getArray("mixed");
  assertNotNull(arrayParameter);
  assertEquals(3, arrayParameter.size());
  assertEquals(77, arrayParameter.getInt(0));
  assertEquals("string", arrayParameter.getString(1));
  ReadableArray nestedArray = arrayParameter.getArray(2);
  assertEquals(2, nestedArray.size());
}
 
Example 14
Project: RNLearn_Project1   File: NativeAnimatedNodesManager.java   Source Code and License Vote up 5 votes
public void addAnimatedEventToView(int viewTag, String eventName, ReadableMap eventMapping) {
  int nodeTag = eventMapping.getInt("animatedValueTag");
  AnimatedNode node = mAnimatedNodes.get(nodeTag);
  if (node == null) {
    throw new JSApplicationIllegalArgumentException("Animated node with tag " + nodeTag +
      " does not exists");
  }
  if (!(node instanceof ValueAnimatedNode)) {
    throw new JSApplicationIllegalArgumentException("Animated node connected to event should be" +
      "of type " + ValueAnimatedNode.class.getName());
  }

  ReadableArray path = eventMapping.getArray("nativeEventPath");
  List<String> pathList = new ArrayList<>(path.size());
  for (int i = 0; i < path.size(); i++) {
    pathList.add(path.getString(i));
  }

  EventAnimationDriver event = new EventAnimationDriver(pathList, (ValueAnimatedNode) node);
  String key = viewTag + eventName;
  if (mEventDrivers.containsKey(key)) {
    mEventDrivers.get(key).add(event);
  } else {
    List<EventAnimationDriver> drivers = new ArrayList<>(1);
    drivers.add(event);
    mEventDrivers.put(key, drivers);
  }
}
 
Example 15
Project: RNLearn_Project1   File: FrameBasedAnimationDriver.java   Source Code and License Vote up 5 votes
FrameBasedAnimationDriver(ReadableMap config) {
  ReadableArray frames = config.getArray("frames");
  int numberOfFrames = frames.size();
  mFrames = new double[numberOfFrames];
  for (int i = 0; i < numberOfFrames; i++) {
    mFrames[i] = frames.getDouble(i);
  }
  mToValue = config.getDouble("toValue");
  mIterations = config.hasKey("iterations") ? config.getInt("iterations") : 1;
  mCurrentLoop = 1;
  mHasFinished = mIterations == 0;
}
 
Example 16
Project: react-native-alert   File: DialogModule.java   Source Code and License Vote up 4 votes
@ReactMethod
public void showAlert(
    ReadableMap options,
    Callback errorCallback,
    Callback actionCallback) {
    System.out.println("Pilipa Alert Module showAlert");

  FragmentManagerHelper fragmentManagerHelper = getFragmentManagerHelper();
  if (fragmentManagerHelper == null) {
    errorCallback.invoke("Tried to show an alert while not attached to an Activity");
    return;
  }

  final Bundle args = new Bundle();
  if (options.hasKey(KEY_TITLE)) {
    args.putString(AlertFragment.ARG_TITLE, options.getString(KEY_TITLE));
  }
  if (options.hasKey(KEY_MESSAGE)) {
    args.putString(AlertFragment.ARG_MESSAGE, options.getString(KEY_MESSAGE));
  }
  if (options.hasKey(KEY_BUTTON_POSITIVE)) {
    args.putString(AlertFragment.ARG_BUTTON_POSITIVE, options.getString(KEY_BUTTON_POSITIVE));
  }
  if (options.hasKey(KEY_BUTTON_NEGATIVE)) {
    args.putString(AlertFragment.ARG_BUTTON_NEGATIVE, options.getString(KEY_BUTTON_NEGATIVE));
  }
  if (options.hasKey(KEY_BUTTON_NEUTRAL)) {
    args.putString(AlertFragment.ARG_BUTTON_NEUTRAL, options.getString(KEY_BUTTON_NEUTRAL));
  }
  if (options.hasKey(KEY_ITEMS)) {
    ReadableArray items = options.getArray(KEY_ITEMS);
    CharSequence[] itemsArray = new CharSequence[items.size()];
    for (int i = 0; i < items.size(); i ++) {
      itemsArray[i] = items.getString(i);
    }
    args.putCharSequenceArray(AlertFragment.ARG_ITEMS, itemsArray);
  }
  if (options.hasKey(KEY_CANCELABLE)) {
    args.putBoolean(KEY_CANCELABLE, options.getBoolean(KEY_CANCELABLE));
  }

  fragmentManagerHelper.showNewAlert(mIsInForeground, args, actionCallback);
}
 
Example 17
Project: react-native-mail-compose   File: RNMailComposeModule.java   Source Code and License Vote up 4 votes
private ReadableArray getArray(ReadableMap map, String key) {
    if (map.hasKey(key) && map.getType(key) == ReadableType.Array) {
        return map.getArray(key);
    }
    return null;
}
 
Example 18
Project: RNLearn_Project1   File: NetworkingModule.java   Source Code and License Vote up 4 votes
private @Nullable MultipartBody.Builder constructMultipartBody(
    ExecutorToken ExecutorToken,
    ReadableArray body,
    String contentType,
    int requestId) {
  RCTDeviceEventEmitter eventEmitter = getEventEmitter(ExecutorToken);
  MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
  multipartBuilder.setType(MediaType.parse(contentType));

  for (int i = 0, size = body.size(); i < size; i++) {
    ReadableMap bodyPart = body.getMap(i);

    // Determine part's content type.
    ReadableArray headersArray = bodyPart.getArray("headers");
    Headers headers = extractHeaders(headersArray, null);
    if (headers == null) {
      ResponseUtil.onRequestError(
        eventEmitter,
        requestId,
        "Missing or invalid header format for FormData part.",
        null);
      return null;
    }
    MediaType partContentType = null;
    String partContentTypeStr = headers.get(CONTENT_TYPE_HEADER_NAME);
    if (partContentTypeStr != null) {
      partContentType = MediaType.parse(partContentTypeStr);
      // Remove the content-type header because MultipartBuilder gets it explicitly as an
      // argument and doesn't expect it in the headers array.
      headers = headers.newBuilder().removeAll(CONTENT_TYPE_HEADER_NAME).build();
    }

    if (bodyPart.hasKey(REQUEST_BODY_KEY_STRING)) {
      String bodyValue = bodyPart.getString(REQUEST_BODY_KEY_STRING);
      multipartBuilder.addPart(headers, RequestBody.create(partContentType, bodyValue));
    } else if (bodyPart.hasKey(REQUEST_BODY_KEY_URI)) {
      if (partContentType == null) {
        ResponseUtil.onRequestError(
          eventEmitter,
          requestId,
          "Binary FormData part needs a content-type header.",
          null);
        return null;
      }
      String fileContentUriStr = bodyPart.getString(REQUEST_BODY_KEY_URI);
      InputStream fileInputStream =
          RequestBodyUtil.getFileInputStream(getReactApplicationContext(), fileContentUriStr);
      if (fileInputStream == null) {
        ResponseUtil.onRequestError(
          eventEmitter,
          requestId,
          "Could not retrieve file for uri " + fileContentUriStr,
          null);
        return null;
      }
      multipartBuilder.addPart(headers, RequestBodyUtil.create(partContentType, fileInputStream));
    } else {
      ResponseUtil.onRequestError(eventEmitter, requestId, "Unrecognized FormData part.", null);
    }
  }
  return multipartBuilder;
}
 
Example 19
Project: RNLearn_Project1   File: NetworkingModule.java   Source Code and License Vote up 4 votes
private @Nullable MultipartBody.Builder constructMultipartBody(
    ExecutorToken ExecutorToken,
    ReadableArray body,
    String contentType,
    int requestId) {
  RCTDeviceEventEmitter eventEmitter = getEventEmitter(ExecutorToken);
  MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
  multipartBuilder.setType(MediaType.parse(contentType));

  for (int i = 0, size = body.size(); i < size; i++) {
    ReadableMap bodyPart = body.getMap(i);

    // Determine part's content type.
    ReadableArray headersArray = bodyPart.getArray("headers");
    Headers headers = extractHeaders(headersArray, null);
    if (headers == null) {
      ResponseUtil.onRequestError(
        eventEmitter,
        requestId,
        "Missing or invalid header format for FormData part.",
        null);
      return null;
    }
    MediaType partContentType = null;
    String partContentTypeStr = headers.get(CONTENT_TYPE_HEADER_NAME);
    if (partContentTypeStr != null) {
      partContentType = MediaType.parse(partContentTypeStr);
      // Remove the content-type header because MultipartBuilder gets it explicitly as an
      // argument and doesn't expect it in the headers array.
      headers = headers.newBuilder().removeAll(CONTENT_TYPE_HEADER_NAME).build();
    }

    if (bodyPart.hasKey(REQUEST_BODY_KEY_STRING)) {
      String bodyValue = bodyPart.getString(REQUEST_BODY_KEY_STRING);
      multipartBuilder.addPart(headers, RequestBody.create(partContentType, bodyValue));
    } else if (bodyPart.hasKey(REQUEST_BODY_KEY_URI)) {
      if (partContentType == null) {
        ResponseUtil.onRequestError(
          eventEmitter,
          requestId,
          "Binary FormData part needs a content-type header.",
          null);
        return null;
      }
      String fileContentUriStr = bodyPart.getString(REQUEST_BODY_KEY_URI);
      InputStream fileInputStream =
          RequestBodyUtil.getFileInputStream(getReactApplicationContext(), fileContentUriStr);
      if (fileInputStream == null) {
        ResponseUtil.onRequestError(
          eventEmitter,
          requestId,
          "Could not retrieve file for uri " + fileContentUriStr,
          null);
        return null;
      }
      multipartBuilder.addPart(headers, RequestBodyUtil.create(partContentType, fileInputStream));
    } else {
      ResponseUtil.onRequestError(eventEmitter, requestId, "Unrecognized FormData part.", null);
    }
  }
  return multipartBuilder;
}
 
Example 20
Project: RNLearn_Project1   File: TransformHelper.java   Source Code and License Vote up 4 votes
public static void processTransform(ReadableArray transforms, double[] result) {
  double[] helperMatrix = sHelperMatrix.get();
  MatrixMathHelper.resetIdentityMatrix(result);

  for (int transformIdx = 0, size = transforms.size(); transformIdx < size; transformIdx++) {
    ReadableMap transform = transforms.getMap(transformIdx);
    String transformType = transform.keySetIterator().nextKey();

    MatrixMathHelper.resetIdentityMatrix(helperMatrix);
    if ("matrix".equals(transformType)) {
      ReadableArray matrix = transform.getArray(transformType);
      for (int i = 0; i < 16; i++) {
        helperMatrix[i] = matrix.getDouble(i);
      }
    } else if ("perspective".equals(transformType)) {
      MatrixMathHelper.applyPerspective(helperMatrix, transform.getDouble(transformType));
    } else if ("rotateX".equals(transformType)) {
      MatrixMathHelper.applyRotateX(
        helperMatrix,
        convertToRadians(transform, transformType));
    } else if ("rotateY".equals(transformType)) {
      MatrixMathHelper.applyRotateY(
        helperMatrix,
        convertToRadians(transform, transformType));
    } else if ("rotate".equals(transformType) || "rotateZ".equals(transformType)) {
      MatrixMathHelper.applyRotateZ(
        helperMatrix,
        convertToRadians(transform, transformType));
    } else if ("scale".equals(transformType)) {
      double scale = transform.getDouble(transformType);
      MatrixMathHelper.applyScaleX(helperMatrix, scale);
      MatrixMathHelper.applyScaleY(helperMatrix, scale);
    } else if ("scaleX".equals(transformType)) {
      MatrixMathHelper.applyScaleX(helperMatrix, transform.getDouble(transformType));
    } else if ("scaleY".equals(transformType)) {
      MatrixMathHelper.applyScaleY(helperMatrix, transform.getDouble(transformType));
    } else if ("translate".equals(transformType)) {
      ReadableArray value = transform.getArray(transformType);
      double x = value.getDouble(0);
      double y = value.getDouble(1);
      double z = value.size() > 2 ? value.getDouble(2) : 0d;
      MatrixMathHelper.applyTranslate3D(helperMatrix, x, y, z);
    } else if ("translateX".equals(transformType)) {
      MatrixMathHelper.applyTranslate2D(helperMatrix, transform.getDouble(transformType), 0d);
    } else if ("translateY".equals(transformType)) {
      MatrixMathHelper.applyTranslate2D(helperMatrix, 0d, transform.getDouble(transformType));
    } else if ("skewX".equals(transformType)) {
      MatrixMathHelper.applySkewX(
        helperMatrix,
        convertToRadians(transform, transformType));
    } else if ("skewY".equals(transformType)) {
      MatrixMathHelper.applySkewY(
        helperMatrix,
        convertToRadians(transform, transformType));
    } else {
      throw new JSApplicationIllegalArgumentException("Unsupported transform type: "
        + transformType);
    }

    MatrixMathHelper.multiplyInto(result, result, helperMatrix);
  }
}