List of usage examples for org.json JSONArray getString
public String getString(int index) throws JSONException
From source file:com.polyvi.xface.extension.audio.XAudioExt.java
@Override public XExtensionResult exec(String action, JSONArray args, XCallbackContext callbackCtx) throws JSONException { String appId = mWebContext.getApplication().getAppId(); XExtensionResult.Status status = XExtensionResult.Status.NO_RESULT; if (action.equals(COMMAND_PLAY)) { XAudioStatusChangeListener listener = new XAudioStatusChangeListener(callbackCtx); play(args.getString(0), args.getString(1), mWebContext.getWorkSpace(), listener); } else if (action.equals(COMMAND_STOP)) { stop(args.getString(0));/*from w w w. j av a2s . c o m*/ } else if (action.equals(COMMAND_PAUSE)) { pause(args.getString(0)); } else if (action.equals(COMMAND_SEEKTO)) { seekTo(args.getString(0), args.getInt(1)); } else if (action.equals(COMMAND_RELEASE)) { boolean ret = release(args.getString(0)); return new XExtensionResult(status, ret); } else if (action.equals(COMMAND_GETCURRENTPOSITION)) { int pos = getCurrentPosition(args.getString(0), appId); return new XExtensionResult(XExtensionResult.Status.OK, pos); } else if (action.equals(COMMAND_STARTRECORDING)) { XAudioStatusChangeListener listener = new XAudioStatusChangeListener(callbackCtx); startRecording(args.getString(0), args.getString(1), mWebContext.getWorkSpace(), listener); } else if (action.equals(COMMAND_STOPRECORDING)) { stopRecording(args.getString(0)); } else if (action.equals(COMMAND_SETVOLUME)) { setVolume(args.getString(0), Float.parseFloat(args.getString(1))); } return new XExtensionResult(status); }
From source file:com.phonegap.Capture.java
@Override public PluginResult execute(String action, JSONArray args, String callbackId) { this.callbackId = callbackId; this.limit = 1; this.duration = 0.0f; this.results = new JSONArray(); JSONObject options = args.optJSONObject(0); if (options != null) { limit = options.optLong("limit", 1); duration = options.optDouble("duration", 0.0f); }//w w w.j a v a 2s . c o m if (action.equals("getFormatData")) { try { JSONObject obj = getFormatData(args.getString(0), args.getString(1)); return new PluginResult(PluginResult.Status.OK, obj); } catch (JSONException e) { return new PluginResult(PluginResult.Status.ERROR); } } else if (action.equals("captureAudio")) { this.captureAudio(); } else if (action.equals("captureImage")) { this.captureImage(); } else if (action.equals("captureVideo")) { this.captureVideo(duration); } PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT); r.setKeepCallback(true); return r; }
From source file:com.liferay.mobile.android.v7.journalarticle.JournalArticleService.java
public String getArticleContent(long groupId, String articleId, String languageId, JSONObjectWrapper themeDisplay) throws Exception { JSONObject _command = new JSONObject(); try {/* ww w. j ava 2s .c o m*/ JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("articleId", checkNull(articleId)); _params.put("languageId", checkNull(languageId)); mangleWrapper(_params, "themeDisplay", "com.liferay.portal.kernel.theme.ThemeDisplay", themeDisplay); _command.put("/journal.journalarticle/get-article-content", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getString(0); }
From source file:com.liferay.mobile.android.v7.journalarticle.JournalArticleService.java
public String getArticleContent(long groupId, String articleId, String languageId, JSONObjectWrapper portletRequestModel, JSONObjectWrapper themeDisplay) throws Exception { JSONObject _command = new JSONObject(); try {// www .jav a2 s . co m JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("articleId", checkNull(articleId)); _params.put("languageId", checkNull(languageId)); mangleWrapper(_params, "portletRequestModel", "com.liferay.portal.kernel.portlet.PortletRequestModel", portletRequestModel); mangleWrapper(_params, "themeDisplay", "com.liferay.portal.kernel.theme.ThemeDisplay", themeDisplay); _command.put("/journal.journalarticle/get-article-content", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getString(0); }
From source file:com.liferay.mobile.android.v7.journalarticle.JournalArticleService.java
public String getArticleContent(long groupId, String articleId, double version, String languageId, JSONObjectWrapper themeDisplay) throws Exception { JSONObject _command = new JSONObject(); try {/* w ww. j a va 2 s. c o m*/ JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("articleId", checkNull(articleId)); _params.put("version", version); _params.put("languageId", checkNull(languageId)); mangleWrapper(_params, "themeDisplay", "com.liferay.portal.kernel.theme.ThemeDisplay", themeDisplay); _command.put("/journal.journalarticle/get-article-content", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getString(0); }
From source file:com.liferay.mobile.android.v7.journalarticle.JournalArticleService.java
public String getArticleContent(long groupId, String articleId, double version, String languageId, JSONObjectWrapper portletRequestModel, JSONObjectWrapper themeDisplay) throws Exception { JSONObject _command = new JSONObject(); try {/*w w w.ja v a2 s . c om*/ JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("articleId", checkNull(articleId)); _params.put("version", version); _params.put("languageId", checkNull(languageId)); mangleWrapper(_params, "portletRequestModel", "com.liferay.portal.kernel.portlet.PortletRequestModel", portletRequestModel); mangleWrapper(_params, "themeDisplay", "com.liferay.portal.kernel.theme.ThemeDisplay", themeDisplay); _command.put("/journal.journalarticle/get-article-content", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getString(0); }
From source file:edu.umass.cs.msocket.proxy.console.commands.GroupMemberList.java
@Override public void parse(String commandText) throws Exception { UniversalGnsClient gnsClient = module.getGnsClient(); try {// w w w. j av a 2 s .co m StringTokenizer st = new StringTokenizer(commandText.trim()); String groupGuid; if (st.countTokens() == 0) { groupGuid = module.getAccountGuid().getGuid(); } else if (st.countTokens() == 1) { groupGuid = st.nextToken(); if (!GnsUtils.isValidGuidString(groupGuid)) { // We probably have an alias, lookup the GUID groupGuid = gnsClient.lookupGuid(groupGuid); } } else { console.printString("Wrong number of arguments for this command.\n"); return; } console.printString("Members in group " + groupGuid); console.printNewline(); JSONArray members = gnsClient.groupGetMembers(groupGuid, module.getAccountGuid()); for (int i = 0; i < members.length(); i++) { console.printString(i + ": " + members.getString(i)); console.printNewline(); } } catch (Exception e) { console.printString("Failed to access GNS ( " + e + ")\n"); } }
From source file:com.karura.framework.plugins.UI.java
@JavascriptInterface // #endif/*w w w . j a v a2 s . c o m*/ @SupportJavascriptInterface @Description("Load the url into the webview.") @Asynchronous(retVal = "none, will load the specified URL in the webview") @Params({ @Param(name = "callId", description = "The method correlator between javascript and java."), @Param(name = "url", description = "URL to be loaded in the web browser"), @Param(name = "props", description = "Specifies the parameters for customizing the loadUrl experience. Look at " + "WAIT_KEY, OPEN_EXTR_KEY and CLEAR_HISTORY_KEY. If the OPEN_EXTR_KEY is specified then this object can also contain additional " + "parameters which need to be passed to the external viewer in the intent. The other keys can only be integer, boolean or string") }) public void loadUrl(final String callId, String url, JSONObject props) throws JSONException { Log.d(TAG, "loadUrl(" + url + "," + props + ")"); int wait = 0; boolean openExternal = false; boolean clearHistory = false; // If there are properties, then set them on the Activity HashMap<String, Object> params = new HashMap<String, Object>(); if (props != null) { JSONArray keys = props.names(); for (int i = 0; i < keys.length(); i++) { String key = keys.getString(i); if (key.equals(WAIT_KEY)) { wait = props.getInt(key); } else if (key.equalsIgnoreCase(OPEN_EXTR_KEY)) { openExternal = props.getBoolean(key); } else if (key.equalsIgnoreCase(CLEAR_HISTORY_KEY)) { clearHistory = props.getBoolean(key); } else { Object value = props.get(key); if (value == null) { } else if (value.getClass().equals(String.class)) { params.put(key, (String) value); } else if (value.getClass().equals(Boolean.class)) { params.put(key, (Boolean) value); } else if (value.getClass().equals(Integer.class)) { params.put(key, (Integer) value); } } } } // If wait property, then delay loading if (wait > 0) { try { synchronized (this) { this.wait(wait); } } catch (InterruptedException e) { e.printStackTrace(); } } getWebView().showWebPage(url, openExternal, clearHistory, params); }
From source file:com.app.plugins.childBrowser.ChildBrowser.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackId The callback id used when calling back into JavaScript. * @return A PluginResult object with a status and message. *///from www . j a v a 2s. c om public PluginResult execute(String action, JSONArray args, String callbackId) { PluginResult.Status status = PluginResult.Status.OK; String result = ""; try { if (action.equals("showWebPage")) { this.browserCallbackId = callbackId; // If the ChildBrowser is already open then throw an error if (dialog != null && dialog.isShowing()) { return new PluginResult(PluginResult.Status.ERROR, "ChildBrowser is already open"); } result = this.showWebPage(args.getString(0), args.optJSONObject(1)); if (result.length() > 0) { status = PluginResult.Status.ERROR; return new PluginResult(status, result); } else { PluginResult pluginResult = new PluginResult(status, result); pluginResult.setKeepCallback(true); return pluginResult; } } else if (action.equals("close")) { closeDialog(); JSONObject obj = new JSONObject(); obj.put("type", CLOSE_EVENT); this.onClose(); PluginResult pluginResult = new PluginResult(status, obj); pluginResult.setKeepCallback(false); return pluginResult; } else if (action.equals("openExternal")) { result = this.openExternal(args.getString(0), args.optBoolean(1)); if (result.length() > 0) { status = PluginResult.Status.ERROR; } } else { status = PluginResult.Status.INVALID_ACTION; } return new PluginResult(status, result); } catch (JSONException e) { return new PluginResult(PluginResult.Status.JSON_EXCEPTION); } }
From source file:com.lewie9021.videothumbnail.VideoThumbnail.java
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { try {/*from w w w. j a v a 2 s. co m*/ // Action is 'create' if (action.equals("create")) { Uri fileURI = Uri.fromFile(new File(args.getString(0))); String filePath = args.getString(0).replace(fileURI.getScheme() + ":", ""); Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail(filePath, Thumbnails.MINI_KIND); callbackContext.success(encodeTobase64(thumbnail)); return true; } else { callbackContext.error("Invalid action"); return false; } } catch (JSONException e) { callbackContext.error("JSON Exception"); return true; } }