Added return value 'dir' as the path of the downloaded file.

Changed the default download path from hard-coded '/sdcard/download' to Environment.getExternalStorageDirectory().getPath() + "/download";
This commit is contained in:
snufkinto
2012-05-29 16:33:57 +08:00
parent cf80054044
commit cd870abc01

View File

@@ -75,6 +75,7 @@ public class Downloader extends Plugin {
obj.put("status", 1);
obj.put("total", 0);
obj.put("file", fileName);
obj.put("dir", dirName);
obj.put("progress", 100);
return new PluginResult(PluginResult.Status.OK, obj);
@@ -104,7 +105,7 @@ public class Downloader extends Plugin {
int newProgress = (int) (totalReaded*100/fileSize);
if (newProgress != progress)
progress = informProgress(fileSize, newProgress, fileName, callbackId);
progress = informProgress(fileSize, newProgress, dirName, fileName, callbackId);
}
@@ -132,12 +133,13 @@ public class Downloader extends Plugin {
}
private int informProgress(int fileSize, int progress, String fileName, String callbackId) throws InterruptedException, JSONException {
private int informProgress(int fileSize, int progress, String dirName, String fileName, String callbackId) throws InterruptedException, JSONException {
JSONObject obj = new JSONObject();
obj.put("status", 0);
obj.put("total", fileSize);
obj.put("file", fileName);
obj.put("dir", dirName);
obj.put("progress", progress);
PluginResult res = new PluginResult(PluginResult.Status.OK, obj);