List of usage examples for com.facebook.react.bridge WritableMap putBoolean
void putBoolean(@NonNull String key, boolean value);
From source file:com.amazonaws.reactnative.core.AWSRNClientMarshaller.java
License:Open Source License
public static WritableMap jsonToReact(final JSONObject jsonObject) throws JSONException { final WritableMap writableMap = Arguments.createMap(); final Iterator iterator = jsonObject.keys(); while (iterator.hasNext()) { final String key = (String) iterator.next(); final Object value = jsonObject.get(key); if (value instanceof Float || value instanceof Double) { writableMap.putDouble(key, jsonObject.getDouble(key)); } else if (value instanceof Number) { writableMap.putInt(key, jsonObject.getInt(key)); } else if (value instanceof String) { writableMap.putString(key, jsonObject.getString(key)); } else if (value instanceof JSONObject) { writableMap.putMap(key, jsonToReact(jsonObject.getJSONObject(key))); } else if (value instanceof JSONArray) { writableMap.putArray(key, jsonToReact(jsonObject.getJSONArray(key))); } else if (value instanceof Boolean) { writableMap.putBoolean(key, jsonObject.getBoolean(key)); } else if (value == JSONObject.NULL) { writableMap.putNull(key);//w w w.ja v a 2 s . co m } } return writableMap; }
From source file:com.auth0.lock.react.bridge.UserProfileBridge.java
License:Open Source License
private void add(UserIdentity identity, WritableArray into) { final WritableMap map = Arguments.createMap(); map.putString("userId", identity.getId()); map.putString("connection", identity.getConnection()); map.putString("provider", identity.getProvider()); map.putBoolean("social", identity.isSocial()); put("profileData", identity.getProfileInfo(), map); into.pushMap(map);//from www . j av a 2 s . co m }
From source file:com.auth0.lock.react.bridge.UserProfileBridge.java
License:Open Source License
private void put(String key, Object value, WritableMap map) { if (value instanceof String) { map.putString(key, (String) value); }// ww w . j a v a 2 s .co m if (value instanceof Integer) { map.putInt(key, (Integer) value); } if (value instanceof Boolean) { map.putBoolean(key, (Boolean) value); } if (value instanceof Double) { map.putDouble(key, (Double) value); } if (value instanceof Date) { map.putString(key, formatter.format(value)); } if (value instanceof Map) { //noinspection unchecked put(key, (Map) value, map); } if (value instanceof List) { put(key, (List) value, map); } }
From source file:com.boundlessgeo.spatialconnect.jsbridge.RNSpatialConnect.java
License:Apache License
private WritableMap writePayloadToMap(WritableMap response, Object value) { if (value instanceof Boolean) { response.putBoolean("payload", (Boolean) value); } else if (value instanceof Integer) { response.putInt("payload", (Integer) value); } else if (value instanceof String) { response.putString("payload", (String) value); } else if (value instanceof HashMap) { // if we upgrade react, we can just `writeMap` instead of having to convert it response.putMap("payload", convertHashMapToMap((Map<String, Object>) value)); }/* w w w . j a v a 2 s . com*/ return response; }
From source file:com.boundlessgeo.spatialconnect.jsbridge.RNSpatialConnect.java
License:Apache License
private WritableMap convertHashMapToMap(Map<String, Object> hashMap) { WritableMap writableMap = Arguments.createMap(); for (Map.Entry<String, Object> entry : hashMap.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (value == null) { writableMap.putNull(key);/*from w w w . j av a2s. c o m*/ } else if (value instanceof Boolean) { writableMap.putBoolean(key, (Boolean) value); } else if (value instanceof Double) { writableMap.putDouble(key, (Double) value); } else if (value instanceof Integer) { writableMap.putInt(key, (Integer) value); } else if (value instanceof Long) { writableMap.putDouble(key, (Long) value); } else if (value instanceof String) { writableMap.putString(key, (String) value); } else if (value instanceof Map) { writableMap.putMap(key, convertHashMapToMap((Map) value)); } else if (value instanceof List) { writableMap.putArray(key, convertArrayToArrayList((List) value)); } } return writableMap; }
From source file:com.boundlessgeo.spatialconnect.jsbridge.SCBridge.java
License:Apache License
private WritableMap getFormMap(SCFormConfig formConfig) { WritableMap params = Arguments.createMap(); params.putString("id", formConfig.getId()); params.putString("name", formConfig.getName()); params.putString("display_name", formConfig.getDisplayName()); params.putString("layer_name", formConfig.getLayerName()); WritableArray fields = Arguments.createArray(); // for each field, create a WriteableMap with all the SCFormField params for (SCFormField field : formConfig.getFields()) { WritableMap fieldMap = Arguments.createMap(); fieldMap.putString("id", field.getId()); fieldMap.putString("key", field.getKey()); fieldMap.putString("label", field.getLabel()); if (field.isRequired() != null) { fieldMap.putBoolean("is_required", field.isRequired()); }/*from w w w. j a va 2 s. c o m*/ if (field.getPosition() != null) { fieldMap.putInt("order", field.getPosition()); } if (field.getType() != null) { fieldMap.putString("type", field.getType()); } if (field.getInitialValue() != null) { fieldMap.putString("initial_value", String.valueOf(field.getInitialValue())); } if (field.getMaximum() != null) { fieldMap.putDouble("minimum", Double.valueOf(String.valueOf(field.getMinimum()))); } if (field.getMaximum() != null) { fieldMap.putDouble("maximum", Double.valueOf(String.valueOf(field.getMaximum()))); } if (field.isExclusiveMaximum() != null) { fieldMap.putBoolean("exclusive_maximum", field.isExclusiveMaximum()); } if (field.isExclusiveMinimum() != null) { fieldMap.putBoolean("exclusive_minimum", field.isExclusiveMinimum()); } if (field.isInteger() != null) { fieldMap.putBoolean("is_integer", field.isInteger()); } if (field.getMaximumLength() != null) { fieldMap.putInt("maximum_length", field.getMaximumLength()); } if (field.getMinimumLength() != null) { fieldMap.putInt("minimum_length", field.getMinimumLength()); } if (field.getPattern() != null) { fieldMap.putString("pattern", field.getPattern()); } fields.pushMap(fieldMap); } params.putArray("fields", fields); return params; }
From source file:com.boundlessgeo.spatialconnect.jsbridge.SCBridge.java
License:Apache License
private static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException { WritableMap map = new WritableNativeMap(); Iterator<String> iterator = jsonObject.keys(); while (iterator.hasNext()) { String key = iterator.next(); Object value = jsonObject.get(key); if (value instanceof JSONObject) { map.putMap(key, convertJsonToMap((JSONObject) value)); } else if (value instanceof JSONArray) { map.putArray(key, convertJsonToArray((JSONArray) value)); } else if (value instanceof Boolean) { map.putBoolean(key, (Boolean) value); } else if (value instanceof Integer) { map.putInt(key, (Integer) value); } else if (value instanceof Double) { map.putDouble(key, (Double) value); } else if (value instanceof String) { map.putString(key, (String) value); } else {/*from w w w . j av a2 s. c o m*/ map.putString(key, value.toString()); } } return map; }
From source file:com.dylanvann.cameraroll.CameraRollManager.java
License:Open Source License
private static void putPageInfo(Cursor photos, WritableMap response, int limit) { WritableMap pageInfo = new WritableNativeMap(); pageInfo.putBoolean("has_next_page", limit < photos.getCount()); if (limit < photos.getCount()) { photos.moveToPosition(limit - 1); pageInfo.putString("end_cursor", photos.getString(photos.getColumnIndex(FileColumns.DATE_MODIFIED))); }//from w w w . jav a2s . c o m response.putMap("page_info", pageInfo); }
From source file:com.ibatimesheet.RNJSONUtils.java
License:Apache License
public static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException { WritableMap map = new WritableNativeMap(); Iterator<String> iterator = jsonObject.keys(); while (iterator.hasNext()) { String key = iterator.next(); Object value = jsonObject.get(key); if (value instanceof JSONObject) { map.putMap(key, convertJsonToMap((JSONObject) value)); } else if (value instanceof JSONArray) { map.putArray(key, convertJsonToArray((JSONArray) value)); } else if (value instanceof Boolean) { map.putBoolean(key, (Boolean) value); } else if (value instanceof Integer) { map.putInt(key, (Integer) value); } else if (value instanceof Double) { map.putDouble(key, (Double) value); } else if (value instanceof String) { map.putString(key, (String) value); } else {/*w w w . j av a2 s .c o m*/ map.putString(key, value.toString()); } } return map; }
From source file:com.idehub.Billing.InAppBillingBridge.java
@ReactMethod public void getProductDetails(final ReadableArray productIds, final Promise promise) { if (bp != null) { try {/*from w w w . ja v a 2 s .c o m*/ ArrayList<String> productIdList = new ArrayList<>(); for (int i = 0; i < productIds.size(); i++) { productIdList.add(productIds.getString(i)); } List<SkuDetails> details = bp.getPurchaseListingDetails(productIdList); if (details != null) { WritableArray arr = Arguments.createArray(); for (SkuDetails detail : details) { if (detail != null) { WritableMap map = Arguments.createMap(); map.putString("productId", detail.productId); map.putString("title", detail.title); map.putString("description", detail.description); map.putBoolean("isSubscription", detail.isSubscription); map.putString("currency", detail.currency); map.putDouble("priceValue", detail.priceValue); map.putString("priceText", detail.priceText); arr.pushMap(map); } } promise.resolve(arr); } else { promise.reject("Details was not found."); } } catch (Exception ex) { promise.reject("Failure on getting product details: " + ex.getMessage()); } } else { promise.reject("Channel is not opened. Call open() on InAppBilling."); } }