当前位置: 首页>>代码示例>>Java>>正文


Java ReadableArray.getMap方法代码示例

本文整理汇总了Java中com.facebook.react.bridge.ReadableArray.getMap方法的典型用法代码示例。如果您正苦于以下问题:Java ReadableArray.getMap方法的具体用法?Java ReadableArray.getMap怎么用?Java ReadableArray.getMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.react.bridge.ReadableArray的用法示例。


在下文中一共展示了ReadableArray.getMap方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSourceIdConstraint

import com.facebook.react.bridge.ReadableArray; //导入方法依赖的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: setActions

import com.facebook.react.bridge.ReadableArray; //导入方法依赖的package包/类
public void setActions(@Nullable ReadableArray actions) {
    Menu menu = getMenu();
    menu.clear();
    mActionsHolder.clear();
    if (actions != null) {
        for (int i = 0; i < actions.size(); i++) {
            ReadableMap action = actions.getMap(i);

            MenuItem item = menu.add(Menu.NONE, Menu.NONE, i, action.getString("title"));
            setMenuItemIcon(item, action.getMap("icon"));
            if (action.getBoolean("disabled")) {
                item.setEnabled(false);
            }
        }
    }
}
 
开发者ID:timomeh,项目名称:react-native-android-bottom-navigation,代码行数:17,代码来源:RNBottomNavigation.java

示例3: setActions

import com.facebook.react.bridge.ReadableArray; //导入方法依赖的package包/类
void setActions(@Nullable ReadableArray actions) {
  Menu menu = getMenu();
  menu.clear();
  mActionsHolder.clear();
  if (actions != null) {
    for (int i = 0; i < actions.size(); i++) {
      ReadableMap action = actions.getMap(i);

      MenuItem item = menu.add(Menu.NONE, Menu.NONE, i, action.getString(PROP_ACTION_TITLE));

      if (action.hasKey(PROP_ACTION_ICON)) {
        setMenuItemIcon(item, action.getMap(PROP_ACTION_ICON));
      }

      int showAsAction = action.hasKey(PROP_ACTION_SHOW)
          ? action.getInt(PROP_ACTION_SHOW)
          : MenuItem.SHOW_AS_ACTION_NEVER;
      if (action.hasKey(PROP_ACTION_SHOW_WITH_TEXT) &&
          action.getBoolean(PROP_ACTION_SHOW_WITH_TEXT)) {
        showAsAction = showAsAction | MenuItem.SHOW_AS_ACTION_WITH_TEXT;
      }
      item.setShowAsAction(showAsAction);
    }
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:26,代码来源:ReactToolbar.java

示例4: stackTraceToString

import com.facebook.react.bridge.ReadableArray; //导入方法依赖的package包/类
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();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:21,代码来源:ExceptionsManagerModule.java

示例5: convertJsStackTrace

import com.facebook.react.bridge.ReadableArray; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:24,代码来源:StackTraceHelper.java

示例6: testArrayWithMaps

import com.facebook.react.bridge.ReadableArray; //导入方法依赖的package包/类
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"));
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:18,代码来源:CatalystNativeJSToJavaParametersTestCase.java

示例7: arrayGetByType

import com.facebook.react.bridge.ReadableArray; //导入方法依赖的package包/类
private void arrayGetByType(ReadableArray array, int index, String typeToAskFor) {
  if (typeToAskFor.equals("double")) {
    array.getDouble(index);
  } else if (typeToAskFor.equals("int")) {
    array.getInt(index);
  } else if (typeToAskFor.equals("string")) {
    array.getString(index);
  } else if (typeToAskFor.equals("array")) {
    array.getArray(index);
  } else if (typeToAskFor.equals("map")) {
    array.getMap(index);
  } else if (typeToAskFor.equals("boolean")) {
    array.getBoolean(index);
  } else {
    throw new RuntimeException("Unknown type: " + typeToAskFor);
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:18,代码来源:CatalystNativeJSToJavaParametersTestCase.java

示例8: createIceServers

import com.facebook.react.bridge.ReadableArray; //导入方法依赖的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

示例9: addAttachments

import com.facebook.react.bridge.ReadableArray; //导入方法依赖的package包/类
private void addAttachments(Intent intent, ReadableArray attachments) {
    if (attachments == null) return;

    ArrayList<Uri> uris = new ArrayList<>();
    for (int i = 0; i < attachments.size(); i++) {
        if (attachments.getType(i) == ReadableType.Map) {
            ReadableMap attachment = attachments.getMap(i);
            if (attachment != null) {
                byte[] blob = getBlob(attachment, "data");
                String text = getString(attachment, "text");
                // String mimeType = getString(attachment, "mimeType");
                String filename = getString(attachment, "filename");
                if (filename == null) {
                    filename = UUID.randomUUID().toString();
                }
                String ext = getString(attachment, "ext");

                File tempFile = createTempFile(filename, ext);

                if (blob != null) {
                    tempFile = writeBlob(tempFile, blob);
                } else if (text != null) {
                    tempFile = writeText(tempFile, text);
                }

                if (tempFile != null) {
                    uris.add(Uri.fromFile(tempFile));
                }
            }
        }
    }

    if (uris.size() > 0) {
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    }
}
 
开发者ID:joonhocho,项目名称:react-native-mail-compose,代码行数:37,代码来源:RNMailComposeModule.java

示例10: setItems

import com.facebook.react.bridge.ReadableArray; //导入方法依赖的package包/类
@ReactProp(name = "items")
public void setItems(ReactPicker view, @Nullable ReadableArray items) {
  if (items != null) {
    ReadableMap[] data = new ReadableMap[items.size()];
    for (int i = 0; i < items.size(); i++) {
      data[i] = items.getMap(i);
    }
    ReactPickerAdapter adapter = new ReactPickerAdapter(view.getContext(), data);
    adapter.setPrimaryTextColor(view.getPrimaryColor());
    view.setAdapter(adapter);
  } else {
    view.setAdapter(null);
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:15,代码来源:ReactPickerManager.java

示例11: populateGeofenceList

import com.facebook.react.bridge.ReadableArray; //导入方法依赖的package包/类
/**
 * 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());
        }
    }
}
 
开发者ID:toystars,项目名称:react-native-geo-fence,代码行数:49,代码来源:RNGeoFenceModule.java

示例12: constructMultipartBody

import com.facebook.react.bridge.ReadableArray; //导入方法依赖的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

示例13: processTransform

import com.facebook.react.bridge.ReadableArray; //导入方法依赖的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.ReadableArray.getMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。