mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 20:51:48 +01:00
Long pressing library button fix
With no categories just toggle favorite status (closes #179)
This commit is contained in:
parent
ddb4092e16
commit
7325a79318
@ -966,30 +966,26 @@ class MangaDetailsController : BaseController,
|
||||
override fun favoriteManga(longPress: Boolean) {
|
||||
if (isLocked()) return
|
||||
val manga = presenter.manga
|
||||
if (longPress) {
|
||||
val categories = presenter.getCategories()
|
||||
if (longPress && categories.isNotEmpty()) {
|
||||
if (!manga.favorite) {
|
||||
presenter.toggleFavorite()
|
||||
showAddedSnack()
|
||||
}
|
||||
val categories = presenter.getCategories()
|
||||
if (categories.isEmpty()) {
|
||||
// no categories exist, display a message about adding categories
|
||||
snack = view?.snack(R.string.action_add_category)
|
||||
} else {
|
||||
val ids = presenter.getMangaCategoryIds(manga)
|
||||
val preselected = ids.mapNotNull { id ->
|
||||
categories.indexOfFirst { it.id == id }.takeIf { it != -1 }
|
||||
}.toTypedArray()
|
||||
val ids = presenter.getMangaCategoryIds(manga)
|
||||
val preselected = ids.mapNotNull { id ->
|
||||
categories.indexOfFirst { it.id == id }.takeIf { it != -1 }
|
||||
}.toTypedArray()
|
||||
|
||||
ChangeMangaCategoriesDialog(this, listOf(manga), categories, preselected)
|
||||
.showDialog(router)
|
||||
}
|
||||
ChangeMangaCategoriesDialog(this, listOf(manga), categories, preselected).showDialog(
|
||||
router
|
||||
)
|
||||
} else {
|
||||
if (!manga.favorite) {
|
||||
toggleMangaFavorite()
|
||||
} else {
|
||||
val headerHolder = recycler.findViewHolderForAdapterPosition(0) as? MangaHeaderHolder
|
||||
?: return
|
||||
val headerHolder =
|
||||
recycler.findViewHolderForAdapterPosition(0) as? MangaHeaderHolder ?: return
|
||||
val popup = PopupMenu(view!!.context, headerHolder.favorite_button)
|
||||
popup.menu.add(R.string.remove_from_library)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user