1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-23 04:41:16 +00:00

Run all API requests in thread pool

This commit is contained in:
Felix Ableitner 2016-10-31 04:22:33 +09:00
parent 2646205620
commit ade637521e
5 changed files with 10 additions and 6 deletions

View file

@ -18,7 +18,7 @@ import javax.net.ssl.HttpsURLConnection;
* Performs a GET request with no parameters to the URL in uri[0] with the path in uri[1] and
* returns the result as a String.
*/
public class GetTask extends RestTask<Void, Void> {
public class GetTask extends RestTask {
private static final String TAG = "GetTask";

View file

@ -15,7 +15,7 @@ import javax.net.ssl.HttpsURLConnection;
/**
* Polls to load the web interface, until we receive http status 200.
*/
public class PollWebGuiAvailableTask extends RestTask<Void, Void> {
public class PollWebGuiAvailableTask extends RestTask {
private static final String TAG = "PollWebGuiAvailableTask";

View file

@ -10,7 +10,7 @@ import java.util.Collections;
import javax.net.ssl.HttpsURLConnection;
public class PostConfigTask extends RestTask<Void, Void> {
public class PostConfigTask extends RestTask {
private static final String TAG = "PostConfigTask";

View file

@ -10,7 +10,7 @@ import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
public class PostScanTask extends RestTask<Void, Void> {
public class PostScanTask extends RestTask {
private static final String TAG = "PostScanTask";

View file

@ -35,8 +35,8 @@ import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
public abstract class RestTask<Params, Progress> extends
AsyncTask<Params, Progress, Pair<Boolean, String>> {
public abstract class RestTask extends
AsyncTask<Void, Void, Pair<Boolean, String>> {
private static final String TAG = "RestTask";
@ -64,6 +64,10 @@ public abstract class RestTask<Params, Progress> extends
mListener = listener;
}
public void execute() {
super.executeOnExecutor(THREAD_POOL_EXECUTOR);
}
protected HttpsURLConnection openConnection(Map<String, String> params) throws IOException {
Uri.Builder uriBuilder = Uri.parse(mUrl.toString())
.buildUpon()