From ade637521e3d2b65ce742381e948fbdf2cd3e48f Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 31 Oct 2016 04:22:33 +0900 Subject: [PATCH] Run all API requests in thread pool --- .../java/com/nutomic/syncthingandroid/http/GetTask.java | 2 +- .../syncthingandroid/http/PollWebGuiAvailableTask.java | 2 +- .../com/nutomic/syncthingandroid/http/PostConfigTask.java | 2 +- .../com/nutomic/syncthingandroid/http/PostScanTask.java | 2 +- .../java/com/nutomic/syncthingandroid/http/RestTask.java | 8 ++++++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/http/GetTask.java b/src/main/java/com/nutomic/syncthingandroid/http/GetTask.java index 380e15ad..8a809d5f 100644 --- a/src/main/java/com/nutomic/syncthingandroid/http/GetTask.java +++ b/src/main/java/com/nutomic/syncthingandroid/http/GetTask.java @@ -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 { +public class GetTask extends RestTask { private static final String TAG = "GetTask"; diff --git a/src/main/java/com/nutomic/syncthingandroid/http/PollWebGuiAvailableTask.java b/src/main/java/com/nutomic/syncthingandroid/http/PollWebGuiAvailableTask.java index aebd6849..149cb9ec 100644 --- a/src/main/java/com/nutomic/syncthingandroid/http/PollWebGuiAvailableTask.java +++ b/src/main/java/com/nutomic/syncthingandroid/http/PollWebGuiAvailableTask.java @@ -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 { +public class PollWebGuiAvailableTask extends RestTask { private static final String TAG = "PollWebGuiAvailableTask"; diff --git a/src/main/java/com/nutomic/syncthingandroid/http/PostConfigTask.java b/src/main/java/com/nutomic/syncthingandroid/http/PostConfigTask.java index 1091dd7b..a24a2767 100644 --- a/src/main/java/com/nutomic/syncthingandroid/http/PostConfigTask.java +++ b/src/main/java/com/nutomic/syncthingandroid/http/PostConfigTask.java @@ -10,7 +10,7 @@ import java.util.Collections; import javax.net.ssl.HttpsURLConnection; -public class PostConfigTask extends RestTask { +public class PostConfigTask extends RestTask { private static final String TAG = "PostConfigTask"; diff --git a/src/main/java/com/nutomic/syncthingandroid/http/PostScanTask.java b/src/main/java/com/nutomic/syncthingandroid/http/PostScanTask.java index d87391c8..08661a97 100644 --- a/src/main/java/com/nutomic/syncthingandroid/http/PostScanTask.java +++ b/src/main/java/com/nutomic/syncthingandroid/http/PostScanTask.java @@ -10,7 +10,7 @@ import java.net.URL; import javax.net.ssl.HttpsURLConnection; -public class PostScanTask extends RestTask { +public class PostScanTask extends RestTask { private static final String TAG = "PostScanTask"; diff --git a/src/main/java/com/nutomic/syncthingandroid/http/RestTask.java b/src/main/java/com/nutomic/syncthingandroid/http/RestTask.java index b6de5586..03ce1220 100644 --- a/src/main/java/com/nutomic/syncthingandroid/http/RestTask.java +++ b/src/main/java/com/nutomic/syncthingandroid/http/RestTask.java @@ -35,8 +35,8 @@ import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; -public abstract class RestTask extends - AsyncTask> { +public abstract class RestTask extends + AsyncTask> { private static final String TAG = "RestTask"; @@ -64,6 +64,10 @@ public abstract class RestTask extends mListener = listener; } + public void execute() { + super.executeOnExecutor(THREAD_POOL_EXECUTOR); + } + protected HttpsURLConnection openConnection(Map params) throws IOException { Uri.Builder uriBuilder = Uri.parse(mUrl.toString()) .buildUpon()