1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 22:31:16 +00:00

Immediately update GUI after config was changed (fixes #355).

This commit is contained in:
Felix Ableitner 2016-02-26 00:06:49 +01:00
parent 5996e134c2
commit 90331bb7ab
4 changed files with 19 additions and 4 deletions

View file

@ -266,6 +266,7 @@ public class DeviceFragment extends Fragment implements
if (!mIsCreateMode) {
List<RestApi.Device> devices = mSyncthingService.getApi().getDevices(false);
mDevice = null;
for (int i = 0; i < devices.size(); i++) {
if (devices.get(i).deviceID.equals(
getActivity().getIntent().getStringExtra(EXTRA_NODE_ID))) {
@ -274,7 +275,7 @@ public class DeviceFragment extends Fragment implements
}
}
if (mDevice == null) {
Log.w(TAG, "Device not found in API update");
Log.w(TAG, "Device not found in API update, maybe it was deleted?");
getActivity().finish();
return;
}

View file

@ -234,6 +234,7 @@ public class FolderFragment extends Fragment
if (!mIsCreateMode) {
List<RestApi.Folder> folders = mSyncthingService.getApi().getFolders();
String passedId = getActivity().getIntent().getStringExtra(EXTRA_REPO_ID);
mFolder = null;
for (RestApi.Folder currentFolder : folders) {
if (currentFolder.id.equals(passedId)) {
mFolder = currentFolder;
@ -241,7 +242,7 @@ public class FolderFragment extends Fragment
}
}
if (mFolder == null) {
Log.w(TAG, "Folder not found in API update");
Log.w(TAG, "Folder not found in API update, maybe it was deleted?");
getActivity().finish();
return;
}

View file

@ -136,6 +136,10 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
public String invalid;
}
public interface OnConfigChangedListener {
void onConfigChanged();
}
private final Context mContext;
private String mVersion;
@ -179,14 +183,15 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
private final Map<String, String> mCacheFolderPathLookup = new HashMap<String, String>();
public RestApi(Context context, String url, String apiKey, String guiUser, String guiPassword,
OnApiAvailableListener listener) {
OnApiAvailableListener apiListener, OnConfigChangedListener configListener) {
mContext = context;
mUrl = url;
mApiKey = apiKey;
mGuiUser = guiUser;
mGuiPassword = guiPassword;
mHttpsCertPath = mContext.getFilesDir() + "/" + SyncthingService.HTTPS_CERT_FILE;
mOnApiAvailableListener = listener;
mOnApiAvailableListener = apiListener;
mOnConfigChangedListener = configListener;
}
/**
@ -205,6 +210,8 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
private final OnApiAvailableListener mOnApiAvailableListener;
private final OnConfigChangedListener mOnConfigChangedListener;
/**
* Gets local device ID, syncthing version and config, then calls all OnApiAvailableListeners.
*/
@ -348,6 +355,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
} else {
activity.startActivity(new Intent(mContext, RestartActivity.class));
}
mOnConfigChangedListener.onConfigChanged();
}
/**

View file

@ -401,6 +401,11 @@ public class SyncthingService extends Service implements
}
}).start();
}
}, new RestApi.OnConfigChangedListener() {
@Override
public void onConfigChanged() {
onApiChange();
}
});
mEventProcessor = new EventProcessor(SyncthingService.this, mApi);