mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 06:11:19 +00:00
Re-organized URI handling.
This commit is contained in:
parent
ef8b424500
commit
c53c907a02
4 changed files with 14 additions and 12 deletions
|
@ -30,7 +30,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
? versionName
|
||||
: getString(R.string.syncthing_version_error));
|
||||
}
|
||||
}.execute(SyncthingService.SYNCTHING_URL + SyncthingService.PATH_VERSION);
|
||||
}.execute(GetTask.URI_VERSION);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,11 @@ public class GetTask extends AsyncTask<String, Void, String> {
|
|||
|
||||
private static final String TAG = "GetTask";
|
||||
|
||||
/**
|
||||
* URI to call to get version name.
|
||||
*/
|
||||
public static final String URI_VERSION = SyncthingService.SYNCTHING_URL + "/rest/version";
|
||||
|
||||
@Override
|
||||
protected String doInBackground(String... uri) {
|
||||
HttpClient httpclient = new DefaultHttpClient();
|
||||
|
|
|
@ -4,6 +4,8 @@ package com.nutomic.syncthingandroid;
|
|||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import com.nutomic.syncthingandroid.service.SyncthingService;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
|
@ -18,6 +20,11 @@ public class PostTask extends AsyncTask<String, Void, Void> {
|
|||
|
||||
private static final String TAG = "PostTask";
|
||||
|
||||
/**
|
||||
* URI to call for shutdown.
|
||||
*/
|
||||
public static final String URI_SHUTDOWN = SyncthingService.SYNCTHING_URL + "/rest/shutdown";
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(String... uri) {
|
||||
HttpClient httpclient = new DefaultHttpClient();
|
||||
|
|
|
@ -37,16 +37,6 @@ public class SyncthingService extends Service {
|
|||
*/
|
||||
public static final String SYNCTHING_URL = "http://127.0.0.1:8080";
|
||||
|
||||
/**
|
||||
* Path to call for shutdown (with POST).
|
||||
*/
|
||||
private static final String PATH_SHUTDOWN = "/rest/shutdown";
|
||||
|
||||
/**
|
||||
* Path to call to get version name (with GET).
|
||||
*/
|
||||
public static final String PATH_VERSION = "/rest/version";
|
||||
|
||||
private final SyncthingServiceBinder mBinder = new SyncthingServiceBinder(this);
|
||||
|
||||
@Override
|
||||
|
@ -133,7 +123,7 @@ public class SyncthingService extends Service {
|
|||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
new PostTask().execute(SYNCTHING_URL + PATH_SHUTDOWN);
|
||||
new PostTask().execute(PostTask.URI_SHUTDOWN);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue