List of usage examples for com.facebook.react.bridge ReadableMap hasKey
boolean hasKey(@NonNull String name);
From source file:com.auth0.lock.react.bridge.InitOptions.java
License:Open Source License
public InitOptions(@Nullable ReadableMap options) { if (options == null) { return;/*from w w w . j a v a2 s . c om*/ } if (options.hasKey(CLIENT_ID_KEY)) { this.clientId = options.getString(CLIENT_ID_KEY); } if (options.hasKey(DOMAIN_KEY)) { this.domain = options.getString(DOMAIN_KEY); } if (options.hasKey(CONFIGURATION_DOMAIN_KEY)) { this.configurationDomain = options.getString(CONFIGURATION_DOMAIN_KEY); } this.libraryVersion = options.hasKey(LIBRARY_VERSION_KEY) ? options.getString(LIBRARY_VERSION_KEY) : "0.0.0"; }
From source file:com.auth0.lock.react.bridge.ShowOptions.java
License:Open Source License
public ShowOptions(@Nullable ReadableMap options) { if (options == null) { return;//from w ww .ja v a2 s . co m } if (options.hasKey(CLOSABLE_KEY)) { closable = options.getBoolean(CLOSABLE_KEY); Log.d(TAG, CLOSABLE_KEY + closable); } if (options.hasKey(DISABLE_SIGNUP)) { disableSignUp = options.getBoolean(DISABLE_SIGNUP); Log.d(TAG, DISABLE_SIGNUP + disableSignUp); } if (options.hasKey(DISABLE_RESET_PASSWORD)) { disableResetPassword = options.getBoolean(DISABLE_RESET_PASSWORD); Log.d(TAG, DISABLE_RESET_PASSWORD + disableResetPassword); } if (options.hasKey(USE_MAGIC_LINK_KEY)) { useMagicLink = options.getBoolean(USE_MAGIC_LINK_KEY); Log.d(TAG, USE_MAGIC_LINK_KEY + useMagicLink); } if (options.hasKey(AUTH_PARAMS_KEY)) { ReadableMap reactMap = options.getMap(AUTH_PARAMS_KEY); authParams = OptionsHelper.convertReadableMapToMap(reactMap); Log.d(TAG, AUTH_PARAMS_KEY + authParams); } if (options.hasKey(CONNECTIONS_KEY)) { ReadableArray connections = options.getArray(CONNECTIONS_KEY); List<String> list = new ArrayList<>(connections.size()); for (int i = 0; i < connections.size(); i++) { String connectionName = connections.getString(i); switch (connectionName) { case LockReactModule.CONNECTION_EMAIL: connectionType = LockReactModule.CONNECTION_EMAIL; break; case LockReactModule.CONNECTION_SMS: connectionType = LockReactModule.CONNECTION_SMS; break; } list.add(connectionName); } this.connections = new String[list.size()]; this.connections = list.toArray(this.connections); Log.d(TAG, CONNECTIONS_KEY + list); } }
From source file:com.blockablewebview.BlockableWebViewManager.java
License:Open Source License
@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);/* www. j av a 2 s. c o m*/ } 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(); headerMap.put(key, headers.getString(key)); } } view.loadUrl(url, headerMap); return; } } view.loadUrl(BLANK_URL); }
From source file:com.boundlessgeo.spatialconnect.jsbridge.RNSpatialConnect.java
License:Apache License
/** * Handles a message sent from Javascript. Expects the message envelope to look like: * <code>{"type":<String>,"payload":<JSON Object>}</code> * * @param message message from javascript *///from w w w .ja v a2 s. c om @ReactMethod public void handler(final ReadableMap message) { if (message == null) { Log.w(LOG_TAG, "data message was null or undefined"); return; } Log.d(LOG_TAG, "JS --> sdk " + message.toString()); String responseId = message.hasKey("responseId") ? message.getString("responseId") : null; final String type = !TextUtils.isEmpty(responseId) ? responseId : message.getString("type"); Subscriber<Object> subscriber = new Subscriber<Object>() { @Override public void onNext(Object object) { WritableMap newAction = Arguments.createMap(); newAction.putString("type", message.getString("type")); writePayloadToMap(newAction, object); sendEvent(newAction, SCBridgeStatus.NEXT, type); } @Override public void onError(Throwable e) { WritableMap newAction = Arguments.createMap(); newAction.putString("type", message.getString("type")); newAction.putString("payload", e.getLocalizedMessage()); sendEvent(newAction, SCBridgeStatus.ERROR, type); } @Override public void onCompleted() { WritableMap completed = Arguments.createMap(); completed.putString("type", message.getString("type")); sendEvent(completed, SCBridgeStatus.COMPLETED, type); } }; mBridgeAPI.parseJSAction(convertMapToHashMap(message), subscriber); }
From source file:com.dylanvann.cameraroll.CameraRollManager.java
License:Open Source License
/** * Get photos from {@link MediaStore.Images}, most recent first. * * @param params a map containing the following keys: * <ul>/*from w w w . java 2 s . c om*/ * <li>first (mandatory): a number representing the number of photos to fetch</li> * <li> * after (optional): a cursor that matches page_info[end_cursor] returned by a * previous call to {@link #getPhotos} * </li> * <li>groupName (optional): an album name</li> * <li> * mimeType (optional): restrict returned images to a specific mimetype (e.g. * image/jpeg) * </li> * </ul> * @param promise the Promise to be resolved when the photos are loaded; for a format of the * parameters passed to this callback, see {@code getPhotosReturnChecker} in CameraRoll.js */ @ReactMethod public void getPhotos(final ReadableMap params, final Promise promise) { int first = params.getInt("first"); String after = params.hasKey("after") ? params.getString("after") : null; String albumId = params.hasKey("albumId") ? params.getString("albumId") : null; ReadableArray mimeTypes = params.hasKey("mimeTypes") ? params.getArray("mimeTypes") : null; if (params.hasKey("groupTypes")) { throw new JSApplicationIllegalArgumentException("groupTypes is not supported on Android"); } new GetPhotosTask(getReactApplicationContext(), first, after, albumId, mimeTypes, promise) .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.dylanvann.cameraroll.ImageEditingManager.java
License:Open Source License
/** * Crop an image. If all goes well, the success callback will be called with the file:// URI of * the new image as the only argument. This is a temporary file - consider using * CameraRollManager.saveImageWithTag to save it in the gallery. * * @param uri the MediaStore URI of the image to crop * @param options crop parameters specified as {@code {offset: {x, y}, size: {width, height}}}. * Optionally this also contains {@code {targetSize: {width, height}}}. If this is * specified, the cropped image will be resized to that size. * All units are in pixels (not DPs). * @param success callback to be invoked when the image has been cropped; the only argument that * is passed to this callback is the file:// URI of the new image * @param error callback to be invoked when an error occurs (e.g. can't create file etc.) *///from w ww. j a v a2 s .c o m @ReactMethod public void cropImage(String uri, ReadableMap options, final Callback success, final Callback error) { ReadableMap offset = options.hasKey("offset") ? options.getMap("offset") : null; ReadableMap size = options.hasKey("size") ? options.getMap("size") : null; if (offset == null || size == null || !offset.hasKey("x") || !offset.hasKey("y") || !size.hasKey("width") || !size.hasKey("height")) { throw new JSApplicationIllegalArgumentException("Please specify offset and size"); } if (uri == null || uri.isEmpty()) { throw new JSApplicationIllegalArgumentException("Please specify a URI"); } CropTask cropTask = new CropTask(getReactApplicationContext(), uri, (int) offset.getDouble("x"), (int) offset.getDouble("y"), (int) size.getDouble("width"), (int) size.getDouble("height"), success, error); if (options.hasKey("displaySize")) { ReadableMap targetSize = options.getMap("displaySize"); cropTask.setTargetSize(targetSize.getInt("width"), targetSize.getInt("height")); } cropTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.farmisen.react_native_file_uploader.RCTFileUploaderModule.java
License:Open Source License
private ReadableMap getMapParam(ReadableMap map, String key, ReadableMap defaultValue) { if (map.hasKey(key)) { return map.getMap(key); } else {/* ww w . j a va 2 s. c om*/ return defaultValue; } }
From source file:com.farmisen.react_native_file_uploader.RCTFileUploaderModule.java
License:Open Source License
private String getStringParam(ReadableMap map, String key, String defaultValue) { if (map.hasKey(key)) { return map.getString(key); } else {/*from ww w .ja v a2 s . c o m*/ return defaultValue; } }
From source file:com.google.android.cameraview.Camera1.java
License:Apache License
void takePictureInternal(final ReadableMap options) { if (!isPictureCaptureInProgress.getAndSet(true)) { if (options.hasKey("orientation") && options.getInt("orientation") != Constants.ORIENTATION_AUTO) { mOrientation = options.getInt("orientation"); int rotation = orientationEnumToRotation(mOrientation); mCameraParameters.setRotation(calcCameraRotation(rotation)); mCamera.setParameters(mCameraParameters); }/*from w w w . j av a 2 s . c o m*/ mCamera.takePicture(null, null, null, new Camera.PictureCallback() { @Override public void onPictureTaken(byte[] data, Camera camera) { isPictureCaptureInProgress.set(false); camera.cancelAutoFocus(); if (options.hasKey("pauseAfterCapture") && !options.getBoolean("pauseAfterCapture")) { camera.startPreview(); mIsPreviewActive = true; if (mIsScanning) { camera.setPreviewCallback(Camera1.this); } } else { camera.stopPreview(); mIsPreviewActive = false; camera.setPreviewCallback(null); } mOrientation = Constants.ORIENTATION_AUTO; mCallback.onPictureTaken(data, displayOrientationToOrientationEnum(mDeviceOrientation)); } }); } }
From source file:com.hijridatepicker.HijriDatePickerAndroidModule.java
License:Open Source License
private Bundle createFragmentArguments(ReadableMap options, Promise promise) { final Bundle args = new Bundle(); try {//from www. j ava 2s . c o m if (options.hasKey(ARG_DATE) && !options.isNull(ARG_DATE)) { if (!parseOptionsWithKey(ARG_DATE, options, args, promise)) return null; } if (options.hasKey(ARG_MINDATE) && !options.isNull(ARG_MINDATE)) { if (!parseOptionsWithKey(ARG_MINDATE, options, args, promise)) return null; } if (options.hasKey(ARG_MAXDATE) && !options.isNull(ARG_MAXDATE)) { if (!parseOptionsWithKey(ARG_MAXDATE, options, args, promise)) return null; } if (options.hasKey(ARG_MODE) && !options.isNull(ARG_MODE)) { args.putString(ARG_MODE, options.getString(ARG_MODE)); } if (options.hasKey(ARG_WEEK_DAY_LABELS) && !options.isNull(ARG_WEEK_DAY_LABELS)) { args.putStringArrayList(ARG_WEEK_DAY_LABELS, toStringArrayList(options.getArray(ARG_WEEK_DAY_LABELS))); } } catch (Exception e) { promise.reject(ERROR_PARSING_OPTIONS, "Exception happened while parsing options, details: " + e.getMessage()); return null; } return args; }