Java Code Examples for com.facebook.react.bridge.ReadableMap#getString()
The following examples show how to use
com.facebook.react.bridge.ReadableMap#getString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RNDocViewerModule.java From react-native-doc-viewer with MIT License | 6 votes |
@ReactMethod public void openDoc(ReadableArray args, Callback callback) { final ReadableMap arg_object = args.getMap(0); try { if (arg_object.getString("url") != null && arg_object.getString("fileName") != null) { // parameter parsing final String url = arg_object.getString("url"); final String fileName =arg_object.getString("fileName"); final String fileType =arg_object.getString("fileType"); final Boolean cache =arg_object.getBoolean("cache"); final byte[] bytesData = new byte[0]; // Begin the Download Task new FileDownloaderAsyncTask(callback, url, cache, fileName, fileType, bytesData).execute(); }else{ callback.invoke(false); } } catch (Exception e) { callback.invoke(e.getMessage()); } }
Example 2
Source File: NativeAnimatedNodesManager.java From react-native-GPay with MIT License | 5 votes |
public void createAnimatedNode(int tag, ReadableMap config) { if (mAnimatedNodes.get(tag) != null) { throw new JSApplicationIllegalArgumentException("Animated node with tag " + tag + " already exists"); } String type = config.getString("type"); final AnimatedNode node; if ("style".equals(type)) { node = new StyleAnimatedNode(config, this); } else if ("value".equals(type)) { node = new ValueAnimatedNode(config); } else if ("props".equals(type)) { node = new PropsAnimatedNode(config, this, mUIImplementation); } else if ("interpolation".equals(type)) { node = new InterpolationAnimatedNode(config); } else if ("addition".equals(type)) { node = new AdditionAnimatedNode(config, this); } else if ("subtraction".equals(type)) { node = new SubtractionAnimatedNode(config, this); } else if ("division".equals(type)) { node = new DivisionAnimatedNode(config, this); } else if ("multiplication".equals(type)) { node = new MultiplicationAnimatedNode(config, this); } else if ("modulus".equals(type)) { node = new ModulusAnimatedNode(config, this); } else if ("diffclamp".equals(type)) { node = new DiffClampAnimatedNode(config, this); } else if ("transform".equals(type)) { node = new TransformAnimatedNode(config, this); } else if ("tracking".equals(type)) { node = new TrackingAnimatedNode(config, this); } else { throw new JSApplicationIllegalArgumentException("Unsupported node type: " + type); } node.mTag = tag; mAnimatedNodes.put(tag, node); mUpdatedNodes.put(tag, node); }
Example 3
Source File: KeychainModule.java From react-native-keychain with MIT License | 5 votes |
/** Get service value from options. */ @NonNull private static String getServiceOrDefault(@Nullable final ReadableMap options) { String service = null; if (null != options && options.hasKey(Maps.SERVICE)) { service = options.getString(Maps.SERVICE); } return getAliasOrDefault(service); }
Example 4
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
/** * 群角色管理 * @param params * @param callback */ @ReactMethod public void setGroupAdmin(ReadableMap params, Callback callback){ Logger.i("setGroupAdmin:" + params.toString()); String groupId = params.getString("groupId"); String xmppid = params.getString("xmppid"); String name = params.getString("name"); boolean isAdmin = params.getBoolean("isAdmin"); ConnectionUtil.getInstance().setGroupAdmin(groupId,xmppid,name,isAdmin); }
Example 5
Source File: BridgeUtils.java From react-native-mp-android-chart with MIT License | 5 votes |
/** * fontStyle: NORMAL = 0, BOLD = 1, ITALIC = 2, BOLD_ITALIC = 3 */ public static Typeface parseTypeface(Context context, ReadableMap propMap, String styleKey, String familyKey) { String fontFamily = null; if (propMap.hasKey(familyKey)) { fontFamily = propMap.getString(familyKey); } int style = 0; if (propMap.hasKey(styleKey)) { style = propMap.getInt(styleKey); } return ReactFontManager.getInstance().getTypeface(fontFamily, style, context.getAssets()); }
Example 6
Source File: CrosswalkWebViewGroupManager.java From react-native-webview-crosswalk with MIT License | 5 votes |
@ReactProp(name = "source") public void setSource(final CrosswalkWebView view, @Nullable ReadableMap source) { Activity _activity = reactContext.getCurrentActivity(); if (_activity != null) { if (source != null) { if (source.hasKey("html")) { final String html = source.getString("html"); _activity.runOnUiThread(new Runnable() { @Override public void run () { view.load(null, html); } }); return; } if (source.hasKey("uri")) { final String url = source.getString("uri"); _activity.runOnUiThread(new Runnable() { @Override public void run () { view.load(url, null); } }); return; } } } setUrl(view, BLANK_URL); }
Example 7
Source File: Utils.java From react-native-update with MIT License | 5 votes |
public static String tryGetString(ReadableMap map, String key) { try { return map.getString(key); } catch (NoSuchKeyException e) { return null; } }
Example 8
Source File: ArcGISMapManager.java From react-native-arcgis-sdk-demo with Apache License 2.0 | 5 votes |
@ReactProp(name = "layers") public void setLayers(MapView view, @Nullable ReadableArray layers) { Log.v(REACT_CLASS, "set layers"); if (layers == null || layers.size() < 1) { Log.v(REACT_CLASS, "set layers: adding default layer"); mapView.addLayer(new ArcGISTiledMapServiceLayer(DEFAULT_LAYER)); } else { mapView.removeAll(); for (int i = 0; i < layers.size(); i++) { ReadableMap layer = layers.getMap(i); String type = layer.getString("type"); String url = layer.getString("url"); if (!url.equals("")) { if (type.equals("ArcGISTiledMapServiceLayer")) { Log.v(REACT_CLASS, "set layers: adding ArcGISTiledMapServiceLayer:" + url); mapView.addLayer(new ArcGISTiledMapServiceLayer(url)); } else if (type.equals("ArcGISFeatureLayer")) { Log.v(REACT_CLASS, "set layers: adding ArcGISFeatureLayer:" + url); mapView.addLayer(new ArcGISFeatureLayer(url, ArcGISFeatureLayer.MODE.SNAPSHOT)); } else { Log.v(REACT_CLASS, "set layers: unrecognized layer: " + type); } } else { Log.v(REACT_CLASS, "set layers: invalid url:" + url); } } } }
Example 9
Source File: RNMailComposeModule.java From react-native-mail-compose with MIT License | 5 votes |
private byte[] getBlobFromUri(ReadableMap map, String key) { if (map.hasKey(key) && map.getType(key) == ReadableType.String) { String uri = map.getString(key); if (uri != null && !uri.isEmpty()) { return byteArrayFromUrl(uri); } } return null; }
Example 10
Source File: Downloader.java From react-native-simple-download-manager with MIT License | 5 votes |
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 external = requestConfig.getBoolean("external"); String external_path = requestConfig.getString("path"); 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)); } if(external){ request.setDestinationInExternalPublicDir(external_path, saveAsName); }else{ request.setDestinationInExternalFilesDir(context, Environment.DIRECTORY_DOWNLOADS, saveAsName); } request.setTitle(downloadTitle); request.setDescription(downloadDescription); 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; }
Example 11
Source File: RNMessageComposeModule.java From react-native-message-compose with MIT License | 5 votes |
private byte[] getBlobFromUri(ReadableMap map, String key) { if (map.hasKey(key) && map.getType(key) == ReadableType.String) { String uri = map.getString(key); if (uri != null && !uri.isEmpty()) { return byteArrayFromUrl(uri); } } return null; }
Example 12
Source File: RNBottomSheet.java From react-native-bottomsheet with MIT License | 5 votes |
@ReactMethod public void showShareBottomSheetWithOptions(ReadableMap options, Callback failureCallback, Callback successCallback) { String url = options.getString("url"); String message = options.getString("message"); String subject = options.getString("subject"); List<String> items = new ArrayList<>(); if (message != null && !message.isEmpty()) { items.add(message); } final Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); Uri uri = Uri.parse(url); if (uri != null) { if (uri.getScheme() != null && "data".equals(uri.getScheme().toLowerCase())) { shareIntent.setType("*/*"); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); } else { shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_EMAIL, url); shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject); shareIntent.putExtra(Intent.EXTRA_TEXT, message); } } this.shareSuccessCallback = successCallback; this.shareFailureCallback = failureCallback; if (shareIntent.resolveActivity(this.getCurrentActivity().getPackageManager()) != null) { this.getCurrentActivity().startActivity(Intent.createChooser(shareIntent, "Share To")); } else { failureCallback.invoke(new Exception("The app you want to share is not installed.")); } }
Example 13
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
/** * 检查该用户此时间段内是否有冲突会议 * * @param params * @param callback */ @ReactMethod public void tripMemberCheck(final ReadableMap params, final Callback callback) { String checkId = params.getString("checkId"); String beginTime = params.getString("beginTime"); String endTime = params.getString("endTime"); CalendarTrip.DataBean.TripsBean bean = new CalendarTrip.DataBean.TripsBean(); bean.setCheckId(checkId); bean.setBeginTime(beginTime); bean.setEndTime(endTime); final WritableNativeMap map = new WritableNativeMap(); HttpUtil.tripMemberCheck(bean, new ProtocolCallback.UnitCallback<TripMemberCheckResponse>() { @Override public void onCompleted(TripMemberCheckResponse tripMemberCheckResponse) { map.putBoolean("ok", true); map.putBoolean("isConform", tripMemberCheckResponse.getData().isIsConform()); callback.invoke(map); } @Override public void onFailure(String errMsg) { map.putBoolean("ok", false); callback.invoke(map); } }); }
Example 14
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
/** * 展示手机号 * * @param params */ @ReactMethod public void showUserPhoneNumber(ReadableMap params) { String userId = params.getString("UserId"); NativeApi.openPhoneNumber(userId); }
Example 15
Source File: ReactExoplayerViewManager.java From react-native-video with MIT License | 5 votes |
@ReactProp(name = PROP_SELECTED_VIDEO_TRACK) public void setSelectedVideoTrack(final ReactExoplayerView videoView, @Nullable ReadableMap selectedVideoTrack) { String typeString = null; Dynamic value = null; if (selectedVideoTrack != null) { typeString = selectedVideoTrack.hasKey(PROP_SELECTED_VIDEO_TRACK_TYPE) ? selectedVideoTrack.getString(PROP_SELECTED_VIDEO_TRACK_TYPE) : null; value = selectedVideoTrack.hasKey(PROP_SELECTED_VIDEO_TRACK_VALUE) ? selectedVideoTrack.getDynamic(PROP_SELECTED_VIDEO_TRACK_VALUE) : null; } videoView.setSelectedVideoTrack(typeString, value); }
Example 16
Source File: RNX5WebViewManager.java From react-native-x5 with MIT License | 4 votes |
@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); }
Example 17
Source File: QimRNBModule.java From imsdk-android with MIT License | 4 votes |
/** * 打开指定人朋友圈 * * @param params */ @ReactMethod public void openUserWorkWorld(ReadableMap params) { String jid = params.getString("UserId"); NativeApi.openUserWorkWorld(jid, jid); }
Example 18
Source File: QimRNBModule.java From imsdk-android with MIT License | 4 votes |
/** * 搜索远程文本数据 * * @param params * @param callback */ @ReactMethod public void searchRemoteMessageByKeyword(ReadableMap params, Callback callback) { String keyword = params.getString("search"); //暂时测试数据 搜索我自己 keyword = "我"; String xmppid = params.getString("xmppid"); String realjid = params.getString("realjid"); String time = params.getString("time"); String chatType = params.getString("chatType"); try { // WritableNativeArray writableNativeArray = new WritableNativeArray(); JSONArray list = IMDatabaseManager.getInstance().selectMessageByKeyWord(keyword, xmppid, realjid); Map<String, List<JSONObject>> map = new LinkedHashMap<>(); for (int i = 0; i < list.length(); i++) { JSONObject imMessage = list.getJSONObject(i); String timeStr = getTimeStr(imMessage.getLong("timeLong")); List<JSONObject> oldList = map.get(timeStr); if (oldList != null) { oldList.add(imMessage); } else { List<JSONObject> newList = new ArrayList<>(); newList.add(imMessage); map.put(timeStr, newList); } } WritableNativeMap cMap = new WritableNativeMap(); WritableNativeArray array = new WritableNativeArray(); for (Map.Entry<String, List<JSONObject>> entry : map.entrySet()) { WritableNativeArray itemArray = new WritableNativeArray(); for (int i = 0; i < entry.getValue().size(); i++) { JSONObject jsonObject = entry.getValue().get(i); WritableNativeMap writableNativeMap = new WritableNativeMap(); writableNativeMap.putString("time", jsonObject.optString("time")); writableNativeMap.putString("timeLong", jsonObject.optString("timeLong")); writableNativeMap.putString("content", jsonObject.optString("content")); writableNativeMap.putString("nickName", jsonObject.optString("nickName")); writableNativeMap.putString("headerUrl", jsonObject.optString("headerUrl")); writableNativeMap.putString("msgId", jsonObject.optString("msgId")); writableNativeMap.putString("from", jsonObject.optString("from")); itemArray.pushMap(writableNativeMap); } WritableNativeMap itemMap = new WritableNativeMap(); itemMap.putArray("data", itemArray); itemMap.putString("key", entry.getKey()); array.pushMap(itemMap); } cMap.putBoolean("ok", true); cMap.putArray("data", array); callback.invoke(cMap); } catch (Exception e) { Logger.i("会话内搜索:" + e.getMessage()); } }
Example 19
Source File: RNMailComposeModule.java From react-native-mail-compose with MIT License | 4 votes |
private String getString(ReadableMap map, String key) { if (map.hasKey(key) && map.getType(key) == ReadableType.String) { return map.getString(key); } return null; }
Example 20
Source File: QtalkPlugin.java From imsdk-android with MIT License | 4 votes |
/** * 打开单人会话 */ @ReactMethod public void openGroupChat(ReadableMap params) { String jid = params.getString("GroupId"); NativeApi.openGroupChat(jid, jid); }