List of usage examples for org.json JSONArray optJSONArray
public JSONArray optJSONArray(int index)
From source file:com.samsung.richnotification.RichNotificationOptions.java
RichNotificationOptions(JSONArray data) throws JSONException { // Fetch options from the data object this.uuid = data.optString(0); this.readoutTitle = data.optString(1); this.readout = data.optString(2); this.notificationTitle = data.optString(3); this.headerSizeType = data.optString(4); this.primarySubHeader = data.optString(5); this.primaryBody = data.optString(6); this.qrImage = data.optString(7); this.primaryBackgroundColor = data.optString(8); this.primaryBackgroundImage = data.optString(9); this.secondaryType = data.optString(10); this.secondarySubHeader = data.optString(11); this.secondaryContent = data.optJSONArray(12); this.secondaryBackgroundColor = data.optString(13); this.secondaryImage = data.optString(14); this.secondaryIcon1Path = data.optString(15); this.secondaryIcon1Text = data.optString(16); this.secondaryIcon2Path = data.optString(17); this.secondaryIcon2Text = data.optString(18); this.notificationIcon = data.optString(19); int alert = data.optInt(20); int popup = data.optInt(21); this.actions = data.optJSONArray(22); switch (alert) { case RichNotificationHelper.ALERT_TYPE_SILENCE: this.alertType = AlertType.SILENCE; break;//from w w w .j a v a 2 s . c o m case RichNotificationHelper.ALERT_TYPE_SOUND: this.alertType = AlertType.SOUND; break; case RichNotificationHelper.ALERT_TYPE_SOUND_AND_VIBR: this.alertType = AlertType.SOUND_AND_VIBRATION; break; case RichNotificationHelper.ALERT_TYPE_VIBR: this.alertType = AlertType.VIBRATION; break; default: this.alertType = AlertType.SOUND_AND_VIBRATION; } if (popup == RichNotificationHelper.POPUP_TYPE_NONE) this.popupType = PopupType.NONE; else this.popupType = PopupType.NORMAL; }
From source file:org.catnut.plugin.zhihu.Zhihu.java
@Override public ContentValues convert(JSONArray array) { long now = System.currentTimeMillis(); ContentValues item = new ContentValues(); // ??item???/*from w ww. jav a 2s . co m*/ item.put(BaseColumns._ID, now); // item.put(STATUS, array.optString(1)); item.put(ANSWER, array.optString(2)); item.put(LAST_ALTER_DATE, array.optLong(4) * 1000); item.put(ANSWER_ID, array.optLong(5)); // JSONArray user = array.optJSONArray(6); if (user != null) { item.put(NICK, user.optString(0)); item.put(UID, user.optString(1)); item.put(AVATAR, user.optInt(2)); } // JSONArray question = array.optJSONArray(7); if (question != null) { item.put(TITLE, question.optString(1, null)); item.put(DESCRIPTION, question.optString(2)); item.put(QUESTION_ID, question.optLong(3)); } return item; }
From source file:org.jjdltc.cordova.plugin.sftp.JJsftp.java
/** * Validate if the options sent by user are not null or empty and also if accomplish the base structure * /*ww w.ja v a 2 s .com*/ * @param arguments The arguments passed by user with the JSONArray of JSONObject with the local and remote path of the files * @return A valid 'actionArr' JSONArray with its inner JSONObject paths */ private JSONArray setActionArr(JSONArray arguments) { JSONArray actionArr = arguments.optJSONArray(1); boolean validArr = true; if (actionArr == null) { return null; } for (int i = 0; i < actionArr.length(); i++) { JSONObject tempActionObj = actionArr.optJSONObject(i); if (tempActionObj == null) { validArr = false; } else { validArr = (tempActionObj.opt("remote") == null || tempActionObj.opt("local") == null) ? false : validArr; } if (!validArr) { break; } } return (validArr) ? actionArr : null; }