Skip to content

Commit

Permalink
Fix detekt
Browse files Browse the repository at this point in the history
  • Loading branch information
RenanLukas committed Jun 5, 2024
1 parent 2d8baa7 commit cdc8c53
Showing 1 changed file with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,30 @@ class ReaderTopBarMenuHelper @Inject constructor(
.takeIf { it.isNotEmpty() }
?.let { customListsArray ->
add(MenuElementData.Divider)
if (customListsArray.size() > 2) {
// If custom lists has more than 2 items, we add a submenu called "Lists"
add(createCustomListsItem(customListsArray))
} else {
// If the custom lists has 2 or less items, we add the items directly without submenu
customListsArray.forEach { index, readerTag ->
add(
MenuElementData.Item.Single(
id = getMenuItemIdFromReaderTagIndex(index),
text = UiString.UiStringText(readerTag.tagTitle),
)
)
}
}
createCustomListsItems(customListsArray)
}
}
}

private fun MutableList<MenuElementData>.createCustomListsItems(
customListsArray: SparseArrayCompat<ReaderTag>
) {
if (customListsArray.size() > 2) {
// If custom lists has more than 2 items, we add a submenu called "Lists"
add(createCustomListsItem(customListsArray))
} else {
// If the custom lists has 2 or less items, we add the items directly without submenu
customListsArray.forEach { index, readerTag ->
add(
MenuElementData.Item.Single(
id = getMenuItemIdFromReaderTagIndex(index),
text = UiString.UiStringText(readerTag.tagTitle),
)
)
}
}
}

private fun createDiscoverItem(id: String): MenuElementData.Item.Single {
return MenuElementData.Item.Single(
id = id,
Expand Down

0 comments on commit cdc8c53

Please sign in to comment.