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


Java ReadableMap.keySetIterator方法代碼示例

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


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

示例1: createIntent

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
private Intent createIntent(String action, ReadableMap extra) {
  final Intent intent = new Intent(action);
  for (
    ReadableMapKeySetIterator it = extra.keySetIterator();
    it.hasNextKey();
  ) {
    String key = it.nextKey();
    ReadableType type = extra.getType(key);
    switch(type) {
      case Null:
        break;
      case Boolean:
        intent.putExtra(key, extra.getBoolean(key));
        break;
      case Number:
        intent.putExtra(key, extra.getInt(key));
        break;
      case String:
        intent.putExtra(key, extra.getString(key));
        break;
      default:
        throw new IllegalArgumentException("Unsupported type " + type);
    }
  }
  return intent;
}
 
開發者ID:de-code,項目名稱:react-native-android-speech-recognizer,代碼行數:27,代碼來源:RNAndroidSpeechRecognizerModule.java

示例2: toMap

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
 * toMap converts a {@link ReadableMap} into a HashMap.
 *
 * @param readableMap The ReadableMap to be converted.
 * @return A HashMap containing the data that was in the ReadableMap.
 */
public static Map<String, Object> toMap(@Nullable ReadableMap readableMap) {
    if (readableMap == null) {
        return null;
    }

    com.facebook.react.bridge.ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
    if (!iterator.hasNextKey()) {
        return null;
    }

    Map<String, Object> result = new HashMap<>();
    while (iterator.hasNextKey()) {
        String key = iterator.nextKey();
        result.put(key, toObject(readableMap, key));
    }

    return result;
}
 
開發者ID:hudl,項目名稱:react-native-android-fragment,代碼行數:25,代碼來源:ReactUtil.java

示例3: parseConstraints

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
 * Parses a constraint set specified in the form of a JavaScript object into
 * a specific <tt>List</tt> of <tt>MediaConstraints.KeyValuePair</tt>s.
 *
 * @param src The constraint set in the form of a JavaScript object to
 * parse.
 * @param dst The <tt>List</tt> of <tt>MediaConstraints.KeyValuePair</tt>s
 * into which the specified <tt>src</tt> is to be parsed.
 */
private void parseConstraints(
        ReadableMap src,
        List<MediaConstraints.KeyValuePair> dst) {
    ReadableMapKeySetIterator keyIterator = src.keySetIterator();

    while (keyIterator.hasNextKey()) {
        String key = keyIterator.nextKey();
        String value = ReactBridgeUtil.getMapStrValue(src, key);

        dst.add(new MediaConstraints.KeyValuePair(key, value));
    }
}
 
開發者ID:angellsl10,項目名稱:react-native-webrtc,代碼行數:22,代碼來源:WebRTCModule.java

示例4: toJSONObject

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
public static JSONObject toJSONObject(ReadableMap readableMap) throws JSONException {
  JSONObject jsonObject = new JSONObject();

  ReadableMapKeySetIterator iterator = readableMap.keySetIterator();

  while (iterator.hasNextKey()) {
    String key = iterator.nextKey();
    ReadableType type = readableMap.getType(key);

    switch (type) {
      case Null:
        jsonObject.put(key, null);
        break;
      case Boolean:
        jsonObject.put(key, readableMap.getBoolean(key));
        break;
      case Number:
        jsonObject.put(key, readableMap.getDouble(key));
        break;
      case String:
        jsonObject.put(key, readableMap.getString(key));
        break;
      case Map:
        jsonObject.put(key, MapUtil.toJSONObject(readableMap.getMap(key)));
        break;
      case Array:
        jsonObject.put(key, ArrayUtil.toJSONArray(readableMap.getArray(key)));
        break;
    }
  }

  return jsonObject;
}
 
開發者ID:davidstoneham,項目名稱:react-native-mssql,代碼行數:34,代碼來源:MapUtil.java

示例5: convertMapToJson

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
private static JSONObject convertMapToJson(ReadableMap readableMap) throws JSONException {
  JSONObject object = new JSONObject();
  ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
  while (iterator.hasNextKey()) {
    String key = iterator.nextKey();
    switch (readableMap.getType(key)) {
      case Null:
        object.put(key, JSONObject.NULL);
        break;
      case Boolean:
        object.put(key, readableMap.getBoolean(key));
        break;
      case Number:
        object.put(key, readableMap.getDouble(key));
        break;
      case String:
        object.put(key, readableMap.getString(key));
        break;
      case Map:
        object.put(key, convertMapToJson(readableMap.getMap(key)));
        break;
      case Array:
        object.put(key, convertArrayToJson(readableMap.getArray(key)));
        break;
    }
  }
  return object;
}
 
開發者ID:humaniq,項目名稱:react-native-android-library-humaniq-api,代碼行數:29,代碼來源:ModelConverterUtils.java

示例6: updateProps

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
public static <T extends ViewManager, V extends View> void updateProps(
    T manager,
    V v,
    ReactStylesDiffMap props) {
  ViewManagerSetter<T, V> setter = findManagerSetter(manager.getClass());
  ReadableMap propMap = props.mBackingMap;
  ReadableMapKeySetIterator iterator = propMap.keySetIterator();
  while (iterator.hasNextKey()) {
    String key = iterator.nextKey();
    setter.setProperty(manager, v, key, props);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:13,代碼來源:ViewManagerPropertyUpdater.java

示例7: PropsAnimatedNode

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
PropsAnimatedNode(ReadableMap config, NativeAnimatedNodesManager nativeAnimatedNodesManager) {
  ReadableMap props = config.getMap("props");
  ReadableMapKeySetIterator iter = props.keySetIterator();
  mPropMapping = new HashMap<>();
  while (iter.hasNextKey()) {
    String propKey = iter.nextKey();
    int nodeIndex = props.getInt(propKey);
    mPropMapping.put(propKey, nodeIndex);
  }
  mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:12,代碼來源:PropsAnimatedNode.java

示例8: toJSONObject

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
public static JSONObject toJSONObject(ReadableMap readableMap) throws JSONException {
    JSONObject jsonObject = new JSONObject();

    ReadableMapKeySetIterator iterator = readableMap.keySetIterator();

    while (iterator.hasNextKey()) {
        String key = iterator.nextKey();
        ReadableType type = readableMap.getType(key);

        switch (type) {
            case Null:
                jsonObject.put(key, null);
                break;
            case Boolean:
                jsonObject.put(key, readableMap.getBoolean(key));
                break;
            case Number:
                jsonObject.put(key, readableMap.getDouble(key));
                break;
            case String:
                jsonObject.put(key, readableMap.getString(key));
                break;
            case Map:
                jsonObject.put(key, MapUtil.toJSONObject(readableMap.getMap(key)));
                break;
            case Array:
                jsonObject.put(key, ArrayUtil.toJSONArray(readableMap.getArray(key)));
                break;
        }
    }

    return jsonObject;
}
 
開發者ID:dangerfarms,項目名稱:react-native-batch,代碼行數:34,代碼來源:MapUtil.java

示例9: toMap

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
public static Map<String, Object> toMap(ReadableMap readableMap) {
    Map<String, Object> map = new HashMap<>();
    ReadableMapKeySetIterator iterator = readableMap.keySetIterator();

    while (iterator.hasNextKey()) {
        String key = iterator.nextKey();
        ReadableType type = readableMap.getType(key);

        switch (type) {
            case Null:
                map.put(key, null);
                break;
            case Boolean:
                map.put(key, readableMap.getBoolean(key));
                break;
            case Number:
                map.put(key, readableMap.getDouble(key));
                break;
            case String:
                map.put(key, readableMap.getString(key));
                break;
            case Map:
                map.put(key, MapUtil.toMap(readableMap.getMap(key)));
                break;
            case Array:
                map.put(key, ArrayUtil.toArray(readableMap.getArray(key)));
                break;
        }
    }

    return map;
}
 
開發者ID:dangerfarms,項目名稱:react-native-batch,代碼行數:33,代碼來源:MapUtil.java

示例10: getQueryKeys

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
private List<String> getQueryKeys(ReadableMap query) {
    List<String> keys = new ArrayList<>();
    ReadableMapKeySetIterator iterator = query.keySetIterator();
    while(iterator.hasNextKey()) {
        keys.add(iterator.nextKey());
    }
    return keys;
}
 
開發者ID:reneweb,項目名稱:rnrecord,代碼行數:9,代碼來源:FindCommand.java

示例11: getHeaders

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
private Map<String, String> getHeaders(ReadableMap readableMap) {
  if (readableMap == null) {
      return null;
  }
  ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
  Map<String, String> map = new HashMap<>();
  while (iterator.hasNextKey()) {
    String key = iterator.nextKey();
    String value = readableMap.getString(key);
    map.put(key, value);
  }
  return map;
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:14,代碼來源:ReactOkHttpNetworkFetcher.java

示例12: convertMapToJson

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
public static JSONObject convertMapToJson(ReadableMap readableMap) throws JSONException {
    JSONObject object = new JSONObject();
    ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
    while (iterator.hasNextKey()) {
        String key = iterator.nextKey();
        switch (readableMap.getType(key)) {
            case Null:
                object.put(key, JSONObject.NULL);
                break;
            case Boolean:
                object.put(key, readableMap.getBoolean(key));
                break;
            case Number:
                object.put(key, readableMap.getDouble(key));
                break;
            case String:
                object.put(key, readableMap.getString(key));
                break;
            case Map:
                object.put(key, convertMapToJson(readableMap.getMap(key)));
                break;
            case Array:
                object.put(key, convertArrayToJson(readableMap.getArray(key)));
                break;
        }
    }
    return object;
}
 
開發者ID:salathegroup,項目名稱:react-native-scandit,代碼行數:29,代碼來源:ReactBridgeHelpers.java

示例13: setSource

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
@ReactProp(name = "source")
public void setSource(WebView view, @Nullable ReadableMap source) {
  if (source != null) {
    if (source.hasKey("html")) {
      String html = source.getString("html");
      if (source.hasKey("baseUrl")) {
        view.loadDataWithBaseURL(
            source.getString("baseUrl"), html, HTML_MIME_TYPE, HTML_ENCODING, null);
      } else {
        view.loadData(html, HTML_MIME_TYPE, HTML_ENCODING);
      }
      return;
    }
    if (source.hasKey("uri")) {
      String url = source.getString("uri");
      String previousUrl = view.getUrl();
      if (previousUrl != null && previousUrl.equals(url)) {
        return;
      }
      if (source.hasKey("method")) {
        String method = source.getString("method");
        if (method.equals(HTTP_METHOD_POST)) {
          byte[] postData = null;
          if (source.hasKey("body")) {
            String body = source.getString("body");
            try {
              postData = body.getBytes("UTF-8");
            } catch (UnsupportedEncodingException e) {
              postData = body.getBytes();
            }
          }
          if (postData == null) {
            postData = new byte[0];
          }
          view.postUrl(url, postData);
          return;
        }
      }
      HashMap<String, String> headerMap = new HashMap<>();
      if (source.hasKey("headers")) {
        ReadableMap headers = source.getMap("headers");
        ReadableMapKeySetIterator iter = headers.keySetIterator();
        while (iter.hasNextKey()) {
          String key = iter.nextKey();
          if ("user-agent".equals(key.toLowerCase(Locale.ENGLISH))) {
            if (view.getSettings() != null) {
              view.getSettings().setUserAgentString(headers.getString(key));
            }
          } else {
            headerMap.put(key, headers.getString(key));
          }
        }
      }
      view.loadUrl(url, headerMap);
      return;
    }
  }
  view.loadUrl(BLANK_URL);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:60,代碼來源:ReactWebViewManager.java

示例14: readableMapToJson

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
public static JSONObject readableMapToJson(ReadableMap readableMap) {
    JSONObject jsonObject = new JSONObject();

    if (readableMap == null) {
        return null;
    }

    ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
    if (!iterator.hasNextKey()) {
        return null;
    }

    while (iterator.hasNextKey()) {
        String key = iterator.nextKey();
        ReadableType readableType = readableMap.getType(key);

        try {
            switch (readableType) {
                case Null:
                    jsonObject.put(key, null);
                    break;
                case Boolean:
                    jsonObject.put(key, readableMap.getBoolean(key));
                    break;
                case Number:
                    // Can be int or double.
                    jsonObject.put(key, readableMap.getInt(key));
                    break;
                case String:
                    jsonObject.put(key, readableMap.getString(key));
                    break;
                case Map:
                    jsonObject.put(key, readableMapToJson(readableMap.getMap(key)));
                    break;
                case Array:
                    jsonObject.put(key, readableMap.getArray(key));
                default:
                    // Do nothing and fail silently
            }
        } catch (JSONException ex) {
            // Do nothing and fail silently
        }
    }

    return jsonObject;
}
 
開發者ID:2534290808,項目名稱:react-native-pili-live,代碼行數:47,代碼來源:Jsons.java

示例15: matches

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
 * User to find notifications:
 * <p>
 * https://github.com/facebook/react-native/blob/master/Libraries/PushNotificationIOS/RCTPushNotificationManager.m#L294
 *
 * @param userInfo map of fields to match
 * @return true all fields in userInfo object match, false otherwise
 */
public boolean matches(ReadableMap userInfo) {
    Bundle bundle = toBundle();

    ReadableMapKeySetIterator iterator = userInfo.keySetIterator();
    while (iterator.hasNextKey()) {
        String key = iterator.nextKey();

        if (!bundle.containsKey(key))
            return false;

        switch (userInfo.getType(key)) {
            case Null: {
                if (bundle.get(key) != null)
                    return false;
                break;
            }
            case Boolean: {
                if (userInfo.getBoolean(key) != bundle.getBoolean(key))
                    return false;
                break;
            }
            case Number: {
                if ((userInfo.getDouble(key) != bundle.getDouble(key)) && (userInfo.getInt(key) != bundle.getInt(key)))
                    return false;
                break;
            }
            case String: {
                if (!userInfo.getString(key).equals(bundle.getString(key)))
                    return false;
                break;
            }
            case Map:
                return false;//there are no maps in the bundle
            case Array:
                return false;//there are no arrays in the bundle
        }
    }

    return true;
}
 
開發者ID:zzzkk2009,項目名稱:react-native-leancloud-sdk,代碼行數:49,代碼來源:RNPushNotificationAttributes.java


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