allow toggling the visibility of multiple folders at once
This commit is contained in:
parent
c0a430c839
commit
e51ff13da7
|
@ -77,12 +77,24 @@ public class Config {
|
|||
mPrefs.edit().putStringSet(Constants.HIDDEN_FOLDERS, hiddenFolders).apply();
|
||||
}
|
||||
|
||||
public void addHiddenDirectories(Set<String> paths) {
|
||||
final Set<String> hiddenFolders = getHiddenFolders();
|
||||
hiddenFolders.addAll(paths);
|
||||
mPrefs.edit().putStringSet(Constants.HIDDEN_FOLDERS, hiddenFolders).apply();
|
||||
}
|
||||
|
||||
public void removeHiddenDirectory(String path) {
|
||||
final Set<String> hiddenFolders = getHiddenFolders();
|
||||
hiddenFolders.remove(path);
|
||||
mPrefs.edit().putStringSet(Constants.HIDDEN_FOLDERS, hiddenFolders).apply();
|
||||
}
|
||||
|
||||
public void removeHiddenDirectories(Set<String> paths) {
|
||||
final Set<String> hiddenFolders = getHiddenFolders();
|
||||
hiddenFolders.removeAll(paths);
|
||||
mPrefs.edit().putStringSet(Constants.HIDDEN_FOLDERS, hiddenFolders).apply();
|
||||
}
|
||||
|
||||
public Set<String> getHiddenFolders() {
|
||||
return mPrefs.getStringSet(Constants.HIDDEN_FOLDERS, new HashSet<String>());
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import java.io.File;
|
|||
import java.io.FilenameFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -629,13 +630,28 @@ public class MainActivity extends SimpleActivity
|
|||
}
|
||||
|
||||
private void hideFolders() {
|
||||
mConfig.addHiddenDirectories(getSelectedPaths());
|
||||
initializeGallery();
|
||||
}
|
||||
|
||||
private void unhideFolders() {
|
||||
mConfig.removeHiddenDirectories(getSelectedPaths());
|
||||
initializeGallery();
|
||||
}
|
||||
|
||||
private Set<String> getSelectedPaths() {
|
||||
final SparseBooleanArray items = mGridView.getCheckedItemPositions();
|
||||
final Set<String> selectedPaths = new HashSet<>();
|
||||
final int cnt = items.size();
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
if (items.valueAt(i)) {
|
||||
final int id = items.keyAt(i);
|
||||
selectedPaths.add(mDirs.get(id).getPath());
|
||||
}
|
||||
}
|
||||
return selectedPaths;
|
||||
}
|
||||
|
||||
private void scanCompleted(final String path) {
|
||||
final File dir = new File(path);
|
||||
if (dir.isDirectory()) {
|
||||
|
|
Loading…
Reference in New Issue