From 9ea8af4774ffcdecdfa1f44c0935ee796d83872d Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Wed, 24 Sep 2014 19:13:52 +0300 Subject: [PATCH] Do not immediately finish() activity after creating or deleting repo/node. This caused problems with restart dialogs ("activity has leaked window"). Instead, the activity is finished anyway as soon as the syncthing API becomes unavailable due to restarting. We will have to revisit this when syncthing does not need to be restarted any more. --- .../syncthingandroid/fragments/NodeSettingsFragment.java | 8 +------- .../syncthingandroid/fragments/RepoSettingsFragment.java | 2 -- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/NodeSettingsFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/NodeSettingsFragment.java index f3992c8d..d4031fbb 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/NodeSettingsFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/NodeSettingsFragment.java @@ -170,7 +170,6 @@ public class NodeSettingsFragment extends PreferenceFragment implements @Override public void onClick(DialogInterface dialogInterface, int i) { mSyncthingService.getApi().deleteNode(mNode, getActivity()); - getActivity().finish(); } }) .setNegativeButton(android.R.string.no, null) @@ -273,17 +272,12 @@ public class NodeSettingsFragment extends PreferenceFragment implements /** * Callback for {@link RestApi#editNode}. - * Displays an error message if present, or finishes the Activity on success in edit mode. - * - * @param normalizedId The normalized node ID, or null on error. - * @param error An error message, or null on success. + * Displays an error toast if error message present. */ @Override public void onNodeIdNormalized(String normalizedId, String error) { if (error != null) { Toast.makeText(getActivity(), error, Toast.LENGTH_LONG).show(); - } else if (mIsCreate) { - getActivity().finish(); } } diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/RepoSettingsFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/RepoSettingsFragment.java index 353e3f85..a721b198 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/RepoSettingsFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/RepoSettingsFragment.java @@ -190,7 +190,6 @@ public class RepoSettingsFragment extends PreferenceFragment return true; } mSyncthingService.getApi().editRepo(mRepo, true, getActivity()); - getActivity().finish(); return true; case R.id.delete: new AlertDialog.Builder(getActivity()) @@ -199,7 +198,6 @@ public class RepoSettingsFragment extends PreferenceFragment @Override public void onClick(DialogInterface dialogInterface, int i) { mSyncthingService.getApi().deleteRepo(mRepo, getActivity()); - getActivity().finish(); } }) .setNegativeButton(android.R.string.no, null)