mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-22 20:31:16 +00:00
Fixed crash on restart.
This commit is contained in:
parent
581e355366
commit
9a0cf429ae
4 changed files with 9 additions and 6 deletions
|
@ -39,7 +39,6 @@ public class NodeSettingsFragment extends PreferenceFragment implements
|
|||
|
||||
private SyncthingService mSyncthingService;
|
||||
|
||||
// FIXME: is null
|
||||
private RestApi.Node mNode;
|
||||
|
||||
private Preference mNodeId;
|
||||
|
@ -93,11 +92,13 @@ public class NodeSettingsFragment extends PreferenceFragment implements
|
|||
@Override
|
||||
public void onApiChange(SyncthingService.State currentState) {
|
||||
if (currentState != SyncthingService.State.ACTIVE) {
|
||||
SyncthingService.showDisabledDialog(getActivity());
|
||||
getActivity().finish();
|
||||
return;
|
||||
}
|
||||
|
||||
if (getActivity() == null || getActivity().isFinishing())
|
||||
return;
|
||||
|
||||
if (mIsCreate) {
|
||||
getActivity().setTitle(R.string.add_node);
|
||||
mNode = new RestApi.Node();
|
||||
|
|
|
@ -52,7 +52,6 @@ public class RepoSettingsFragment extends PreferenceFragment
|
|||
|
||||
private SyncthingService mSyncthingService;
|
||||
|
||||
// FIXME: is null
|
||||
private RestApi.Repo mRepo;
|
||||
|
||||
private EditTextPreference mRepoId;
|
||||
|
@ -102,11 +101,13 @@ public class RepoSettingsFragment extends PreferenceFragment
|
|||
@Override
|
||||
public void onApiChange(SyncthingService.State currentState) {
|
||||
if (currentState != SyncthingService.State.ACTIVE) {
|
||||
SyncthingService.showDisabledDialog(getActivity());
|
||||
getActivity().finish();
|
||||
return;
|
||||
}
|
||||
|
||||
if (getActivity() == null || getActivity().isFinishing())
|
||||
return;
|
||||
|
||||
if (mIsCreate) {
|
||||
getActivity().setTitle(R.string.create_repo);
|
||||
mRepo = new RestApi.Repo();
|
||||
|
|
|
@ -739,7 +739,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener {
|
|||
/**
|
||||
* Updates or creates the given node.
|
||||
*/
|
||||
public void editRepo(Repo repo, boolean create, Activity activity) {
|
||||
public void editRepo(Repo repo, boolean create, Context context) {
|
||||
try {
|
||||
JSONArray repos = mConfig.getJSONArray("Repositories");
|
||||
JSONObject r = null;
|
||||
|
@ -777,7 +777,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener {
|
|||
params.put(key, repo.Versioning.getParams().get(key));
|
||||
}
|
||||
r.put("Versioning", versioning);
|
||||
configUpdated(activity);
|
||||
configUpdated(context);
|
||||
}
|
||||
catch (JSONException e) {
|
||||
Log.w(TAG, "Failed to edit repo " + repo.ID + " at " + repo.Directory, e);
|
||||
|
|
|
@ -131,6 +131,7 @@ public class SyncthingService extends Service {
|
|||
ConfigXml config = new ConfigXml(SyncthingService.this);
|
||||
mApi = new RestApi(SyncthingService.this,
|
||||
config.getWebGuiUrl(), config.getApiKey());
|
||||
mCurrentState = State.STARTING;
|
||||
registerOnWebGuiAvailableListener(mApi);
|
||||
new PollWebGuiAvailableTask().execute();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue