mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
ignore folders which contain .nomedia
This commit is contained in:
parent
301f14acdb
commit
cff90e1e8b
1 changed files with 22 additions and 0 deletions
|
@ -37,6 +37,7 @@ import com.simplemobiletools.gallery.dialogs.ChangeSorting;
|
||||||
import com.simplemobiletools.gallery.models.Directory;
|
import com.simplemobiletools.gallery.models.Directory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FilenameFilter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
@ -227,6 +228,7 @@ public class MainActivity extends SimpleActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Directory> dirs = new ArrayList<>(directories.values());
|
final List<Directory> dirs = new ArrayList<>(directories.values());
|
||||||
|
removeNoMediaDirs(dirs);
|
||||||
Directory.mSorting = mConfig.getDirectorySorting();
|
Directory.mSorting = mConfig.getDirectorySorting();
|
||||||
Collections.sort(dirs);
|
Collections.sort(dirs);
|
||||||
|
|
||||||
|
@ -236,6 +238,26 @@ public class MainActivity extends SimpleActivity
|
||||||
return dirs;
|
return dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeNoMediaDirs(List<Directory> dirs) {
|
||||||
|
final List<Directory> ignoreDirs = new ArrayList<>();
|
||||||
|
for (final Directory d : dirs) {
|
||||||
|
final File dir = new File(d.getPath());
|
||||||
|
if (dir.exists() && dir.isDirectory()) {
|
||||||
|
final String[] res = dir.list(new FilenameFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean accept(File file, String filename) {
|
||||||
|
return filename.equals(".nomedia");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.length > 0)
|
||||||
|
ignoreDirs.add(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dirs.removeAll(ignoreDirs);
|
||||||
|
}
|
||||||
|
|
||||||
// sort the files at querying too, just to get the correct thumbnail
|
// sort the files at querying too, just to get the correct thumbnail
|
||||||
private String getSortOrder() {
|
private String getSortOrder() {
|
||||||
final int sorting = mConfig.getDirectorySorting();
|
final int sorting = mConfig.getDirectorySorting();
|
||||||
|
|
Loading…
Reference in a new issue