Fix crash when deleting last item in library (#6079)

(cherry picked from commit 3448751e0e2f1d96d547a019ce2d274c9be5a0e6)
This commit is contained in:
jmir1 2021-10-11 16:17:01 +02:00 committed by Jobobby04
parent a9a93e2f8f
commit 7e11f3952f

View File

@ -139,9 +139,9 @@ class LibraryAdapter(
} }
override fun getViewType(position: Int): Int { override fun getViewType(position: Int): Int {
val category = categories[position] val category = categories.getOrNull(position)
return if (isPerCategory && category.id != 0) { return if (isPerCategory && category?.id != 0) {
if (DisplayModeSetting.fromFlag(category.displayMode) == DisplayModeSetting.LIST) { if (DisplayModeSetting.fromFlag(category?.displayMode) == DisplayModeSetting.LIST) {
LIST_DISPLAY_MODE LIST_DISPLAY_MODE
} else { } else {
GRID_DISPLAY_MODE GRID_DISPLAY_MODE