當前位置: 首頁>>代碼示例>>Java>>正文


Java ReadableMap.getArray方法代碼示例

本文整理匯總了Java中com.facebook.react.bridge.ReadableMap.getArray方法的典型用法代碼示例。如果您正苦於以下問題:Java ReadableMap.getArray方法的具體用法?Java ReadableMap.getArray怎麽用?Java ReadableMap.getArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.facebook.react.bridge.ReadableMap的用法示例。


在下文中一共展示了ReadableMap.getArray方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getSourceIdConstraint

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:angellsl10,項目名稱:react-native-webrtc,代碼行數:26,代碼來源:WebRTCModule.java

示例2: getPhotos

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:41,代碼來源:CameraRollManager.java

示例3: createIceServers

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
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;
}
 
開發者ID:angellsl10,項目名稱:react-native-webrtc,代碼行數:38,代碼來源:WebRTCModule.java

示例4: parseMediaConstraints

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:angellsl10,項目名稱:react-native-webrtc,代碼行數:41,代碼來源:WebRTCModule.java

示例5: testMapParameterWithArrays

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
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());
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:33,代碼來源:CatalystNativeJSToJavaParametersTestCase.java

示例6: DivisionAnimatedNode

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
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);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:11,代碼來源:DivisionAnimatedNode.java

示例7: MultiplicationAnimatedNode

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
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);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:11,代碼來源:MultiplicationAnimatedNode.java

示例8: FrameBasedAnimationDriver

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
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;
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:13,代碼來源:FrameBasedAnimationDriver.java

示例9: AdditionAnimatedNode

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
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);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:11,代碼來源:AdditionAnimatedNode.java

示例10: addAnimatedEventToView

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
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);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:29,代碼來源:NativeAnimatedNodesManager.java

示例11: showAlert

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
@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);
}
 
開發者ID:pilipa-cn,項目名稱:react-native-alert,代碼行數:44,代碼來源:DialogModule.java

示例12: getArray

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
private ReadableArray getArray(ReadableMap map, String key) {
    if (map.hasKey(key) && map.getType(key) == ReadableType.Array) {
        return map.getArray(key);
    }
    return null;
}
 
開發者ID:joonhocho,項目名稱:react-native-mail-compose,代碼行數:7,代碼來源:RNMailComposeModule.java

示例13: constructMultipartBody

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
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;
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:63,代碼來源:NetworkingModule.java

示例14: processTransform

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
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);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:63,代碼來源:TransformHelper.java


注:本文中的com.facebook.react.bridge.ReadableMap.getArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。