/** * Get the optional int value associated with an index. The defaultValue is * returned if there is no value for the index, or if the value is not a * number and cannot be converted to a number. * * @param index * The index must be between 0 and length() - 1. * @param defaultValue * The default value. * @return The value. */ public int optInt(int index, int defaultValue) { try { return this.getInt(index); } catch (Exception e) { return defaultValue; } }
try { JSONArray jsonArray2 = new JSONArray(prefs.getString("key", "[]")); for (int i = 0; i < jsonArray2.length(); i++) { Log.d("your JSON Array", jsonArray2.getInt(i)+""); } } catch (Exception e) { e.printStackTrace(); }
private void update(JSONObject g) { for (String t : new String[] { "new", "rev", "lrn", "time" }) { String key = t + "Today"; try { if (g.getJSONArray(key).getInt(0) != mToday) { JSONArray ja = new JSONArray(); ja.put(mToday); ja.put(0); g.put(key, ja); } } catch (JSONException e) { throw new RuntimeException(e); } } }
public int _deckNewLimitSingle(JSONObject g) { try { if (g.getInt("dyn") != 0) { return mReportLimit; } JSONObject c = mCol.getDecks().confForDid(g.getLong("id")); return Math.max(0, c.getJSONObject("new").getInt("perDay") - g.getJSONArray("newToday").getInt(1)); } catch (JSONException e) { throw new RuntimeException(e); } }
private int _deckRevLimitSingle(JSONObject d) { try { if (d.getInt("dyn") != 0) { return mReportLimit; } JSONObject c = mCol.getDecks().confForDid(d.getLong("id")); return Math.max(0, c.getJSONObject("rev").getInt("perDay") - d.getJSONArray("revToday").getInt(1)); } catch (JSONException e) { throw new RuntimeException(e); } }
@NonNull private static List<ObservedUri> convertJsonToObservedUris(@NonNull String contentUrisJson) { List<ObservedUri> uris = new ArrayList<>(); try { JSONObject json = new JSONObject(contentUrisJson); JSONArray jsonFlags = json.getJSONArray(JSON_URI_FLAGS); JSONArray jsonUris = json.getJSONArray(JSON_URIS); int length = jsonFlags.length(); for (int i = 0; i < length; i++) { int flags = jsonFlags.getInt(i); String uri = jsonUris.getString(i); uris.add(new ObservedUri(Uri.parse(uri), flags)); } } catch (JSONException e) { throw new RuntimeException(e); } return uris; } }
private List<Long> _fillDyn(JSONObject deck) { JSONArray terms; List<Long> ids; try { terms = deck.getJSONArray("terms").getJSONArray(0); String search = terms.getString(0); int limit = terms.getInt(1); int order = terms.getInt(2); String orderlimit = _dynOrder(order, limit); if (!TextUtils.isEmpty(search.trim())) { search = String.format(Locale.US, "(%s)", search); } search = String.format(Locale.US, "%s -is:suspended -is:buried -deck:filtered", search); ids = mCol.findCards(search, orderlimit); if (ids.isEmpty()) { return ids; } // move the cards over mCol.log(deck.getLong("id"), ids); _moveToDyn(deck.getLong("id"), ids); } catch (JSONException e) { throw new RuntimeException(e); } return ids; }
int precedence = inactivePrecedences.getInt(i); inactiveQueuesByPrecedence.put(precedence,createInactiveQueueForPrecedence(precedence,true));
public void extendLimits(int newc, int rev) { JSONObject cur = mCol.getDecks().current(); ArrayList<JSONObject> decks = new ArrayList<>(); decks.add(cur); try { decks.addAll(mCol.getDecks().parents(cur.getLong("id"))); for (long did : mCol.getDecks().children(cur.getLong("id")).values()) { decks.add(mCol.getDecks().get(did)); } for (JSONObject g : decks) { // add JSONArray ja = g.getJSONArray("newToday"); ja.put(1, ja.getInt(1) - newc); g.put("newToday", ja); ja = g.getJSONArray("revToday"); ja.put(1, ja.getInt(1) - rev); g.put("revToday", ja); mCol.getDecks().save(g); } } catch (JSONException e) { throw new RuntimeException(e); } }
byte[] array = new byte[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = (byte)jsonArray.getInt(i); short[] array = new short[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = (short)jsonArray.getInt(i); int[] array = new int[jsonArray.length()]; for (int i = 0; i < array.length; i++) { array[i] = jsonArray.getInt(i);
for (int i = 0; i < videos.length(); i++) { JSONArray jsonVideo = videos.getJSONArray(i); int vidid = jsonVideo.getInt(1); String videoURL = com.rarchives.ripme.ripper.rippers.video.VkRipper.getVideoURLAtPage( "http://vk.com/video" + oid + "_" + vidid);
final Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, reminder.getJSONArray("time").getInt(0)); calendar.set(Calendar.MINUTE, reminder.getJSONArray("time").getInt(1)); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.HOUR_OF_DAY, reminder.getJSONArray("time").getInt(0)); calendar.set(Calendar.MINUTE, reminder.getJSONArray("time").getInt(1)); calendar.set(Calendar.SECOND, 0);
jsonObject.getJSONArray(testObject.getW_byteArrayFN()).getInt(1)); Assert.assertEquals("VerifyPdxInstanceToJson: Double[] type values are not matched", testObject.getW_doubleArray()[0],
lastUsn = data.getJSONArray(data.length()-1).getInt(1); for (int i = 0; i < data.length(); i++) { int rusn = data.getJSONArray(i).getInt(1); String rsum = null; if (!data.getJSONArray(i).isNull(2)) { int processedCnt = changes.getInt(0); int serverLastUsn = changes.getInt(1); mCol.getMedia().markClean(fnames.subList(0, processedCnt));