For #2792: Display bookmark folders at the top of the bookmarks UI
This commit is contained in:
parent
078843675b
commit
b7b3ee5ce6
|
@ -26,16 +26,30 @@ class BookmarkAdapter(private val emptyView: View, private val interactor: Bookm
|
|||
private var isFirstRun = true
|
||||
|
||||
fun updateData(tree: BookmarkNode?, mode: BookmarkFragmentState.Mode) {
|
||||
// Display folders above all other bookmarks.
|
||||
val allNodes = tree?.children.orEmpty()
|
||||
val folders: MutableList<BookmarkNode> = mutableListOf()
|
||||
val notFolders: MutableList<BookmarkNode> = mutableListOf()
|
||||
allNodes.forEach {
|
||||
if (it.type == BookmarkNodeType.FOLDER) {
|
||||
folders.add(it)
|
||||
} else {
|
||||
notFolders.add(it)
|
||||
}
|
||||
}
|
||||
val newTree = folders + notFolders
|
||||
|
||||
val diffUtil = DiffUtil.calculateDiff(
|
||||
BookmarkDiffUtil(
|
||||
this.tree,
|
||||
tree?.children.orEmpty(),
|
||||
newTree,
|
||||
this.mode,
|
||||
mode
|
||||
)
|
||||
)
|
||||
|
||||
this.tree = tree?.children.orEmpty()
|
||||
this.tree = newTree
|
||||
|
||||
isFirstRun = if (isFirstRun) false else {
|
||||
emptyView.isVisible = this.tree.isEmpty()
|
||||
false
|
||||
|
|
Loading…
Reference in New Issue
Block a user