本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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());
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}