|
|
|
@ -50,31 +50,56 @@ private fun normalModeAdapterItems(
|
|
|
|
|
|
|
|
|
|
items.add(AdapterItem.TabHeader(false, tabs.isNotEmpty()))
|
|
|
|
|
|
|
|
|
|
if (tabs.isNotEmpty()) {
|
|
|
|
|
items.addAll(tabs.reversed().map(AdapterItem::TabItem))
|
|
|
|
|
items.add(AdapterItem.SaveTabGroup)
|
|
|
|
|
} else {
|
|
|
|
|
items.add(noTabMessage)
|
|
|
|
|
}
|
|
|
|
|
when {
|
|
|
|
|
tabs.isNotEmpty() && collections.isNotEmpty() -> {
|
|
|
|
|
showTabs(items, tabs)
|
|
|
|
|
showCollections(collections, expandedCollections, tabs, items)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
items.add(AdapterItem.CollectionHeader)
|
|
|
|
|
if (collections.isNotEmpty()) {
|
|
|
|
|
// If the collection is expanded, we want to add all of its tabs beneath it in the adapter
|
|
|
|
|
collections.map {
|
|
|
|
|
AdapterItem.CollectionItem(it, expandedCollections.contains(it.id), tabs.isNotEmpty())
|
|
|
|
|
}.forEach {
|
|
|
|
|
items.add(it)
|
|
|
|
|
if (it.expanded) {
|
|
|
|
|
items.addAll(collectionTabItems(it.collection))
|
|
|
|
|
}
|
|
|
|
|
tabs.isNotEmpty() && collections.isEmpty() -> {
|
|
|
|
|
showTabs(items, tabs)
|
|
|
|
|
items.add(noCollectionMessage)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tabs.isEmpty() && collections.isNotEmpty() -> {
|
|
|
|
|
items.add(noTabMessage)
|
|
|
|
|
showCollections(collections, expandedCollections, tabs, items)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tabs.isEmpty() && collections.isEmpty() -> {
|
|
|
|
|
items.add(noTabMessage)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
items.add(noCollectionMessage)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return items
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun showTabs(
|
|
|
|
|
items: MutableList<AdapterItem>,
|
|
|
|
|
tabs: List<Tab>
|
|
|
|
|
) {
|
|
|
|
|
items.addAll(tabs.reversed().map(AdapterItem::TabItem))
|
|
|
|
|
items.add(AdapterItem.SaveTabGroup)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun showCollections(
|
|
|
|
|
collections: List<TabCollection>,
|
|
|
|
|
expandedCollections: Set<Long>,
|
|
|
|
|
tabs: List<Tab>,
|
|
|
|
|
items: MutableList<AdapterItem>
|
|
|
|
|
) {
|
|
|
|
|
// If the collection is expanded, we want to add all of its tabs beneath it in the adapter
|
|
|
|
|
items.add(AdapterItem.CollectionHeader)
|
|
|
|
|
collections.map {
|
|
|
|
|
AdapterItem.CollectionItem(it, expandedCollections.contains(it.id), tabs.isNotEmpty())
|
|
|
|
|
}.forEach {
|
|
|
|
|
items.add(it)
|
|
|
|
|
if (it.expanded) {
|
|
|
|
|
items.addAll(collectionTabItems(it.collection))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun privateModeAdapterItems(tabs: List<Tab>): List<AdapterItem> {
|
|
|
|
|
val items = mutableListOf<AdapterItem>()
|
|
|
|
|
items.add(AdapterItem.TabHeader(true, tabs.isNotEmpty()))
|
|
|
|
|