From 2b360dab5431f713118d719520df9294aaf51002 Mon Sep 17 00:00:00 2001 From: Catfriend1 Date: Sat, 16 Jun 2018 15:25:36 +0200 Subject: [PATCH] FolderActivity - fix NPE - don't update if removed (fixes #1143) --- .../syncthingandroid/activities/FolderActivity.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java index 5cfb9b10..8c58461f 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java @@ -29,6 +29,7 @@ import com.google.gson.Gson; import com.nutomic.syncthingandroid.R; import com.nutomic.syncthingandroid.model.Device; import com.nutomic.syncthingandroid.model.Folder; +import com.nutomic.syncthingandroid.service.RestApi; import com.nutomic.syncthingandroid.service.SyncthingService; import com.nutomic.syncthingandroid.util.TextWatcherAdapter; import com.nutomic.syncthingandroid.util.Util; @@ -85,7 +86,7 @@ public class FolderActivity extends SyncthingActivity private TextView mEditIgnores; private boolean mIsCreateMode; - private boolean mFolderNeedsToUpdate; + private boolean mFolderNeedsToUpdate = false; private Dialog mDeleteDialog; private Dialog mDiscardDialog; @@ -403,7 +404,11 @@ public class FolderActivity extends SyncthingActivity return new AlertDialog.Builder(this) .setMessage(R.string.remove_folder_confirm) .setPositiveButton(android.R.string.yes, (dialogInterface, i) -> { - getApi().removeFolder(mFolder.id); + RestApi restApi = getApi(); + if (restApi != null) { + restApi.removeFolder(mFolder.id); + } + mFolderNeedsToUpdate = false; finish(); }) .setNegativeButton(android.R.string.no, null)