mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 03:41:50 +01:00
Mark common categories when moving them. Closes #135
This commit is contained in:
parent
78314077bb
commit
81bce8ef76
@ -385,10 +385,15 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
||||
* @param mangas the manga list to move.
|
||||
*/
|
||||
private fun moveMangasToCategories(mangas: List<Manga>) {
|
||||
val categories = presenter.categories
|
||||
val commonCategoriesIndexes = presenter.getCommonCategories(mangas)
|
||||
.map { categories.indexOf(it) }
|
||||
.toTypedArray()
|
||||
|
||||
MaterialDialog.Builder(activity)
|
||||
.title(R.string.action_move_category)
|
||||
.items(presenter.getCategoryNames())
|
||||
.itemsCallbackMultiChoice(null) { dialog, positions, text ->
|
||||
.items(categories.map { it.name })
|
||||
.itemsCallbackMultiChoice(commonCategoriesIndexes) { dialog, positions, text ->
|
||||
presenter.moveMangasToCategories(positions, mangas)
|
||||
destroyActionModeIfNeeded()
|
||||
true
|
||||
|
@ -220,11 +220,13 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category names as a list.
|
||||
* Returns the common categories for the given list of manga.
|
||||
*
|
||||
* @param mangas the list of manga.
|
||||
*/
|
||||
fun getCategoryNames(): List<String> {
|
||||
return categories.map { it.name }
|
||||
}
|
||||
fun getCommonCategories(mangas: List<Manga>) = mangas.toSet()
|
||||
.map { db.getCategoriesForManga(it).executeAsBlocking() }
|
||||
.reduce { set1: Iterable<Category>, set2 -> set1.intersect(set2) }
|
||||
|
||||
/**
|
||||
* Remove the selected manga from the library.
|
||||
|
Loading…
Reference in New Issue
Block a user