From 131f0647a9fcc42cc867fb78bf0b9ebbe97f7047 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 24 Aug 2016 23:26:52 +0200 Subject: [PATCH] rescan all files in directory on open - related to #18, #16 --- .../gallery/activities/MediaActivity.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java index c66deeaa2..3682dadc0 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java @@ -112,6 +112,8 @@ public class MediaActivity extends SimpleActivity return; } + rescanDirectory(); + mMedia = newMedia; if (isDirEmpty()) return; @@ -144,6 +146,19 @@ public class MediaActivity extends SimpleActivity } } + private void rescanDirectory() { + final File file = new File(mPath); + if (file.isDirectory()) { + final File[] files = file.listFiles(); + final String[] paths = new String[files.length]; + final int cnt = file.listFiles().length; + for (int i = 0; i < cnt; i++) { + paths[i] = files[i].getPath(); + } + MediaScannerConnection.scanFile(getApplicationContext(), paths, null, null); + } + } + private void showSortingDialog() { new ChangeSorting(this, false); }