1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 03:11:30 +00:00

Fixed crash on restart.

This commit is contained in:
Felix Ableitner 2014-08-18 00:49:48 +02:00
parent 581e355366
commit 9a0cf429ae
4 changed files with 9 additions and 6 deletions

View file

@ -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();

View file

@ -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();

View file

@ -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);

View file

@ -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();
}