tweak sdkCall params and sdk poll interval
This commit is contained in:
parent
3f013d1272
commit
6aa44d8a9e
2 changed files with 11 additions and 5 deletions
|
@ -74,7 +74,7 @@ public class LbrynetService extends PythonService {
|
||||||
|
|
||||||
public static LbrynetService serviceInstance;
|
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;
|
private BroadcastReceiver stopServiceReceiver;
|
||||||
|
|
||||||
|
@ -210,7 +210,12 @@ public class LbrynetService extends PythonService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (streamManagerReady) {
|
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) {
|
if (fileList != null) {
|
||||||
JSONObject response = new JSONObject(fileList);
|
JSONObject response = new JSONObject(fileList);
|
||||||
if (!response.has("error")) {
|
if (!response.has("error")) {
|
||||||
|
@ -229,7 +234,7 @@ public class LbrynetService extends PythonService {
|
||||||
(new AsyncTask<Void, Void, String>() {
|
(new AsyncTask<Void, Void, String>() {
|
||||||
protected String doInBackground(Void... param) {
|
protected String doInBackground(Void... param) {
|
||||||
try {
|
try {
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, Object> params = new HashMap<String, Object>();
|
||||||
params.put("outpoint", outpoint);
|
params.put("outpoint", outpoint);
|
||||||
return Utils.sdkCall("file_list", params);
|
return Utils.sdkCall("file_list", params);
|
||||||
} catch (ConnectException ex) {
|
} catch (ConnectException ex) {
|
||||||
|
@ -350,6 +355,7 @@ public class LbrynetService extends PythonService {
|
||||||
// do not start a download that is considered completed
|
// do not start a download that is considered completed
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!completed && downloadPath != null) {
|
if (!completed && downloadPath != null) {
|
||||||
downloadManager.clearWrittenBytesForDownload(uri);
|
downloadManager.clearWrittenBytesForDownload(uri);
|
||||||
intent.putExtra("action", "start");
|
intent.putExtra("action", "start");
|
||||||
|
|
|
@ -346,13 +346,13 @@ public final class Utils {
|
||||||
return sdkCall(method, null);
|
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 {
|
try {
|
||||||
JSONObject request = new JSONObject();
|
JSONObject request = new JSONObject();
|
||||||
request.put("method", method);
|
request.put("method", method);
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
JSONObject requestParams = new JSONObject();
|
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());
|
requestParams.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
request.put("params", requestParams);
|
request.put("params", requestParams);
|
||||||
|
|
Loading…
Reference in a new issue