rescan invalid files at mediaactivity too
This commit is contained in:
parent
b676bc7ca4
commit
399f9ee066
|
@ -126,6 +126,7 @@ public class MediaActivity extends AppCompatActivity
|
||||||
|
|
||||||
private List<Media> getMedia() {
|
private List<Media> getMedia() {
|
||||||
final List<Media> myMedia = new ArrayList<>();
|
final List<Media> myMedia = new ArrayList<>();
|
||||||
|
final List<String> invalidFiles = new ArrayList<>();
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
|
@ -146,12 +147,18 @@ public class MediaActivity extends AppCompatActivity
|
||||||
final File file = new File(curPath);
|
final File file = new File(curPath);
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
myMedia.add(new Media(cursor.getString(pathIndex), (i == 1)));
|
myMedia.add(new Media(cursor.getString(pathIndex), (i == 1)));
|
||||||
|
} else {
|
||||||
|
invalidFiles.add(file.getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String[] invalids = invalidFiles.toArray(new String[invalidFiles.size()]);
|
||||||
|
MediaScannerConnection.scanFile(getApplicationContext(), invalids, null, null);
|
||||||
|
|
||||||
return myMedia;
|
return myMedia;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue