use of org.json.JSONObject in project glide by bumptech.
the class PhotoJsonStringParser method parse.
List<Photo> parse(String response) throws JSONException {
JSONObject searchResults = new JSONObject(response.substring(FLICKR_API_PREFIX_LENGTH, response.length() - 1));
JSONArray photos = searchResults.getJSONObject("photos").getJSONArray("photo");
List<Photo> results = new ArrayList<>(photos.length());
for (int i = 0, size = photos.length(); i < size; i++) {
results.add(new Photo(photos.getJSONObject(i)));
}
return results;
}
use of org.json.JSONObject in project clutchandroid by clutchio.
the class ClutchStats method testFailure.
public void testFailure(String name, String type) {
JSONObject data = new JSONObject();
try {
data.put("action", "failure");
data.put("name", name);
data.put("type", type);
} catch (JSONException e) {
Log.e(TAG, "Could not create JSON for insert into testFailure (name: " + name + ", type: " + type + ")");
return;
}
logABData(data);
}
use of org.json.JSONObject in project clutchandroid by clutchio.
the class ClutchStats method logAction.
public void logAction(String action, Map<String, ?> data) {
SQLiteDatabase db = getWritableDatabase();
Object[] args = { ClutchUtils.getUUID(), System.currentTimeMillis() / 1000.0, action, new JSONObject(data).toString() };
db.execSQL("INSERT INTO stats (uuid, ts, action, data) VALUES (?, ?, ?, ?)", args);
db.close();
}
use of org.json.JSONObject in project clutchandroid by clutchio.
the class ClutchStats method goalReached.
public void goalReached(String name) {
JSONObject data = new JSONObject();
try {
data.put("action", "goal");
data.put("name", name);
} catch (JSONException e) {
Log.e(TAG, "Could not create JSON for insert into goalReached (name: " + name + ")");
return;
}
logABData(data);
}
use of org.json.JSONObject in project clutchandroid by clutchio.
the class ClutchStats method testChosen.
public void testChosen(String name, int choice, int numChoices) {
JSONObject data = new JSONObject();
try {
data.put("action", "test");
data.put("name", name);
data.put("choice", choice);
data.put("num_choices", numChoices);
} catch (JSONException e) {
Log.e(TAG, "Could not create JSON for insert into testChosen (name: " + name + ", choice: " + choice + ", numChoies: " + numChoices + ")");
return;
}
logABData(data);
}
Aggregations