mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/2792: Display bookmark folders at the top of the bookmarks UI
This commit is contained in:
parent
ec18031057
commit
4f6213a2dd
@ -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