Search in sources :

Example 1 with PostConfigRequest

use of com.nutomic.syncthingandroid.http.PostConfigRequest in project syncthing-android by syncthing.

the class RestApi method saveConfigAndRestart.

/**
 * Sends current config and restarts Syncthing.
 */
public void saveConfigAndRestart() {
    String jsonConfig;
    synchronized (mConfigLock) {
        jsonConfig = new Gson().toJson(mConfig);
    }
    new PostConfigRequest(mContext, mUrl, mApiKey, jsonConfig, result -> {
        Intent intent = new Intent(mContext, SyncthingService.class).setAction(SyncthingService.ACTION_RESTART);
        mContext.startService(intent);
    });
    mOnConfigChangedListener.onConfigChanged();
}
Also used : Gson(com.google.gson.Gson) Intent(android.content.Intent) PostConfigRequest(com.nutomic.syncthingandroid.http.PostConfigRequest)

Example 2 with PostConfigRequest

use of com.nutomic.syncthingandroid.http.PostConfigRequest in project syncthing-android by syncthing.

the class RestApi method restart.

/**
 * Sends current config and restarts Syncthing.
 */
public void restart() {
    new PostConfigRequest(mContext, mUrl, mApiKey, new Gson().toJson(mConfig), result -> {
        Intent intent = new Intent(mContext, SyncthingService.class).setAction(SyncthingService.ACTION_RESTART);
        mContext.startService(intent);
    });
}
Also used : Gson(com.google.gson.Gson) Intent(android.content.Intent) PostConfigRequest(com.nutomic.syncthingandroid.http.PostConfigRequest)

Aggregations

Intent (android.content.Intent)2 Gson (com.google.gson.Gson)2 PostConfigRequest (com.nutomic.syncthingandroid.http.PostConfigRequest)2