本文整理汇总了Java中com.facebook.react.bridge.ReadableMapKeySetIterator类的典型用法代码示例。如果您正苦于以下问题:Java ReadableMapKeySetIterator类的具体用法?Java ReadableMapKeySetIterator怎么用?Java ReadableMapKeySetIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReadableMapKeySetIterator类属于com.facebook.react.bridge包,在下文中一共展示了ReadableMapKeySetIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMapIterateOverNestedMaps
import com.facebook.react.bridge.ReadableMapKeySetIterator; //导入依赖的package包/类
public void testMapIterateOverNestedMaps() {
mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnNestedMap();
waitForBridgeAndUIIdle();
List<ReadableMap> calls = mRecordingTestModule.getMapCalls();
assertEquals(1, calls.size());
ReadableNativeMap map = (ReadableNativeMap) calls.get(0);
assertNotNull(map);
ReadableMapKeySetIterator firstLevelIterator = map.keySetIterator();
String firstLevelKey = firstLevelIterator.nextKey();
assertEquals(firstLevelKey, "weHaveToGoDeeper");
ReadableNativeMap secondMap = map.getMap("weHaveToGoDeeper");
ReadableMapKeySetIterator secondLevelIterator = secondMap.keySetIterator();
String secondLevelKey = secondLevelIterator.nextKey();
assertEquals(secondLevelKey, "inception");
assertTrue(secondMap.getBoolean(secondLevelKey));
}
示例2: createIntent
import com.facebook.react.bridge.ReadableMapKeySetIterator; //导入依赖的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
示例3: readableMapToHashMap
import com.facebook.react.bridge.ReadableMapKeySetIterator; //导入依赖的package包/类
public static HashMap<String, Object> readableMapToHashMap(ReadableMap readableMap) {
if (readableMap == null) {
return null;
}
HashMap map = new HashMap<String, Object>();
ReadableMapKeySetIterator keySetIterator = readableMap.keySetIterator();
while (keySetIterator.hasNextKey()) {
String key = keySetIterator.nextKey();
ReadableType type = readableMap.getType(key);
switch(type) {
case String:
map.put(key, readableMap.getString(key));
break;
case Map:
HashMap<String, Object> attributes = new RCTConvert().readableMapToHashMap(readableMap.getMap(key));
map.put(key, attributes);
break;
default:
// do nothing
}
}
return map;
}
示例4: isLayoutOnlyAndCollapsable
import com.facebook.react.bridge.ReadableMapKeySetIterator; //导入依赖的package包/类
private static boolean isLayoutOnlyAndCollapsable(@Nullable ReactStylesDiffMap props) {
if (props == null) {
return true;
}
if (props.hasKey(ViewProps.COLLAPSABLE) && !props.getBoolean(ViewProps.COLLAPSABLE, true)) {
return false;
}
ReadableMapKeySetIterator keyIterator = props.mBackingMap.keySetIterator();
while (keyIterator.hasNextKey()) {
if (!ViewProps.isLayoutOnly(props.mBackingMap, keyIterator.nextKey())) {
return false;
}
}
return true;
}
示例5: testMapIterateOverMapWithBasicTypes
import com.facebook.react.bridge.ReadableMapKeySetIterator; //导入依赖的package包/类
public void testMapIterateOverMapWithBasicTypes() {
mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnMapWithBasicTypes();
waitForBridgeAndUIIdle();
List<ReadableMap> calls = mRecordingTestModule.getMapCalls();
assertEquals(1, calls.size());
ReadableNativeMap map = (ReadableNativeMap) calls.get(0);
assertNotNull(map);
ReadableMapKeySetIterator mapIterator = map.keySetIterator();
Set<String> keys = new HashSet<String>();
while (mapIterator.hasNextKey()) {
keys.add(mapIterator.nextKey());
}
Set<String> expectedKeys = new HashSet<String>(
Arrays.asList("stringKey", "doubleKey", "intKey", "booleanKey", "nullKey"));
assertEquals(keys, expectedKeys);
}
示例6: isLayoutOnlyAndCollapsable
import com.facebook.react.bridge.ReadableMapKeySetIterator; //导入依赖的package包/类
private static boolean isLayoutOnlyAndCollapsable(@Nullable ReactStylesDiffMap props) {
if (props == null) {
return true;
}
if (props.hasKey(ViewProps.COLLAPSABLE) && !props.getBoolean(ViewProps.COLLAPSABLE, true)) {
return false;
}
ReadableMapKeySetIterator keyIterator = props.mBackingMap.keySetIterator();
while (keyIterator.hasNextKey()) {
if (!ViewProps.isLayoutOnly(keyIterator.nextKey())) {
return false;
}
}
return true;
}
示例7: toMap
import com.facebook.react.bridge.ReadableMapKeySetIterator; //导入依赖的package包/类
private static Map<String, String> toMap(@Nullable ReadableMap readableMap) {
if (readableMap == null) {
return null;
}
ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
if (!iterator.hasNextKey()) {
return null;
}
Map<String, String> result = new HashMap<>();
while (iterator.hasNextKey()) {
String key = iterator.nextKey();
result.put(key, readableMap.getString(key));
}
return result;
}
示例8: createJsonObject
import com.facebook.react.bridge.ReadableMapKeySetIterator; //导入依赖的package包/类
@NonNull
private JSONObject createJsonObject(final ReadableMap properties) throws JSONException {
JSONObject jsonPayload = new JSONObject();
for (final ReadableMapKeySetIterator iterator = properties.keySetIterator(); iterator.hasNextKey();) {
final String key = iterator.nextKey();
final ReadableType type = properties.getType(key);
switch (type) {
case String: jsonPayload.put(key, properties.getString(key)); break;
case Array: jsonPayload.put(key, properties.getArray(key)); break;
case Boolean: jsonPayload.put(key, properties.getBoolean(key)); break;
case Number: jsonPayload.put(key, properties.getDouble(key)); break;
case Map: jsonPayload.put(key, createJsonObject(properties.getMap(key))); break;
}
jsonPayload.put(key, type);
}
return jsonPayload;
}
示例9: addParametersToRequest
import com.facebook.react.bridge.ReadableMapKeySetIterator; //导入依赖的package包/类
static private OAuthRequest addParametersToRequest(
OAuthRequest request,
final String access_token,
@Nullable final ReadableMap params
) {
if (params != null && params.hasKey("params")) {
ReadableMapKeySetIterator iterator = params.keySetIterator();
while (iterator.hasNextKey()) {
String key = iterator.nextKey();
ReadableType readableType = params.getType(key);
switch(readableType) {
case String:
String val = params.getString(key);
// String escapedVal = Uri.encode(val);
if (val.equals("access_token")) {
val = access_token;
}
request.addParameter(key, val);
break;
default:
throw new IllegalArgumentException("Could not read object with key: " + key);
}
}
}
return request;
}
示例10: getUserProperties
import com.facebook.react.bridge.ReadableMapKeySetIterator; //导入依赖的package包/类
private Map<String, Object> getUserProperties(ReadableMap properties) {
ReadableMapKeySetIterator iterator = properties.keySetIterator();
Map<String, Object> userProperties = new HashMap<>();
while (iterator.hasNextKey()) {
String key = iterator.nextKey();
ReadableType type = properties.getType(key);
if (type == ReadableType.Boolean) {
userProperties.put(key, properties.getBoolean(key));
} else if (type == ReadableType.Number) {
userProperties.put(key, properties.getDouble(key));
} else if (type == ReadableType.String) {
userProperties.put(key, properties.getString(key));
}
}
return userProperties;
}
示例11: parseConstraints
import com.facebook.react.bridge.ReadableMapKeySetIterator; //导入依赖的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));
}
}
示例12: toJSONObject
import com.facebook.react.bridge.ReadableMapKeySetIterator; //导入依赖的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;
}
示例13: toMap
import com.facebook.react.bridge.ReadableMapKeySetIterator; //导入依赖的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;
}
示例14: reactToJSON
import com.facebook.react.bridge.ReadableMapKeySetIterator; //导入依赖的package包/类
public static JSONObject reactToJSON(ReadableMap readableMap) throws JSONException {
JSONObject jsonObject = new JSONObject();
ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
while(iterator.hasNextKey()){
String key = iterator.nextKey();
ReadableType valueType = readableMap.getType(key);
switch (valueType){
case Null:
jsonObject.put(key,JSONObject.NULL);
break;
case Boolean:
jsonObject.put(key, readableMap.getBoolean(key));
break;
case Number:
try {
jsonObject.put(key, readableMap.getInt(key));
} catch(Exception e) {
jsonObject.put(key, readableMap.getDouble(key));
}
break;
case String:
jsonObject.put(key, readableMap.getString(key));
break;
case Map:
jsonObject.put(key, reactToJSON(readableMap.getMap(key)));
break;
case Array:
jsonObject.put(key, reactToJSON(readableMap.getArray(key)));
break;
}
}
return jsonObject;
}
示例15: createRequest
import com.facebook.react.bridge.ReadableMapKeySetIterator; //导入依赖的package包/类
public DownloadManager.Request createRequest(String url, ReadableMap headers, ReadableMap requestConfig) {
String downloadTitle = requestConfig.getString("downloadTitle");
String downloadDescription = requestConfig.getString("downloadTitle");
String saveAsName = requestConfig.getString("saveAsName");
Boolean allowedInRoaming = requestConfig.getBoolean("allowedInRoaming");
Boolean allowedInMetered = requestConfig.getBoolean("allowedInMetered");
Boolean showInDownloads = requestConfig.getBoolean("showInDownloads");
Uri downloadUri = Uri.parse(url);
DownloadManager.Request request = new DownloadManager.Request(downloadUri);
ReadableMapKeySetIterator iterator = headers.keySetIterator();
while (iterator.hasNextKey()) {
String key = iterator.nextKey();
request.addRequestHeader(key, headers.getString(key));
}
request.setTitle(downloadTitle);
request.setDescription(downloadDescription);
request.setDestinationInExternalFilesDir(context, Environment.DIRECTORY_DOWNLOADS, saveAsName);
request.setAllowedOverRoaming(allowedInRoaming);
request.setAllowedOverMetered(allowedInMetered);
request.setVisibleInDownloadsUi(showInDownloads);
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
return request;
}