mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-23 00:00:09 +08:00
Refactor out the Java casting code
When we return JSON to the Java side it does not have the proper methods such as Contact.save() so we need to cast the JSON to the correct JS object. This used to be done from the Java layer calling the right method to cast the JSON. In this new approach the JavaScript layer will no what needs to be cast and call it's own internal function to do the cast.
This commit is contained in:
@@ -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]);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user