tweak sdkCall params and sdk poll interval

This commit is contained in:
Akinwale Ariwodola 2020-01-17 07:24:50 +01:00
parent 3f013d1272
commit 6aa44d8a9e
2 changed files with 11 additions and 5 deletions

View file

@ -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<String, Object> params = new HashMap<String, Object>();
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<Void, Void, String>() {
protected String doInBackground(Void... param) {
try {
Map<String, String> params = new HashMap<String, String>();
Map<String, Object> params = new HashMap<String, Object>();
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");

View file

@ -346,13 +346,13 @@ public final class Utils {
return sdkCall(method, null);
}
public static String sdkCall(String method, Map<String, String> params) throws ConnectException {
public static String sdkCall(String method, Map<String, Object> params) throws ConnectException {
try {
JSONObject request = new JSONObject();
request.put("method", method);
if (params != null) {
JSONObject requestParams = new JSONObject();
for (Map.Entry<String, String> entry : params.entrySet()) {
for (Map.Entry<String, Object> entry : params.entrySet()) {
requestParams.put(entry.getKey(), entry.getValue());
}
request.put("params", requestParams);