use of org.json.JSONObject in project baker-android by bakerframework.
the class BasicResult method errorJson.
public JSONObject errorJson(final String value) throws JSONException {
JSONObject json = new JSONObject();
json.put("type", "error");
json.put("value", value);
return json;
}
use of org.json.JSONObject in project baker-android by bakerframework.
the class BasicResult method toJson.
public JSONObject toJson() throws JSONException {
JSONObject json = new JSONObject();
json.put("type", this.type);
json.put("value", this.value);
return json;
}
use of org.json.JSONObject in project baker-android by bakerframework.
the class BookJson method fromJson.
public void fromJson(final String jsonString) throws JSONException, ParseException {
JSONObject json = new JSONObject(jsonString);
if (json.has("liveUrl")) {
this.liveUrl = json.getString("liveUrl");
}
// SimpleDateFormat sdfInput = new SimpleDateFormat("yyyy-MM-dd",
// Locale.US);
// The other properties are commented by now, as we are not gonna use them yet.
this.hpub = json.optString("hpub", "1");
this.title = json.optString("title", "");
// this.date = sdfInput.parse(json.getString("date"));
this.url = json.optString("url", "");
this.cover = json.optString("cover", "");
this.orientation = json.optString("orientation", "PORTRAIT");
// this.zoomable = json.getBoolean("zoomable");
// JSONArray authors = new JSONArray(json.getString("author"));
// JSONArray creators = new JSONArray(json.getString("creator"));
JSONArray contents = new JSONArray(json.getString("contents"));
// this.authors = new ArrayList<String>();
// this.creators = new ArrayList<String>();
this.contents = new ArrayList<String>();
for (int i = 0; i < contents.length(); i++) {
this.contents.add(contents.getString(i));
}
}
use of org.json.JSONObject in project cordova-android-chromeview by thedracle.
the class Capture method createMediaFile.
/**
* Creates a JSONObject that represents a File from the Uri
*
* @param data the Uri of the audio/image/video
* @return a JSONObject that represents a File
* @throws IOException
*/
private JSONObject createMediaFile(Uri data) {
File fp = new File(FileHelper.getRealPath(data, this.cordova));
JSONObject obj = new JSONObject();
try {
// File properties
obj.put("name", fp.getName());
obj.put("fullPath", "file://" + fp.getAbsolutePath());
// is stored in the audio or video content store.
if (fp.getAbsoluteFile().toString().endsWith(".3gp") || fp.getAbsoluteFile().toString().endsWith(".3gpp")) {
if (data.toString().contains("/audio/")) {
obj.put("type", AUDIO_3GPP);
} else {
obj.put("type", VIDEO_3GPP);
}
} else {
obj.put("type", FileHelper.getMimeType(fp.getAbsolutePath(), cordova));
}
obj.put("lastModifiedDate", fp.lastModified());
obj.put("size", fp.length());
} catch (JSONException e) {
// this will never happen
e.printStackTrace();
}
return obj;
}
use of org.json.JSONObject in project cordova-android-chromeview by thedracle.
the class Capture method getFormatData.
/**
* Provides the media data file data depending on it's mime type
*
* @param filePath path to the file
* @param mimeType of the file
* @return a MediaFileData object
*/
private JSONObject getFormatData(String filePath, String mimeType) throws JSONException {
JSONObject obj = new JSONObject();
// setup defaults
obj.put("height", 0);
obj.put("width", 0);
obj.put("bitrate", 0);
obj.put("duration", 0);
obj.put("codecs", "");
// so let's see if we can determine it.
if (mimeType == null || mimeType.equals("") || "null".equals(mimeType)) {
mimeType = FileHelper.getMimeType(filePath, cordova);
}
Log.d(LOG_TAG, "Mime type = " + mimeType);
if (mimeType.equals(IMAGE_JPEG) || filePath.endsWith(".jpg")) {
obj = getImageData(filePath, obj);
} else if (mimeType.endsWith(AUDIO_3GPP)) {
obj = getAudioVideoData(filePath, obj, false);
} else if (mimeType.equals(VIDEO_3GPP) || mimeType.equals(VIDEO_MP4)) {
obj = getAudioVideoData(filePath, obj, true);
}
return obj;
}
Aggregations