List of usage examples for org.json JSONArray getBoolean
public boolean getBoolean(int index) throws JSONException
From source file:com.mirasense.scanditsdk.plugin.ScanditSDK.java
/** * Switches the torch on or off. Pass true to turn it on, false to turn it off. * You call this the following way from java script: * * cordova.exec(null, null, "ScanditSDK", "torch", [true]); *///from w w w .j ava2 s .c o m private void torch(JSONArray data) { boolean enabled = false; try { if (data.length() < 1) { Log.e("ScanditSDK", "The torch call received too few arguments and has to return without starting."); return; } enabled = data.getBoolean(0); } catch (JSONException e) { e.printStackTrace(); } final boolean innerEnabled = enabled; cordova.getActivity().runOnUiThread(new Runnable() { public void run() { if (mBarcodePicker != null) { mBarcodePicker.switchTorchOn(innerEnabled); } else { ScanditSDKActivity.torch(innerEnabled); } } }); }
From source file:com.remobile.camera.CameraLauncher.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback id used when calling back into JavaScript. * @return A PluginResult object with a status and message. *//*from ww w. ja va 2 s . c om*/ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { this.callbackContext = callbackContext; if (action.equals("takePicture")) { int srcType = CAMERA; int destType = FILE_URI; this.saveToPhotoAlbum = false; this.targetHeight = 0; this.targetWidth = 0; this.encodingType = JPEG; this.mediaType = PICTURE; this.mQuality = 80; this.mQuality = args.getInt(0); destType = args.getInt(1); srcType = args.getInt(2); this.targetWidth = args.getInt(3); this.targetHeight = args.getInt(4); this.encodingType = args.getInt(5); this.mediaType = args.getInt(6); this.allowEdit = args.getBoolean(7); this.correctOrientation = args.getBoolean(8); this.saveToPhotoAlbum = args.getBoolean(9); // If the user specifies a 0 or smaller width/height // make it -1 so later comparisons succeed if (this.targetWidth < 1) { this.targetWidth = -1; } if (this.targetHeight < 1) { this.targetHeight = -1; } try { if (srcType == CAMERA) { this.takePicture(destType, encodingType); } else if ((srcType == PHOTOLIBRARY) || (srcType == SAVEDPHOTOALBUM)) { this.getImage(srcType, destType, encodingType); } } catch (IllegalArgumentException e) { callbackContext.error("Illegal Argument Exception"); PluginResult r = new PluginResult(PluginResult.Status.ERROR); callbackContext.sendPluginResult(r); return true; } return true; } return false; }
From source file:com.liferay.mobile.android.v62.dlapp.DLAppService.java
public Boolean verifyFileEntryCheckOut(long repositoryId, long fileEntryId, String lockUuid) throws Exception { JSONObject _command = new JSONObject(); try {//www .j av a 2 s . co m JSONObject _params = new JSONObject(); _params.put("repositoryId", repositoryId); _params.put("fileEntryId", fileEntryId); _params.put("lockUuid", checkNull(lockUuid)); _command.put("/dlapp/verify-file-entry-check-out", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getBoolean(0); }
From source file:com.liferay.mobile.android.v62.dlapp.DLAppService.java
public Boolean verifyFileEntryLock(long repositoryId, long fileEntryId, String lockUuid) throws Exception { JSONObject _command = new JSONObject(); try {// w ww. j a va 2s . co m JSONObject _params = new JSONObject(); _params.put("repositoryId", repositoryId); _params.put("fileEntryId", fileEntryId); _params.put("lockUuid", checkNull(lockUuid)); _command.put("/dlapp/verify-file-entry-lock", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getBoolean(0); }
From source file:com.liferay.mobile.android.v62.dlapp.DLAppService.java
public Boolean verifyInheritableLock(long repositoryId, long folderId, String lockUuid) throws Exception { JSONObject _command = new JSONObject(); try {//from ww w . ja v a 2 s .c o m JSONObject _params = new JSONObject(); _params.put("repositoryId", repositoryId); _params.put("folderId", folderId); _params.put("lockUuid", checkNull(lockUuid)); _command.put("/dlapp/verify-inheritable-lock", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getBoolean(0); }
From source file:com.liferay.mobile.android.v62.role.RoleService.java
public Boolean hasUserRole(long userId, long companyId, String name, boolean inherited) throws Exception { JSONObject _command = new JSONObject(); try {//from ww w . ja va 2 s . c o m JSONObject _params = new JSONObject(); _params.put("userId", userId); _params.put("companyId", companyId); _params.put("name", checkNull(name)); _params.put("inherited", inherited); _command.put("/role/has-user-role", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getBoolean(0); }
From source file:com.liferay.mobile.android.v62.role.RoleService.java
public Boolean hasUserRoles(long userId, long companyId, JSONArray names, boolean inherited) throws Exception { JSONObject _command = new JSONObject(); try {//ww w. ja v a2 s.c om JSONObject _params = new JSONObject(); _params.put("userId", userId); _params.put("companyId", companyId); _params.put("names", checkNull(names)); _params.put("inherited", inherited); _command.put("/role/has-user-roles", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getBoolean(0); }
From source file:com.cordova.photo.CameraLauncher.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @return A PluginResult object with a status and message. *///w w w . j a va 2s .com private boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { this.callbackContext = callbackContext; if (action.equals("takePicture")) { int srcType = CAMERA; int destType = FILE_URI; this.saveToPhotoAlbum = false; this.targetHeight = 0; this.targetWidth = 0; this.encodingType = JPEG; this.mediaType = PICTURE; this.mQuality = 80; this.mQuality = args.getInt(0); destType = args.getInt(1); srcType = args.getInt(2); this.targetWidth = args.getInt(3); this.targetHeight = args.getInt(4); this.encodingType = args.getInt(5); this.mediaType = args.getInt(6); this.allowEdit = args.getBoolean(7); this.correctOrientation = args.getBoolean(8); this.saveToPhotoAlbum = args.getBoolean(9); // If the user specifies a 0 or smaller width/height // make it -1 so later comparisons succeed if (this.targetWidth < 1) { this.targetWidth = -1; } if (this.targetHeight < 1) { this.targetHeight = -1; } try { if (srcType == CAMERA) { this.takePicture(destType, encodingType); } else if ((srcType == PHOTOLIBRARY) || (srcType == SAVEDPHOTOALBUM)) { this.getImage(srcType, destType, encodingType); } } catch (IllegalArgumentException e) { return true; } return true; } return false; }
From source file:com.nolanlawson.cordova.sqlite.SQLitePlugin.java
private SQLitePLuginResult[] execInBackgroundAndReturnResults(JSONArray args) throws JSONException { String dbName = args.getString(0); JSONArray queries = args.getJSONArray(1); boolean readOnly = args.getBoolean(2); int numQueries = queries.length(); SQLitePLuginResult[] results = new SQLitePLuginResult[numQueries]; SQLiteDatabase db = getDatabase(dbName); for (int i = 0; i < numQueries; i++) { JSONArray sqlQuery = queries.getJSONArray(i); String sql = sqlQuery.getString(0); String[] bindArgs = jsonArrayToStringArray(sqlQuery.getJSONArray(1)); try {/*from w w w . j ava 2s . co m*/ if (isSelect(sql)) { results[i] = doSelectInBackgroundAndPossiblyThrow(sql, bindArgs, db); } else { // update/insert/delete if (readOnly) { results[i] = new SQLitePLuginResult(EMPTY_ROWS, EMPTY_COLUMNS, 0, 0, new ReadOnlyException()); } else { results[i] = doUpdateInBackgroundAndPossiblyThrow(sql, bindArgs, db); } } } catch (Throwable e) { if (DEBUG_MODE) { e.printStackTrace(); } results[i] = new SQLitePLuginResult(EMPTY_ROWS, EMPTY_COLUMNS, 0, 0, e); } } return results; }
From source file:io.strider.camera.CameraLauncher.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback id used when calling back into JavaScript. * @return A PluginResult object with a status and message. */// w ww . j a v a 2s .c o m public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { this.callbackContext = callbackContext; if (action.equals("takePicture")) { int srcType = CAMERA; int destType = FILE_URI; this.saveToPhotoAlbum = false; this.targetHeight = 0; this.targetWidth = 0; this.encodingType = JPEG; this.mediaType = PICTURE; this.mQuality = 80; this.mQuality = args.getInt(0); destType = args.getInt(1); srcType = args.getInt(2); this.targetWidth = args.getInt(3); this.targetHeight = args.getInt(4); this.encodingType = args.getInt(5); this.mediaType = args.getInt(6); //this.allowEdit = args.getBoolean(7); // This field is unused. this.correctOrientation = args.getBoolean(8); this.saveToPhotoAlbum = args.getBoolean(9); // If the user specifies a 0 or smaller width/height // make it -1 so later comparisons succeed if (this.targetWidth < 1) { this.targetWidth = -1; } if (this.targetHeight < 1) { this.targetHeight = -1; } try { if (srcType == CAMERA) { this.cleanCache(); this.takePicture(destType, encodingType); } // else if ((srcType == PHOTOLIBRARY) || (srcType == SAVEDPHOTOALBUM)) { // this.getImage(srcType, destType); // } } catch (IllegalArgumentException e) { callbackContext.error("Illegal Argument Exception"); PluginResult r = new PluginResult(PluginResult.Status.ERROR); callbackContext.sendPluginResult(r); return true; } PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT); r.setKeepCallback(true); callbackContext.sendPluginResult(r); return true; } else if (action.equals("cleanup")) { try { this.cleanCache(); } catch (IllegalArgumentException e) { callbackContext.error("Illegal Argument Exception"); PluginResult r = new PluginResult(PluginResult.Status.ERROR); callbackContext.sendPluginResult(r); return true; } PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT); r.setKeepCallback(true); callbackContext.sendPluginResult(r); return true; } return false; }