diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueFragment.kt index f72b4675e..c26f7afec 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueFragment.kt @@ -427,9 +427,9 @@ class CatalogueFragment : BaseRxFragment(), FlexibleViewHold * @return true if the item should be selected, false otherwise. */ override fun onListItemClick(position: Int): Boolean { - val selectedManga = adapter.getItem(position) + val item = adapter.getItem(position) ?: return false - val intent = MangaActivity.newIntent(activity, selectedManga) + val intent = MangaActivity.newIntent(activity, item) intent.putExtra(MangaActivity.FROM_CATALOGUE, true) startActivity(intent) return false diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.kt index 2ed052b6c..b0925ecae 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.kt @@ -162,13 +162,12 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli */ override fun onListItemClick(position: Int): Boolean { // If the action mode is created and the position is valid, toggle the selection. - if (position == -1) { - return false - } else if (libraryFragment.actionMode != null) { + val item = adapter.getItem(position) ?: return false + if (libraryFragment.actionMode != null) { toggleSelection(position) return true } else { - openManga(adapter.getItem(position)) + openManga(item) return false } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt index cbedcfea2..572baa377 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt @@ -359,11 +359,12 @@ class ChaptersFragment : BaseRxFragment(), ActionMode.Callbac } override fun onListItemClick(position: Int): Boolean { + val item = adapter.getItem(position) ?: return false if (actionMode != null && adapter.mode == FlexibleAdapter.MODE_MULTI) { toggleSelection(position) return true } else { - openChapter(adapter.getItem(position)) + openChapter(item) return false } }