properly store hidden folders

This commit is contained in:
tibbi 2016-11-17 14:14:19 +01:00
parent 8c57a00947
commit 18bad5106a

View file

@ -40,35 +40,34 @@ class Config private constructor(context: Context) {
set(showHiddenFolders) = mPrefs.edit().putBoolean(SHOW_HIDDEN_FOLDERS, showHiddenFolders).apply() set(showHiddenFolders) = mPrefs.edit().putBoolean(SHOW_HIDDEN_FOLDERS, showHiddenFolders).apply()
fun addHiddenDirectory(path: String) { fun addHiddenDirectory(path: String) {
val hiddenFolders = hiddenFolders val currHiddenFolders = HashSet<String>(hiddenFolders)
hiddenFolders.add(path) currHiddenFolders.add(path)
mPrefs.edit().putStringSet(HIDDEN_FOLDERS, hiddenFolders).apply() hiddenFolders = currHiddenFolders
} }
fun addHiddenDirectories(paths: Set<String>) { fun addHiddenDirectories(paths: Set<String>) {
val hiddenFolders = hiddenFolders val currHiddenFolders = HashSet<String>(hiddenFolders)
hiddenFolders.addAll(paths) currHiddenFolders.addAll(paths)
mPrefs.edit().putStringSet(HIDDEN_FOLDERS, hiddenFolders).apply() hiddenFolders = currHiddenFolders
} }
fun removeHiddenDirectory(path: String) { fun removeHiddenDirectory(path: String) {
val hiddenFolders = hiddenFolders val currHiddenFolders = HashSet<String>(hiddenFolders)
hiddenFolders.remove(path) currHiddenFolders.remove(path)
mPrefs.edit().putStringSet(HIDDEN_FOLDERS, hiddenFolders).apply() hiddenFolders = currHiddenFolders
} }
fun removeHiddenDirectories(paths: Set<String>) { fun removeHiddenDirectories(paths: Set<String>) {
val hiddenFolders = hiddenFolders val currHiddenFolders = HashSet<String>(hiddenFolders)
hiddenFolders.removeAll(paths) currHiddenFolders.removeAll(paths)
mPrefs.edit().putStringSet(HIDDEN_FOLDERS, hiddenFolders).apply() hiddenFolders = currHiddenFolders
} }
val hiddenFolders: MutableSet<String> fun getIsFolderHidden(path: String) = hiddenFolders.contains(path)
var hiddenFolders: MutableSet<String>
get() = mPrefs.getStringSet(HIDDEN_FOLDERS, HashSet<String>()) get() = mPrefs.getStringSet(HIDDEN_FOLDERS, HashSet<String>())
set(hiddenFolders) = mPrefs.edit().remove(HIDDEN_FOLDERS).putStringSet(HIDDEN_FOLDERS, hiddenFolders).apply()
fun getIsFolderHidden(path: String): Boolean {
return hiddenFolders.contains(path)
}
var autoplayVideos: Boolean var autoplayVideos: Boolean
get() = mPrefs.getBoolean(AUTOPLAY_VIDEOS, false) get() = mPrefs.getBoolean(AUTOPLAY_VIDEOS, false)