From 09e4f00f27088dc7a8b5e54a38fa49fc74f43afa Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 5 Mar 2016 21:57:10 +0100 Subject: [PATCH] scan only the affected items on Delete --- .../gallery/activities/PhotosActivity.java | 3 ++- .../gallery/activities/ViewPagerActivity.java | 6 ++++-- 2 files changed, 6 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 494ac1ce7..6eb884e9b 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotosActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotosActivity.java @@ -183,7 +183,8 @@ public class PhotosActivity extends AppCompatActivity file.delete(); } - MediaScannerConnection.scanFile(this, new String[]{path}, null, null); + final String[] deletedPaths = toBeDeleted.toArray(new String[toBeDeleted.size()]); + MediaScannerConnection.scanFile(this, deletedPaths, null, null); } private View.OnClickListener undoDeletion = new View.OnClickListener() { diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java index d5b596bb6..00f586c2e 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java @@ -102,8 +102,10 @@ public class ViewPagerActivity extends AppCompatActivity private void deleteImage() { Helpers.showToast(this, R.string.deleting); final File file = getCurrentFile(); - file.delete(); - MediaScannerConnection.scanFile(this, new String[]{path}, null, this); + if (file.delete()) { + final String[] deletedPath = new String[]{file.getAbsolutePath()}; + MediaScannerConnection.scanFile(this, deletedPath, null, this); + } } private boolean isDirEmpty() {