diff --git a/src/main/java/io/lbry/browser/LbrynetService.java b/src/main/java/io/lbry/browser/LbrynetService.java index 33c0583..40592cd 100644 --- a/src/main/java/io/lbry/browser/LbrynetService.java +++ b/src/main/java/io/lbry/browser/LbrynetService.java @@ -74,7 +74,7 @@ public class LbrynetService extends PythonService { public static LbrynetService serviceInstance; - private static final int SDK_POLL_INTERVAL = 500; // 500 milliseconds + private static final int SDK_POLL_INTERVAL = 1000; // 1 second private BroadcastReceiver stopServiceReceiver; @@ -210,7 +210,12 @@ public class LbrynetService extends PythonService { } if (streamManagerReady) { - String fileList = Utils.sdkCall("file_list"); + Map params = new HashMap(); + params.put("page_size", 100); + params.put("reverse", true); + params.put("sort", "added_on"); + + String fileList = Utils.sdkCall("file_list", params); if (fileList != null) { JSONObject response = new JSONObject(fileList); if (!response.has("error")) { @@ -229,7 +234,7 @@ public class LbrynetService extends PythonService { (new AsyncTask() { protected String doInBackground(Void... param) { try { - Map params = new HashMap(); + Map params = new HashMap(); params.put("outpoint", outpoint); return Utils.sdkCall("file_list", params); } catch (ConnectException ex) { @@ -350,6 +355,7 @@ public class LbrynetService extends PythonService { // do not start a download that is considered completed continue; } + if (!completed && downloadPath != null) { downloadManager.clearWrittenBytesForDownload(uri); intent.putExtra("action", "start"); diff --git a/src/main/java/io/lbry/browser/Utils.java b/src/main/java/io/lbry/browser/Utils.java index c35b94b..cf53899 100644 --- a/src/main/java/io/lbry/browser/Utils.java +++ b/src/main/java/io/lbry/browser/Utils.java @@ -346,13 +346,13 @@ public final class Utils { return sdkCall(method, null); } - public static String sdkCall(String method, Map params) throws ConnectException { + public static String sdkCall(String method, Map params) throws ConnectException { try { JSONObject request = new JSONObject(); request.put("method", method); if (params != null) { JSONObject requestParams = new JSONObject(); - for (Map.Entry entry : params.entrySet()) { + for (Map.Entry entry : params.entrySet()) { requestParams.put(entry.getKey(), entry.getValue()); } request.put("params", requestParams);