mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Fixes for adding a new categories via the set categories sheet
This commit is contained in:
parent
edbaa9f428
commit
7ac14b09f3
1 changed files with 11 additions and 9 deletions
|
@ -90,11 +90,7 @@ class SetCategoriesSheet(
|
|||
|
||||
init {
|
||||
binding.toolbarTitle.text = context.getString(
|
||||
if (addingToLibrary) {
|
||||
R.string.add_x_to
|
||||
} else {
|
||||
R.string.move_x_to
|
||||
},
|
||||
if (addingToLibrary) R.string.add_x_to else R.string.move_x_to,
|
||||
if (listManga.size == 1) {
|
||||
listManga.first().seriesType(context)
|
||||
} else {
|
||||
|
@ -239,10 +235,16 @@ class SetCategoriesSheet(
|
|||
binding.newCategoryButton.setOnClickListener {
|
||||
ManageCategoryDialog(null) {
|
||||
categories = db.getCategories().executeAsBlocking()
|
||||
itemAdapter.set(categories.map(::AddCategoryItem))
|
||||
itemAdapter.adapterItems.forEach { item ->
|
||||
item.isSelected = it == item.category.id
|
||||
val map = itemAdapter.adapterItems.map { it.category.id to it.state }.toMap()
|
||||
itemAdapter.set(
|
||||
categories.mapIndexed { index, category ->
|
||||
AddCategoryItem(category).apply {
|
||||
skipInversed =
|
||||
preselected.getOrElse(index) { TriStateCheckBox.State.UNCHECKED } != TriStateCheckBox.State.IGNORE
|
||||
state = map[category.id] ?: TriStateCheckBox.State.CHECKED
|
||||
}
|
||||
}
|
||||
)
|
||||
setCategoriesButtons()
|
||||
}.show(activity)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue