Skip to content

Commit

Permalink
rescan invalid files at mediaactivity too
Browse files Browse the repository at this point in the history
  • Loading branch information
tibbi committed Jun 5, 2016
1 parent b676bc7 commit 399f9ee
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ private void deleteDirectoryIfEmpty() {

private List<Media> getMedia() {
final List<Media> myMedia = new ArrayList<>();
final List<String> invalidFiles = new ArrayList<>();
for (int i = 0; i < 2; i++) {
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
if (i == 1) {
Expand All @@ -146,12 +147,18 @@ private List<Media> getMedia() {
final File file = new File(curPath);
if (file.exists()) {
myMedia.add(new Media(cursor.getString(pathIndex), (i == 1)));
} else {
invalidFiles.add(file.getAbsolutePath());
}
}
} while (cursor.moveToNext());
cursor.close();
}
}

final String[] invalids = invalidFiles.toArray(new String[invalidFiles.size()]);
MediaScannerConnection.scanFile(getApplicationContext(), invalids, null, null);

return myMedia;
}

Expand Down

0 comments on commit 399f9ee

Please sign in to comment.