This commit is contained in:
Joe Bowser 2012-02-09 15:05:30 -08:00
commit 95b9cd0229
12 changed files with 260 additions and 187 deletions

View File

@ -95,7 +95,7 @@ var Capture = function(){
* @param {CaptureAudioOptions} options
*/
Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
Cordova.exec(successCallback, errorCallback, "Capture", "captureAudio", [options]);
navigator.device.capture._capture("captureAudio", successCallback, errorCallback, options);
};
/**
@ -106,30 +106,7 @@ Capture.prototype.captureAudio = function(successCallback, errorCallback, option
* @param {CaptureImageOptions} options
*/
Capture.prototype.captureImage = function(successCallback, errorCallback, options){
Cordova.exec(successCallback, errorCallback, "Capture", "captureImage", [options]);
};
/**
* Launch camera application for taking image(s).
*
* @param {Function} successCB
* @param {Function} errorCB
* @param {CaptureImageOptions} options
*/
Capture.prototype._castMediaFile = function(pluginResult){
var mediaFiles = [];
var i;
for (i = 0; i < pluginResult.message.length; i++) {
var mediaFile = new MediaFile();
mediaFile.name = pluginResult.message[i].name;
mediaFile.fullPath = pluginResult.message[i].fullPath;
mediaFile.type = pluginResult.message[i].type;
mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
mediaFile.size = pluginResult.message[i].size;
mediaFiles.push(mediaFile);
}
pluginResult.message = mediaFiles;
return pluginResult;
navigator.device.capture._capture("captureImage", successCallback, errorCallback, options);
};
/**
@ -140,9 +117,36 @@ Capture.prototype._castMediaFile = function(pluginResult){
* @param {CaptureVideoOptions} options
*/
Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
Cordova.exec(successCallback, errorCallback, "Capture", "captureVideo", [options]);
navigator.device.capture._capture("captureVideo", successCallback, errorCallback, options);
};
/**
* Launches the correct capture.
*
* @param (DOMString} type
* @param {Function} successCB
* @param {Function} errorCB
* @param {CaptureVideoOptions} options
*/
Capture.prototype._capture = function(type, successCallback, errorCallback, options){
var win = function(result) {
var mediaFiles = [];
var i;
for (i = 0; i < pluginResult.message.length; i++) {
var mediaFile = new MediaFile();
mediaFile.name = pluginResult.message[i].name;
mediaFile.fullPath = pluginResult.message[i].fullPath;
mediaFile.type = pluginResult.message[i].type;
mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
mediaFile.size = pluginResult.message[i].size;
mediaFiles.push(mediaFile);
}
successCallback(mediaFiles);
};
Cordova.exec(win, errorCallback, "Capture", type, [options]);
};
/**
* Encapsulates a set of parameters that the capture device supports.
*/

View File

@ -73,9 +73,17 @@ Compass.prototype.getCurrentHeading = function(successCallback, errorCallback, o
console.log("Compass Error: errorCallback is not a function");
return;
}
var win = function(result) {
if (result.timestamp) {
var timestamp = new Date(result.timestamp);
result.timestamp = timestamp;
}
successCallback(result);
};
// Get heading
Cordova.exec(successCallback, errorCallback, "Compass", "getHeading", []);
Cordova.exec(win, errorCallback, "Compass", "getHeading", []);
};
/**
@ -116,7 +124,14 @@ Compass.prototype.watchHeading= function(successCallback, errorCallback, options
var id = Cordova.createUUID();
navigator.compass.timers[id] = setInterval(
function() {
Cordova.exec(successCallback, errorCallback, "Compass", "getHeading", []);
var win = function(result) {
if (result.timestamp) {
var timestamp = new Date(result.timestamp);
result.timestamp = timestamp;
}
successCallback(result);
};
Cordova.exec(win, errorCallback, "Compass", "getHeading", []);
}, (frequency ? frequency : 1));
return id;

View File

@ -259,7 +259,14 @@ Contacts.prototype.find = function(fields, successCB, errorCB, options) {
errorCB({"code": ContactError.INVALID_ARGUMENT_ERROR});
}
} else {
Cordova.exec(successCB, errorCB, "Contacts", "search", [fields, options]);
var win = function(result) {
var cs = [];
for (var i = 0, l = result.length; i < l; i++) {
cs.push(navigator.contacts.create(result[i]));
}
successCB(cs);
};
Cordova.exec(win, errorCB, "Contacts", "search", [fields, options]);
}
};
@ -281,24 +288,6 @@ Contacts.prototype.create = function(properties) {
return contact;
};
/**
* This function returns and array of contacts. It is required as we need to convert raw
* JSON objects into concrete Contact objects. Currently this method is called after
* navigator.contacts.find but before the find methods success call back.
*
* @param jsonArray an array of JSON Objects that need to be converted to Contact objects.
* @returns an array of Contact objects
*/
Contacts.prototype.cast = function(pluginResult) {
var contacts = [];
var i;
for (i=0; i<pluginResult.message.length; i++) {
contacts.push(navigator.contacts.create(pluginResult.message[i]));
}
pluginResult.message = contacts;
return pluginResult;
};
/**
* ContactFindOptions.
* @constructor

View File

@ -624,7 +624,25 @@ var DirectoryReader = function(fullPath){
* @param {Function} errorCallback is called with a FileError
*/
DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
Cordova.exec(successCallback, errorCallback, "File", "readEntries", [this.fullPath]);
var win = function(result) {
var retVal = [];
for (var i=0; i<result.length; i++) {
var entry = null;
if (result[i].isDirectory) {
entry = new DirectoryEntry();
}
else if (result[i].isFile) {
entry = new FileEntry();
}
entry.isDirectory = result[i].isDirectory;
entry.isFile = result[i].isFile;
entry.name = result[i].name;
entry.fullPath = result[i].fullPath;
retVal.push(entry);
}
successCallback(retVal);
};
Cordova.exec(win, errorCallback, "File", "readEntries", [this.fullPath]);
};
/**
@ -654,7 +672,21 @@ var DirectoryEntry = function() {
* @param {Function} errorCallback is called with a FileError
*/
DirectoryEntry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
Cordova.exec(successCallback, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
var win = function(result) {
var entry = null;
if (result.isDirectory) {
entry = new DirectoryEntry();
}
else if (result.isFile) {
entry = new FileEntry();
}
entry.isDirectory = result.isDirectory;
entry.isFile = result.isFile;
entry.name = result.name;
entry.fullPath = result.fullPath;
successCallback(entry);
};
Cordova.exec(win, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
};
/**
@ -664,7 +696,11 @@ DirectoryEntry.prototype.copyTo = function(parent, newName, successCallback, err
* @param {Function} errorCallback is called with a FileError
*/
DirectoryEntry.prototype.getMetadata = function(successCallback, errorCallback) {
Cordova.exec(successCallback, errorCallback, "File", "getMetadata", [this.fullPath]);
var win = function(result) {
result.modificationTime = new Date(result.modificationTime);
successCallback(result);
};
Cordova.exec(win, errorCallback, "File", "getMetadata", [this.fullPath]);
};
/**
@ -674,7 +710,16 @@ DirectoryEntry.prototype.getMetadata = function(successCallback, errorCallback)
* @param {Function} errorCallback is called with a FileError
*/
DirectoryEntry.prototype.getParent = function(successCallback, errorCallback) {
Cordova.exec(successCallback, errorCallback, "File", "getParent", [this.fullPath]);
var win = function(result) {
var entry = null;
entry = new DirectoryEntry();
entry.isDirectory = result.isDirectory;
entry.isFile = result.isFile;
entry.name = result.name;
entry.fullPath = result.fullPath;
successCallback(entry);
};
Cordova.exec(win, errorCallback, "File", "getParent", [this.fullPath]);
};
/**
@ -686,7 +731,21 @@ DirectoryEntry.prototype.getParent = function(successCallback, errorCallback) {
* @param {Function} errorCallback is called with a FileError
*/
DirectoryEntry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
Cordova.exec(successCallback, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
var win = function(result) {
var entry = null;
if (result.isDirectory) {
entry = new DirectoryEntry();
}
else if (result.isFile) {
entry = new FileEntry();
}
entry.isDirectory = result.isDirectory;
entry.isFile = result.isFile;
entry.name = result.name;
entry.fullPath = result.fullPath;
successCallback(entry);
};
Cordova.exec(win, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
};
/**
@ -725,7 +784,16 @@ DirectoryEntry.prototype.createReader = function(successCallback, errorCallback)
* @param {Function} errorCallback is called with a FileError
*/
DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
Cordova.exec(successCallback, errorCallback, "File", "getDirectory", [this.fullPath, path, options]);
var win = function(result) {
var entry = null;
entry = new DirectoryEntry();
entry.isDirectory = result.isDirectory;
entry.isFile = result.isFile;
entry.name = result.name;
entry.fullPath = result.fullPath;
successCallback(entry);
};
Cordova.exec(win, errorCallback, "File", "getDirectory", [this.fullPath, path, options]);
};
/**
@ -737,7 +805,16 @@ DirectoryEntry.prototype.getDirectory = function(path, options, successCallback,
* @param {Function} errorCallback is called with a FileError
*/
DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
Cordova.exec(successCallback, errorCallback, "File", "getFile", [this.fullPath, path, options]);
var win = function(result) {
var entry = null;
entry = new FileEntry();
entry.isDirectory = result.isDirectory;
entry.isFile = result.isFile;
entry.name = result.name;
entry.fullPath = result.fullPath;
successCallback(entry);
};
Cordova.exec(win, errorCallback, "File", "getFile", [this.fullPath, path, options]);
};
/**
@ -777,7 +854,21 @@ var FileEntry = function() {
* @param {Function} errorCallback is called with a FileError
*/
FileEntry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
Cordova.exec(successCallback, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
var win = function(result) {
var entry = null;
if (result.isDirectory) {
entry = new DirectoryEntry();
}
else if (result.isFile) {
entry = new FileEntry();
}
entry.isDirectory = result.isDirectory;
entry.isFile = result.isFile;
entry.name = result.name;
entry.fullPath = result.fullPath;
successCallback(entry);
};
Cordova.exec(win, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
};
/**
@ -787,7 +878,11 @@ FileEntry.prototype.copyTo = function(parent, newName, successCallback, errorCal
* @param {Function} errorCallback is called with a FileError
*/
FileEntry.prototype.getMetadata = function(successCallback, errorCallback) {
Cordova.exec(successCallback, errorCallback, "File", "getMetadata", [this.fullPath]);
var win = function(result) {
result.modificationTime = new Date(result.modificationTime);
successCallback(result);
};
Cordova.exec(win, errorCallback, "File", "getMetadata", [this.fullPath]);
};
/**
@ -797,7 +892,16 @@ FileEntry.prototype.getMetadata = function(successCallback, errorCallback) {
* @param {Function} errorCallback is called with a FileError
*/
FileEntry.prototype.getParent = function(successCallback, errorCallback) {
Cordova.exec(successCallback, errorCallback, "File", "getParent", [this.fullPath]);
var win = function(result) {
var entry = null;
entry = new DirectoryEntry();
entry.isDirectory = result.isDirectory;
entry.isFile = result.isFile;
entry.name = result.name;
entry.fullPath = result.fullPath;
successCallback(entry);
};
Cordova.exec(win, errorCallback, "File", "getParent", [this.fullPath]);
};
/**
@ -809,7 +913,21 @@ FileEntry.prototype.getParent = function(successCallback, errorCallback) {
* @param {Function} errorCallback is called with a FileError
*/
FileEntry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
Cordova.exec(successCallback, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
var win = function(result) {
var entry = null;
if (result.isDirectory) {
entry = new DirectoryEntry();
}
else if (result.isFile) {
entry = new FileEntry();
}
entry.isDirectory = result.isDirectory;
entry.isFile = result.isFile;
entry.name = result.name;
entry.fullPath = result.fullPath;
successCallback(entry);
};
Cordova.exec(win, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
};
/**
@ -863,7 +981,16 @@ FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
* @param {Function} errorCallback is called with a FileError
*/
FileEntry.prototype.file = function(successCallback, errorCallback) {
Cordova.exec(successCallback, errorCallback, "File", "getFileMetadata", [this.fullPath]);
var win = function(result) {
var file = new File();
file.size = result.size;
file.type = result.type;
file.name = result.name;
file.fullPath = result.fullPath;
file.lastModifiedDate = new Date(result.lastModifiedDate);
successCallback(file);
};
Cordova.exec(win, errorCallback, "File", "getFileMetadata", [this.fullPath]);
};
/** @constructor */
@ -892,7 +1019,20 @@ LocalFileSystem.prototype.requestFileSystem = function(type, size, successCallba
}
}
else {
Cordova.exec(successCallback, errorCallback, "File", "requestFileSystem", [type, size]);
var win = function(result){
console.log("in win of requestFileSystem");
console.log("Result: " + JSON.stringify(result));
var entry = null;
entry = new DirectoryEntry();
entry.isDirectory = result.root.isDirectory;
entry.isFile = result.root.isFile;
entry.name = result.root.name;
entry.fullPath = result.root.fullPath;
result.root = entry;
successCallback(result);
};
console.log("about to call requestFileSystem");
Cordova.exec(win, errorCallback, "File", "requestFileSystem", [type, size]);
}
};
@ -903,84 +1043,24 @@ LocalFileSystem.prototype.requestFileSystem = function(type, size, successCallba
* @param {Function} errorCallback is called with a FileError
*/
LocalFileSystem.prototype.resolveLocalFileSystemURI = function(uri, successCallback, errorCallback) {
Cordova.exec(successCallback, errorCallback, "File", "resolveLocalFileSystemURI", [uri]);
};
/**
* This function returns and array of contacts. It is required as we need to convert raw
* JSON objects into concrete Contact objects. Currently this method is called after
* navigator.service.contacts.find but before the find methods success call back.
*
* @param a JSON Objects that need to be converted to DirectoryEntry or FileEntry objects.
* @returns an entry
*/
LocalFileSystem.prototype._castFS = function(pluginResult) {
var entry = null;
entry = new DirectoryEntry();
entry.isDirectory = pluginResult.message.root.isDirectory;
entry.isFile = pluginResult.message.root.isFile;
entry.name = pluginResult.message.root.name;
entry.fullPath = pluginResult.message.root.fullPath;
pluginResult.message.root = entry;
return pluginResult;
};
LocalFileSystem.prototype._castEntry = function(pluginResult) {
var entry = null;
if (pluginResult.message.isDirectory) {
entry = new DirectoryEntry();
}
else if (pluginResult.message.isFile) {
entry = new FileEntry();
}
entry.isDirectory = pluginResult.message.isDirectory;
entry.isFile = pluginResult.message.isFile;
entry.name = pluginResult.message.name;
entry.fullPath = pluginResult.message.fullPath;
pluginResult.message = entry;
return pluginResult;
};
LocalFileSystem.prototype._castEntries = function(pluginResult) {
var entries = pluginResult.message;
var retVal = [];
for (var i=0; i<entries.length; i++) {
retVal.push(window.localFileSystem._createEntry(entries[i]));
}
pluginResult.message = retVal;
return pluginResult;
};
LocalFileSystem.prototype._createEntry = function(castMe) {
var entry = null;
if (castMe.isDirectory) {
entry = new DirectoryEntry();
}
else if (castMe.isFile) {
entry = new FileEntry();
}
entry.isDirectory = castMe.isDirectory;
entry.isFile = castMe.isFile;
entry.name = castMe.name;
entry.fullPath = castMe.fullPath;
return entry;
};
LocalFileSystem.prototype._castDate = function(pluginResult) {
if (pluginResult.message.modificationTime) {
var modTime = new Date(pluginResult.message.modificationTime);
pluginResult.message.modificationTime = modTime;
}
else if (pluginResult.message.lastModifiedDate) {
var file = new File();
file.size = pluginResult.message.size;
file.type = pluginResult.message.type;
file.name = pluginResult.message.name;
file.fullPath = pluginResult.message.fullPath;
file.lastModifiedDate = new Date(pluginResult.message.lastModifiedDate);
pluginResult.message = file;
}
return pluginResult;
var win = function(result) {
console.log("in win of resolveLocalFileSystemURI");
console.log("Result: " + JSON.stringify(result));
var entry = null;
if (result.isDirectory) {
entry = new DirectoryEntry();
}
else if (result.isFile) {
entry = new FileEntry();
}
entry.isDirectory = result.isDirectory;
entry.isFile = result.isFile;
entry.name = result.name;
entry.fullPath = result.fullPath;
successCallback(entry);
};
console.log("about to call resolveLocalFileSystemURI");
Cordova.exec(win, errorCallback, "File", "resolveLocalFileSystemURI", [uri]);
};
/**

View File

@ -91,7 +91,21 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
* @param errorCallback {Function} Callback to be invoked upon error
*/
FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) {
Cordova.exec(successCallback, errorCallback, 'FileTransfer', 'download', [source, target]);
var win = function(result) {
var entry = null;
if (result.isDirectory) {
entry = new DirectoryEntry();
}
else if (result.isFile) {
entry = new FileEntry();
}
entry.isDirectory = result.isDirectory;
entry.isFile = result.isFile;
entry.name = result.name;
entry.fullPath = result.fullPath;
successCallback(entry);
};
Cordova.exec(win, errorCallback, 'FileTransfer', 'download', [source, target]);
};
/**

View File

@ -31,14 +31,6 @@ public class PluginResult extends org.apache.cordova.api.PluginResult {
super(status, message);
}
public PluginResult(Status status, JSONArray message, String cast) {
super(status, message, cast);
}
public PluginResult(Status status, JSONObject message, String cast) {
super(status, message, cast);
}
public PluginResult(Status status, JSONArray message) {
super(status, message);
}

View File

@ -236,7 +236,7 @@ public class Capture extends Plugin {
if (results.length() >= limit) {
// Send Uri back to JavaScript for listening to audio
this.success(new PluginResult(PluginResult.Status.OK, results, "navigator.device.capture._castMediaFile"), this.callbackId);
this.success(new PluginResult(PluginResult.Status.OK, results), this.callbackId);
} else {
// still need to capture more audio clips
captureAudio();
@ -291,7 +291,7 @@ public class Capture extends Plugin {
if (results.length() >= limit) {
// Send Uri back to JavaScript for viewing image
this.success(new PluginResult(PluginResult.Status.OK, results, "navigator.device.capture._castMediaFile"), this.callbackId);
this.success(new PluginResult(PluginResult.Status.OK, results), this.callbackId);
} else {
// still need to capture more images
captureImage();
@ -308,7 +308,7 @@ public class Capture extends Plugin {
if (results.length() >= limit) {
// Send Uri back to JavaScript for viewing video
this.success(new PluginResult(PluginResult.Status.OK, results, "navigator.device.capture._castMediaFile"), this.callbackId);
this.success(new PluginResult(PluginResult.Status.OK, results), this.callbackId);
} else {
// still need to capture more video clips
captureVideo(duration);
@ -319,7 +319,7 @@ public class Capture extends Plugin {
else if (resultCode == Activity.RESULT_CANCELED) {
// If we have partial results send them back to the user
if (results.length() > 0) {
this.success(new PluginResult(PluginResult.Status.OK, results, "navigator.device.capture._castMediaFile"), this.callbackId);
this.success(new PluginResult(PluginResult.Status.OK, results), this.callbackId);
}
// user canceled the action
else {
@ -330,7 +330,7 @@ public class Capture extends Plugin {
else {
// If we have partial results send them back to the user
if (results.length() > 0) {
this.success(new PluginResult(PluginResult.Status.OK, results, "navigator.device.capture._castMediaFile"), this.callbackId);
this.success(new PluginResult(PluginResult.Status.OK, results), this.callbackId);
}
// something bad happened
else {

View File

@ -119,7 +119,7 @@ public class CompassListener extends Plugin implements SensorEventListener {
}
}
//float f = this.getHeading();
return new PluginResult(status, getCompassHeading(), "navigator.compass._castDate");
return new PluginResult(status, getCompassHeading());
}
else if (action.equals("setTimeout")) {
this.setTimeout(args.getLong(0));

View File

@ -85,7 +85,7 @@ public class ContactManager extends Plugin {
try {
if (action.equals("search")) {
JSONArray res = contactAccessor.search(args.getJSONArray(0), args.optJSONObject(1));
return new PluginResult(status, res, "navigator.contacts.cast");
return new PluginResult(status, res);
}
else if (action.equals("save")) {
String id = contactAccessor.save(args.getJSONObject(0));

View File

@ -101,7 +101,7 @@ public class FileTransfer extends Plugin {
} else if (action.equals("download")) {
JSONObject r = download(source, target);
Log.d(LOG_TAG, "****** About to return a result from download");
return new PluginResult(PluginResult.Status.OK, r, "window.localFileSystem._castEntry");
return new PluginResult(PluginResult.Status.OK, r);
} else {
return new PluginResult(PluginResult.Status.INVALID_ACTION);
}

View File

@ -137,31 +137,31 @@ public class FileUtils extends Plugin {
}
}
JSONObject obj = requestFileSystem(args.getInt(0));
return new PluginResult(status, obj, "window.localFileSystem._castFS");
return new PluginResult(status, obj);
}
else if (action.equals("resolveLocalFileSystemURI")) {
JSONObject obj = resolveLocalFileSystemURI(args.getString(0));
return new PluginResult(status, obj, "window.localFileSystem._castEntry");
return new PluginResult(status, obj);
}
else if (action.equals("getMetadata")) {
JSONObject obj = getMetadata(args.getString(0));
return new PluginResult(status, obj, "window.localFileSystem._castDate");
return new PluginResult(status, obj);
}
else if (action.equals("getFileMetadata")) {
JSONObject obj = getFileMetadata(args.getString(0));
return new PluginResult(status, obj, "window.localFileSystem._castDate");
return new PluginResult(status, obj);
}
else if (action.equals("getParent")) {
JSONObject obj = getParent(args.getString(0));
return new PluginResult(status, obj, "window.localFileSystem._castEntry");
return new PluginResult(status, obj);
}
else if (action.equals("getDirectory")) {
JSONObject obj = getFile(args.getString(0), args.getString(1), args.optJSONObject(2), true);
return new PluginResult(status, obj, "window.localFileSystem._castEntry");
return new PluginResult(status, obj);
}
else if (action.equals("getFile")) {
JSONObject obj = getFile(args.getString(0), args.getString(1), args.optJSONObject(2), false);
return new PluginResult(status, obj, "window.localFileSystem._castEntry");
return new PluginResult(status, obj);
}
else if (action.equals("remove")) {
boolean success;
@ -187,15 +187,15 @@ public class FileUtils extends Plugin {
}
else if (action.equals("moveTo")) {
JSONObject entry = transferTo(args.getString(0), args.getJSONObject(1), args.optString(2), true);
return new PluginResult(status, entry, "window.localFileSystem._castEntry");
return new PluginResult(status, entry);
}
else if (action.equals("copyTo")) {
JSONObject entry = transferTo(args.getString(0), args.getJSONObject(1), args.optString(2), false);
return new PluginResult(status, entry, "window.localFileSystem._castEntry");
return new PluginResult(status, entry);
}
else if (action.equals("readEntries")) {
JSONArray entries = readEntries(args.getString(0));
return new PluginResult(status, entries, "window.localFileSystem._castEntries");
return new PluginResult(status, entries);
}
return new PluginResult(status, result);
} catch (FileNotFoundException e) {

View File

@ -27,7 +27,6 @@ public class PluginResult {
private final int status;
private final String message;
private boolean keepCallback = false;
private String cast = null;
public PluginResult(Status status) {
this.status = status.ordinal();
@ -39,18 +38,6 @@ public class PluginResult {
this.message = JSONObject.quote(message);
}
public PluginResult(Status status, JSONArray message, String cast) {
this.status = status.ordinal();
this.message = message.toString();
this.cast = cast;
}
public PluginResult(Status status, JSONObject message, String cast) {
this.status = status.ordinal();
this.message = message.toString();
this.cast = cast;
}
public PluginResult(Status status, JSONArray message) {
this.status = status.ordinal();
this.message = message.toString();
@ -97,15 +84,7 @@ public class PluginResult {
}
public String toSuccessCallbackString(String callbackId) {
StringBuffer buf = new StringBuffer("");
if (cast != null) {
buf.append("var temp = "+cast+"("+this.getJSONString() + ");\n");
buf.append("Cordova.callbackSuccess('"+callbackId+"',temp);");
}
else {
buf.append("Cordova.callbackSuccess('"+callbackId+"',"+this.getJSONString()+");");
}
return buf.toString();
return "Cordova.callbackSuccess('"+callbackId+"',"+this.getJSONString()+");";
}
public String toErrorCallbackString(String callbackId) {