Java Code Examples for org.json.JSONArray#optBoolean()
The following examples show how to use
org.json.JSONArray#optBoolean() .
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: Core.java From FairEmail with GNU General Public License v3.0 | 5 votes |
private static void onMove(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message) throws JSONException, FolderNotFoundException { // Move message DB db = DB.getInstance(context); // Get arguments long id = jargs.getLong(0); boolean seen = jargs.optBoolean(1); boolean unflag = jargs.optBoolean(3); // Get target folder EntityFolder target = db.folder().getFolder(id); if (target == null) throw new FolderNotFoundException(); // Move from trash/drafts only if (!EntityFolder.TRASH.equals(folder.type) && !EntityFolder.DRAFTS.equals(folder.type)) throw new IllegalArgumentException("Invalid POP3 folder" + " source=" + folder.type + " target=" + target.type); message.folder = target.id; if (seen) message.ui_seen = seen; if (unflag) message.ui_flagged = false; message.ui_hide = false; db.message().updateMessage(message); }
Example 2
Source File: ShortcutsPlugin.java From cordova-plugin-shortcuts-android with MIT License | 5 votes |
private void subscribeOnNewIntent( JSONArray args, CallbackContext callbackContext ) throws JSONException { boolean remove = args.optBoolean(0); if (remove) { this.onNewIntentCallbackContext = null; Log.i(TAG, "Removed callback for onNewIntent"); } else { this.onNewIntentCallbackContext = callbackContext; Log.i(TAG, "Added a new callback for onNewIntent"); } }
Example 3
Source File: CommonParser.java From letv with Apache License 2.0 | 4 votes |
protected boolean getBoolean(JSONArray array, int index) { return array.optBoolean(index); }
Example 4
Source File: CommonParser.java From letv with Apache License 2.0 | 4 votes |
protected boolean getBoolean(JSONArray array, int index) { return array.optBoolean(index); }
Example 5
Source File: CommonParser.java From letv with Apache License 2.0 | 4 votes |
protected boolean getBoolean(JSONArray array, int index) { return array.optBoolean(index); }
Example 6
Source File: SpeechRecognition.java From cordova-plugin-speechrecognition with MIT License | 4 votes |
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { this.callbackContext = callbackContext; Log.d(LOG_TAG, "execute() action " + action); try { if (IS_RECOGNITION_AVAILABLE.equals(action)) { boolean available = isRecognitionAvailable(); PluginResult result = new PluginResult(PluginResult.Status.OK, available); callbackContext.sendPluginResult(result); return true; } if (START_LISTENING.equals(action)) { if (!isRecognitionAvailable()) { callbackContext.error(NOT_AVAILABLE); return true; } if (!audioPermissionGranted(RECORD_AUDIO_PERMISSION)) { callbackContext.error(MISSING_PERMISSION); return true; } String lang = args.optString(0); if (lang == null || lang.isEmpty() || lang.equals("null")) { lang = Locale.getDefault().toString(); } int matches = args.optInt(1, MAX_RESULTS); String prompt = args.optString(2); if (prompt == null || prompt.isEmpty() || prompt.equals("null")) { prompt = null; } mLastPartialResults = new JSONArray(); Boolean showPartial = args.optBoolean(3, false); Boolean showPopup = args.optBoolean(4, true); startListening(lang, matches, prompt,showPartial, showPopup); return true; } if (STOP_LISTENING.equals(action)) { final CallbackContext callbackContextStop = this.callbackContext; view.post(new Runnable() { @Override public void run() { if(recognizer != null) { recognizer.stopListening(); } callbackContextStop.success(); } }); return true; } if (GET_SUPPORTED_LANGUAGES.equals(action)) { getSupportedLanguages(); return true; } if (HAS_PERMISSION.equals(action)) { hasAudioPermission(); return true; } if (REQUEST_PERMISSION.equals(action)) { requestAudioPermission(); return true; } } catch (Exception e) { e.printStackTrace(); callbackContext.error(e.getMessage()); } return false; }