mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-23 12:51:16 +00:00
Run all API requests in thread pool
This commit is contained in:
parent
2646205620
commit
ade637521e
5 changed files with 10 additions and 6 deletions
|
@ -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
|
* 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.
|
* returns the result as a String.
|
||||||
*/
|
*/
|
||||||
public class GetTask extends RestTask<Void, Void> {
|
public class GetTask extends RestTask {
|
||||||
|
|
||||||
private static final String TAG = "GetTask";
|
private static final String TAG = "GetTask";
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import javax.net.ssl.HttpsURLConnection;
|
||||||
/**
|
/**
|
||||||
* Polls to load the web interface, until we receive http status 200.
|
* 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";
|
private static final String TAG = "PollWebGuiAvailableTask";
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import java.util.Collections;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
public class PostConfigTask extends RestTask<Void, Void> {
|
public class PostConfigTask extends RestTask {
|
||||||
|
|
||||||
private static final String TAG = "PostConfigTask";
|
private static final String TAG = "PostConfigTask";
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import java.net.URL;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
public class PostScanTask extends RestTask<Void, Void> {
|
public class PostScanTask extends RestTask {
|
||||||
|
|
||||||
private static final String TAG = "PostScanTask";
|
private static final String TAG = "PostScanTask";
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,8 @@ import javax.net.ssl.SSLSocketFactory;
|
||||||
import javax.net.ssl.TrustManager;
|
import javax.net.ssl.TrustManager;
|
||||||
import javax.net.ssl.X509TrustManager;
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
|
||||||
public abstract class RestTask<Params, Progress> extends
|
public abstract class RestTask extends
|
||||||
AsyncTask<Params, Progress, Pair<Boolean, String>> {
|
AsyncTask<Void, Void, Pair<Boolean, String>> {
|
||||||
|
|
||||||
private static final String TAG = "RestTask";
|
private static final String TAG = "RestTask";
|
||||||
|
|
||||||
|
@ -64,6 +64,10 @@ public abstract class RestTask<Params, Progress> extends
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
super.executeOnExecutor(THREAD_POOL_EXECUTOR);
|
||||||
|
}
|
||||||
|
|
||||||
protected HttpsURLConnection openConnection(Map<String, String> params) throws IOException {
|
protected HttpsURLConnection openConnection(Map<String, String> params) throws IOException {
|
||||||
Uri.Builder uriBuilder = Uri.parse(mUrl.toString())
|
Uri.Builder uriBuilder = Uri.parse(mUrl.toString())
|
||||||
.buildUpon()
|
.buildUpon()
|
||||||
|
|
Loading…
Reference in a new issue