From 2c86b0fb1c489d36f53017cf162655a300d4425f Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 3 Mar 2016 20:31:42 +0100 Subject: [PATCH] hide the snackbar when paused too --- .../gallery/activities/PhotosActivity.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotosActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotosActivity.java index d245fba1d..d06dbbb91 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotosActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotosActivity.java @@ -60,6 +60,12 @@ public class PhotosActivity extends AppCompatActivity tryloadGallery(); } + @Override + protected void onPause() { + super.onPause(); + deleteFiles(); + } + private void tryloadGallery() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { initializeGallery(); @@ -148,7 +154,6 @@ public class PhotosActivity extends AppCompatActivity toBeDeleted.add(photos.get(id)); } - notifyDeletion(toBeDeleted.size()); MediaScannerConnection.scanFile(this, new String[]{path}, null, this); } @@ -163,6 +168,12 @@ public class PhotosActivity extends AppCompatActivity } private void deleteFiles() { + if (snackbar == null) + return; + + snackbar.dismiss(); + isSnackbarShown = false; + for (String delPath : toBeDeleted) { final File file = new File(delPath); if (file.exists()) @@ -242,6 +253,7 @@ public class PhotosActivity extends AppCompatActivity @Override public void run() { updateGridView(); + notifyDeletion(toBeDeleted.size()); } }); } @@ -250,8 +262,6 @@ public class PhotosActivity extends AppCompatActivity public boolean onTouch(View v, MotionEvent event) { if (isSnackbarShown) { deleteFiles(); - snackbar.dismiss(); - isSnackbarShown = false; } return false;