use of org.horaapps.leafpic.data.base.ImageFileFilter in project LeafPic by HoraApps.
the class StorageProvider method checkAndAddFolder.
private void checkAndAddFolder(Context context, File dir, ArrayList<Album> albumArrayList) {
File[] files = dir.listFiles(new ImageFileFilter(includeVideo));
if (files != null && files.length > 0) {
//valid folder
Album asd = new Album(context, dir.getAbsolutePath(), -1, dir.getName(), files.length);
long lastMod = Long.MIN_VALUE;
File choice = null;
for (File file : files) {
if (file.lastModified() > lastMod) {
choice = file;
lastMod = file.lastModified();
}
}
if (choice != null)
asd.addMedia(new Media(choice.getAbsolutePath(), choice.lastModified()));
albumArrayList.add(asd);
}
}
use of org.horaapps.leafpic.data.base.ImageFileFilter in project LeafPic by HoraApps.
the class MediaStoreProvider method getHiddenAlbums.
private static ArrayList<Album> getHiddenAlbums(Context context) {
ArrayList<Album> list = new ArrayList<Album>();
String[] projection = new String[] { MediaStore.Files.FileColumns.DATA, MediaStore.Files.FileColumns.PARENT };
String selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "=" + MediaStore.Files.FileColumns.MEDIA_TYPE_NONE + " and " + MediaStore.Files.FileColumns.DATA + " LIKE '%.nomedia'";
Cursor cur = context.getContentResolver().query(MediaStore.Files.getContentUri("external"), projection, selection, null, null);
if (cur != null && cur.moveToFirst()) {
do {
File folder = new File(cur.getString(0)).getParentFile();
File[] files = folder.listFiles(new ImageFileFilter(true));
if (files != null && files.length > 0) {
Album album = new Album(context, folder.getAbsolutePath(), -1, folder.getName(), files.length);
// TODO: 21/08/16 sort and find?
long lastMod = Long.MIN_VALUE;
File f = null;
for (File file : files) {
if (file.lastModified() > lastMod) {
f = file;
lastMod = file.lastModified();
}
}
if (f != null && !isExcluded(f.getPath())) {
album.addMedia(new Media(f.getPath(), f.lastModified()));
list.add(album);
}
}
} while (cur.moveToNext());
cur.close();
}
return list;
}
use of org.horaapps.leafpic.data.base.ImageFileFilter in project LeafPic by HoraApps.
the class StorageProvider method getMedia.
public static ArrayList<Media> getMedia(String path, boolean includeVideo) {
ArrayList<Media> list = new ArrayList<Media>();
File[] images = new File(path).listFiles(new ImageFileFilter(includeVideo));
for (File image : images) list.add(new Media(image));
return list;
}