update some functions related to pinning and hiding folders
This commit is contained in:
parent
b5b4e15990
commit
0857391189
3 changed files with 30 additions and 22 deletions
|
@ -116,11 +116,11 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
true
|
||||
}
|
||||
R.id.hide_folder -> {
|
||||
hideDirectory()
|
||||
hideFolder()
|
||||
true
|
||||
}
|
||||
R.id.unhide_folder -> {
|
||||
unhideDirectory()
|
||||
unhideFolder()
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
|
@ -138,8 +138,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
}
|
||||
}
|
||||
|
||||
private fun hideDirectory() {
|
||||
mConfig.addHiddenDirectory(mPath)
|
||||
private fun hideFolder() {
|
||||
mConfig.addHiddenFolder(mPath)
|
||||
|
||||
if (!mConfig.showHiddenFolders)
|
||||
finish()
|
||||
|
@ -147,8 +147,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
private fun unhideDirectory() {
|
||||
mConfig.removeHiddenDirectory(mPath)
|
||||
private fun unhideFolder() {
|
||||
mConfig.removeHiddenFolder(mPath)
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
|
|
|
@ -78,12 +78,12 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
true
|
||||
}
|
||||
R.id.cab_hide -> {
|
||||
hideDirs()
|
||||
hideFolders()
|
||||
mode.finish()
|
||||
true
|
||||
}
|
||||
R.id.cab_unhide -> {
|
||||
unhideDir()
|
||||
unhideFolders()
|
||||
mode.finish()
|
||||
true
|
||||
}
|
||||
|
@ -163,13 +163,13 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
}
|
||||
}
|
||||
|
||||
private fun hideDirs() {
|
||||
config.addHiddenDirectories(getSelectedPaths())
|
||||
private fun hideFolders() {
|
||||
config.addHiddenFolders(getSelectedPaths())
|
||||
listener?.refreshItems()
|
||||
}
|
||||
|
||||
private fun unhideDir() {
|
||||
config.removeHiddenDirectories(getSelectedPaths())
|
||||
private fun unhideFolders() {
|
||||
config.removeHiddenFolders(getSelectedPaths())
|
||||
listener?.refreshItems()
|
||||
}
|
||||
|
||||
|
|
|
@ -43,25 +43,33 @@ class Config private constructor(context: Context) {
|
|||
get() = mPrefs.getStringSet(PINNED_FOLDERS, HashSet<String>())
|
||||
set(pinnedFolders) = mPrefs.edit().putStringSet(PINNED_FOLDERS, pinnedFolders).apply()
|
||||
|
||||
fun addHiddenDirectory(path: String) {
|
||||
val currHiddenFolders = HashSet<String>(hiddenFolders)
|
||||
currHiddenFolders.add(path)
|
||||
hiddenFolders = currHiddenFolders
|
||||
fun addPinnedFolders(paths: Set<String>) {
|
||||
val currPinnedFolders = HashSet<String>(pinnedFolders)
|
||||
currPinnedFolders.addAll(paths)
|
||||
pinnedFolders = currPinnedFolders
|
||||
}
|
||||
|
||||
fun addHiddenDirectories(paths: Set<String>) {
|
||||
fun removePinnedFolders(paths: Set<String>) {
|
||||
val currPinnedFolders = HashSet<String>(pinnedFolders)
|
||||
currPinnedFolders.removeAll(paths)
|
||||
pinnedFolders = currPinnedFolders
|
||||
}
|
||||
|
||||
fun addHiddenFolder(path: String) {
|
||||
addHiddenFolders(HashSet<String>(Arrays.asList(path)))
|
||||
}
|
||||
|
||||
fun addHiddenFolders(paths: Set<String>) {
|
||||
val currHiddenFolders = HashSet<String>(hiddenFolders)
|
||||
currHiddenFolders.addAll(paths)
|
||||
hiddenFolders = currHiddenFolders
|
||||
}
|
||||
|
||||
fun removeHiddenDirectory(path: String) {
|
||||
val currHiddenFolders = HashSet<String>(hiddenFolders)
|
||||
currHiddenFolders.remove(path)
|
||||
hiddenFolders = currHiddenFolders
|
||||
fun removeHiddenFolder(path: String) {
|
||||
removeHiddenFolders(HashSet<String>(Arrays.asList(path)))
|
||||
}
|
||||
|
||||
fun removeHiddenDirectories(paths: Set<String>) {
|
||||
fun removeHiddenFolders(paths: Set<String>) {
|
||||
val currHiddenFolders = HashSet<String>(hiddenFolders)
|
||||
currHiddenFolders.removeAll(paths)
|
||||
hiddenFolders = currHiddenFolders
|
||||
|
|
Loading…
Reference in a new issue