fix hiding folders when Show Hidden Items is disabled

This commit is contained in:
tibbi 2018-04-09 14:28:11 +02:00
parent 2b37c315f1
commit 79dfab5efa

View file

@ -224,8 +224,9 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
updateFolderNames() updateFolderNames()
} else { } else {
val affectedPositions = ArrayList<Int>() val affectedPositions = ArrayList<Int>()
val includedFolders = activity.config.includedFolders
val newDirs = dirs.filterIndexed { index, directory -> val newDirs = dirs.filterIndexed { index, directory ->
val removeDir = directory.path.startsWith(path, true) val removeDir = File(directory.path).doesThisOrParentHaveNoMedia() && !includedFolders.contains(directory.path)
if (removeDir) { if (removeDir) {
affectedPositions.add(index) affectedPositions.add(index)
} }
@ -234,7 +235,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
activity.runOnUiThread { activity.runOnUiThread {
affectedPositions.sortedDescending().forEach { affectedPositions.sortedDescending().forEach {
notifyItemRemoved(it + positionOffset) notifyItemRemoved(it)
itemViews.put(it, null) itemViews.put(it, null)
} }
@ -245,6 +246,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
currentDirectoriesHash = newDirs.hashCode() currentDirectoriesHash = newDirs.hashCode()
itemViews = newItems itemViews = newItems
dirs = newDirs
finishActMode() finishActMode()
fastScroller?.measureRecyclerView() fastScroller?.measureRecyclerView()
listener?.updateDirectories(newDirs, false) listener?.updateDirectories(newDirs, false)