From e7e1a9bf50f6a49274daf9c33c734dd0295ee6b1 Mon Sep 17 00:00:00 2001 From: inorichi Date: Sun, 15 Apr 2018 13:26:33 +0200 Subject: [PATCH] Fix #1073 --- .../tachiyomi/ui/library/LibraryCategoryAdapter.kt | 2 +- .../kanade/tachiyomi/ui/library/LibraryController.kt | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt index 61731d87d2..b14996f111 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryAdapter.kt @@ -34,7 +34,7 @@ class LibraryCategoryAdapter(view: LibraryCategoryView) : * @param manga the manga to find. */ fun indexOf(manga: Manga): Int { - return mangas.indexOfFirst { it.manga.id == manga.id } + return currentItems.indexOfFirst { it.manga.id == manga.id } } fun performFilter() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 169df75ba9..4f8c9451c0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -73,7 +73,7 @@ class LibraryController( /** * Currently selected mangas. */ - val selectedMangas = mutableListOf() + val selectedMangas = mutableSetOf() private var selectedCoverManga: Manga? = null @@ -429,11 +429,13 @@ class LibraryController( */ fun setSelection(manga: Manga, selected: Boolean) { if (selected) { - selectedMangas.add(manga) - selectionRelay.call(LibrarySelectionEvent.Selected(manga)) + if (selectedMangas.add(manga)) { + selectionRelay.call(LibrarySelectionEvent.Selected(manga)) + } } else { - selectedMangas.remove(manga) - selectionRelay.call(LibrarySelectionEvent.Unselected(manga)) + if (selectedMangas.remove(manga)) { + selectionRelay.call(LibrarySelectionEvent.Unselected(manga)) + } } }