ReadableType type = map.getType(key); switch (type) { case Number: double value = map.getDouble(key); if (value == (long) value) { return String.valueOf((long) value); return String.valueOf(map.getBoolean(key)); case String: return map.getString(key); case Null: return null;
if (options.hasKey("onPositive")) { mBuilder.onPositive(new MaterialDialog.SingleButtonCallback() { @Override if (options.hasKey("onNegative")) { mBuilder.onNegative(new MaterialDialog.SingleButtonCallback() { @Override if (options.hasKey("onNeutral")) { mBuilder.onNeutral(new MaterialDialog.SingleButtonCallback() { @Override if (options.hasKey("onAny")) { mBuilder.onAny(new MaterialDialog.SingleButtonCallback() { @Override if (options.hasKey("itemsCallback")) { mBuilder.itemsCallback(new MaterialDialog.ListCallback() { @Override if (options.hasKey("itemsCallbackSingleChoice")) { int selectedIndex = options.hasKey("selectedIndex") ? options.getInt("selectedIndex") : -1; mBuilder.itemsCallbackSingleChoice(selectedIndex, new MaterialDialog.ListCallbackSingleChoice() { @Override if (options.hasKey("itemsCallbackMultiChoice")) { if (options.hasKey("selectedIndices")) {
/** * Convert a JavaScript stack trace (see {@code parseErrorStack} JS module) to an array of * {@link StackFrame}s. */ public static StackFrame[] convertJsStackTrace(@Nullable ReadableArray stack) { int size = stack != null ? stack.size() : 0; StackFrame[] result = new StackFrame[size]; for (int i = 0; i < size; i++) { ReadableMap frame = stack.getMap(i); String methodName = frame.getString("methodName"); String fileName = frame.getString("file"); int lineNumber = -1; if (frame.hasKey(LINE_NUMBER_KEY) && !frame.isNull(LINE_NUMBER_KEY)) { lineNumber = frame.getInt(LINE_NUMBER_KEY); } int columnNumber = -1; if (frame.hasKey(COLUMN_KEY) && !frame.isNull(COLUMN_KEY)) { columnNumber = frame.getInt(COLUMN_KEY); } result[i] = new StackFrameImpl(fileName, methodName, lineNumber, columnNumber); } return result; }
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; }
protected ShareFile getFileShare(ReadableMap options) { if (ShareIntent.hasValidKey("type", options)) { return new ShareFile(options.getString("url"), options.getString("type"), this.reactContext); } else { return new ShareFile(options.getString("url"), this.reactContext); } } protected ShareFiles getFileShares(ReadableMap options) {
protected ShareFiles getFileShares(ReadableMap options) { if (ShareIntent.hasValidKey("type", options)) { return new ShareFiles(options.getArray("urls"), options.getString("type"), this.reactContext); } else { return new ShareFiles(options.getArray("urls"), this.reactContext); } } protected static String urlEncode(String param) {
String callbackUrlStr = params.getString("callback_url"); _callbackUrls.add(callbackUrlStr); 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);
if (options.hasKey("blured")) { getBluredImages = options.getBoolean("blured"); if (options.hasKey("artist")) { getArtistFromSong = options.getBoolean("artist"); if (options.hasKey("duration")) { getDurationFromSong = options.getBoolean("duration"); if (options.hasKey("title")) { getTitleFromSong = options.getBoolean("title"); if (options.hasKey("id")) { getIDFromSong = options.getBoolean("id"); if (options.hasKey("cover")) { getCoverFromSong = options.getBoolean("cover"); if (options.hasKey("genre")) { getGenreFromSong = options.getBoolean("genre"); if (options.hasKey("album")) { getAlbumFromSong = options.getBoolean("album"); if (options.hasKey("batchNumber")) { songsPerIteration = options.getInt("batchNumber"); if (options.hasKey("minimumSongDuration") && options.getInt("minimumSongDuration") > 0) { minimumSongDuration = options.getInt("minimumSongDuration");
protected void openIntentChooser() throws ActivityNotFoundException { if(this.options.hasKey("forceDialog") && this.options.getBoolean("forceDialog")){ Intent chooser = Intent.createChooser(this.getIntent(), this.chooserTitle); chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); this.reactContext.startActivity(chooser); }else{ this.getIntent().setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); this.reactContext.startActivity(this.getIntent()); } } }
@ReactMethod public void show(ReadableMap args, Callback callback) { Intent intent; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } else { intent = new Intent(Intent.ACTION_PICK); } intent.addCategory(Intent.CATEGORY_OPENABLE); if (!args.isNull("filetype")) { ReadableArray filetypes = args.getArray("filetype"); if (filetypes.size() > 0) { intent.setType(filetypes.getString(0)); } } this.callback = callback; getReactApplicationContext().startActivityForResult(intent, READ_REQUEST_CODE, Bundle.EMPTY); }
@ReactMethod public void showBottomSheetWithOptions(ReadableMap options, final Callback onSelect) { ReadableArray optionArray = options.getArray("options"); final Integer cancelButtonIndex = options.getInt("cancelButtonIndex"); final BottomSheet.Builder builder = new BottomSheet.Builder(this.getCurrentActivity()); // create options Integer size = optionArray.size(); for (int i = 0; i < size; i++) { builder.sheet(i, optionArray.getString(i)); } builder.listener(new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == cancelButtonIndex) { dialog.dismiss(); } else { onSelect.invoke(which); } } }); UiThreadUtil.runOnUiThread(new Runnable() { @Override public void run() { builder.build().show(); } }); }
private MaterialDialog.Builder applyOptions(MaterialDialog.Builder builder, ReadableMap options) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException { ReadableMapKeySetIterator iterator = options.keySetIterator(); while(iterator.hasNextKey()) { String key = iterator.nextKey(); builder.title(options.getString("title")); break; case "content": if(options.hasKey("contentIsHtml") && options.getBoolean("contentIsHtml")) { builder.content(Html.fromHtml(options.getString("content"))); } else { builder.content(options.getString("content")); builder.positiveText(options.getString("positiveText")); break; case "positiveColor": builder.positiveColor(options.getInt("positiveColor")); break; case "negativeText": builder.negativeText(options.getString("negativeText")); break; case "negativeColor": builder.negativeColor(options.getInt("negativeColor")); break; case "neutralText": builder.neutralText(options.getString("neutralText")); break; case "neutralColor": builder.neutralColor(options.getInt("neutralColor"));
ReadableType type = map.getType(key); switch (type) { case Number: double value = map.getDouble(key); if (value == (long) value) { return String.valueOf((long) value); return String.valueOf(map.getBoolean(key)); case String: return map.getString(key); case Null: return null;
@ReactMethod public void shareSingle(ReadableMap options, @Nullable Callback failureCallback, @Nullable Callback successCallback) { System.out.println("SHARE SINGLE METHOD"); if (ShareIntent.hasValidKey("social", options) ) { try{ ShareIntent shareClass = SHARES.getShareClass(options.getString("social"), this.reactContext); if (shareClass != null && shareClass instanceof ShareIntent) { shareClass.open(options); successCallback.invoke("OK"); } else { throw new ActivityNotFoundException("Invalid share activity"); } }catch(ActivityNotFoundException ex) { System.out.println("ERROR"); System.out.println(ex.getMessage()); failureCallback.invoke(ex.getMessage()); }catch (Exception e) { System.out.println("ERROR"); System.out.println(e.getMessage()); failureCallback.invoke(e.getMessage()); } } else { failureCallback.invoke("key 'social' missing in options"); } }
this.getIntent().putExtra(Intent.EXTRA_SUBJECT, options.getString("subject")); this.chooserTitle = options.getString("title"); message = options.getString("message"); this.getIntent().putExtra(Intent.EXTRA_TEXT, message + " " + options.getArray("urls").toString()); } else { this.getIntent().putExtra(Intent.EXTRA_TEXT, options.getArray("urls").toString()); this.getIntent().putExtra(Intent.EXTRA_TEXT, message + " " + options.getString("url")); } else { this.getIntent().putExtra(Intent.EXTRA_TEXT, options.getString("url"));