Edit mangas' Categories in Library using TriState list (#5422)
* Use QuadState Categories to edit mangas in Library Add updateMangasToCategories to build build correct Categories list for each manga using Common and Mix list Update QuadState Multi-Choice to either Action or Display List Display list would have different state sequece from Action Uncheck-> Indeterminate (only if initial so)-> Check fixup manga categories logic as Windows and push request comments * fixup: Use QuadStateTextView.State enum Update function to use QuadStateTextView.State enum that missed in last change * fixup: missing closing bracket and type cast Co-authored-by: quangkieu <quangkieu1993@gmail.com>
This commit is contained in:
+9
-4
@@ -49,6 +49,7 @@ import eu.kanade.tachiyomi.util.view.shrinkOnScroll
|
||||
import eu.kanade.tachiyomi.util.view.snack
|
||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||
import eu.kanade.tachiyomi.widget.EmptyView
|
||||
import eu.kanade.tachiyomi.widget.materialdialogs.QuadStateTextView
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
@@ -626,8 +627,12 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
// Choose a category
|
||||
else -> {
|
||||
val ids = presenter.getMangaCategoryIds(manga)
|
||||
val preselected = ids.mapNotNull { id ->
|
||||
categories.indexOfFirst { it.id == id }.takeIf { it != -1 }
|
||||
val preselected = categories.map {
|
||||
if (it.id in ids) {
|
||||
QuadStateTextView.State.CHECKED.ordinal
|
||||
} else {
|
||||
QuadStateTextView.State.UNCHECKED.ordinal
|
||||
}
|
||||
}.toTypedArray()
|
||||
|
||||
ChangeMangaCategoriesDialog(this, listOf(manga), categories, preselected)
|
||||
@@ -643,11 +648,11 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
* @param mangas The list of manga to move to categories.
|
||||
* @param categories The list of categories where manga will be placed.
|
||||
*/
|
||||
override fun updateCategoriesForMangas(mangas: List<Manga>, categories: List<Category>) {
|
||||
override fun updateCategoriesForMangas(mangas: List<Manga>, addCategories: List<Category>, removeCategories: List<Category>) {
|
||||
val manga = mangas.firstOrNull() ?: return
|
||||
|
||||
presenter.changeMangaFavorite(manga)
|
||||
presenter.updateMangaCategories(manga, categories)
|
||||
presenter.updateMangaCategories(manga, addCategories)
|
||||
|
||||
val position = adapter?.currentItems?.indexOfFirst { it -> (it as SourceItem).manga.id == manga.id }
|
||||
if (position != null) {
|
||||
|
||||
Reference in New Issue
Block a user