Crash fixes

This commit is contained in:
len 2016-04-04 23:25:50 +02:00
parent 5029e4a28c
commit d8ac35d259
3 changed files with 7 additions and 7 deletions

View file

@ -427,9 +427,9 @@ class CatalogueFragment : BaseRxFragment<CataloguePresenter>(), 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

View file

@ -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
}
}

View file

@ -359,11 +359,12 @@ class ChaptersFragment : BaseRxFragment<ChaptersPresenter>(), 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
}
}