mirror of
https://github.com/purplecabbage/phonegap-plugins.git
synced 2026-04-24 03:00:11 -04:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user