diff --git a/app/src/main/java/org/koitharu/kotatsu/base/ui/list/fastscroll/FastScroller.kt b/app/src/main/java/org/koitharu/kotatsu/base/ui/list/fastscroll/FastScroller.kt index 23c79d7a2..e5cb94dd4 100644 --- a/app/src/main/java/org/koitharu/kotatsu/base/ui/list/fastscroll/FastScroller.kt +++ b/app/src/main/java/org/koitharu/kotatsu/base/ui/list/fastscroll/FastScroller.kt @@ -516,6 +516,6 @@ class FastScroller @JvmOverloads constructor( interface SectionIndexer { - fun getSectionText(context: Context, position: Int): CharSequence + fun getSectionText(context: Context, position: Int): CharSequence? } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/koitharu/kotatsu/details/ui/adapter/ChaptersAdapter.kt b/app/src/main/java/org/koitharu/kotatsu/details/ui/adapter/ChaptersAdapter.kt index 766ffb0e3..7b91abef5 100644 --- a/app/src/main/java/org/koitharu/kotatsu/details/ui/adapter/ChaptersAdapter.kt +++ b/app/src/main/java/org/koitharu/kotatsu/details/ui/adapter/ChaptersAdapter.kt @@ -42,7 +42,8 @@ class ChaptersAdapter( } } - override fun getSectionText(context: Context, position: Int): CharSequence { - return items[position].chapter.number.toString() + override fun getSectionText(context: Context, position: Int): CharSequence? { + val item = items.getOrNull(position) ?: return null + return item.chapter.number.toString() } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/koitharu/kotatsu/history/ui/HistoryListAdapter.kt b/app/src/main/java/org/koitharu/kotatsu/history/ui/HistoryListAdapter.kt index b44f5db90..4f0805690 100644 --- a/app/src/main/java/org/koitharu/kotatsu/history/ui/HistoryListAdapter.kt +++ b/app/src/main/java/org/koitharu/kotatsu/history/ui/HistoryListAdapter.kt @@ -14,14 +14,14 @@ class HistoryListAdapter( listener: MangaListListener ) : MangaListAdapter(coil, lifecycleOwner, listener), FastScroller.SectionIndexer { - override fun getSectionText(context: Context, position: Int): CharSequence { + override fun getSectionText(context: Context, position: Int): CharSequence? { val list = items for (i in (0..position).reversed()) { - val item = list[i] + val item = list.getOrNull(i) ?: continue if (item is DateTimeAgo) { return item.format(context.resources) } } - return "" + return null } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/koitharu/kotatsu/shelf/ui/adapter/ShelfAdapter.kt b/app/src/main/java/org/koitharu/kotatsu/shelf/ui/adapter/ShelfAdapter.kt index 691db99ac..1a19dbb17 100644 --- a/app/src/main/java/org/koitharu/kotatsu/shelf/ui/adapter/ShelfAdapter.kt +++ b/app/src/main/java/org/koitharu/kotatsu/shelf/ui/adapter/ShelfAdapter.kt @@ -46,9 +46,9 @@ class ShelfAdapter( .addDelegate(errorStateListAD(listener)) } - override fun getSectionText(context: Context, position: Int): CharSequence { - val item = items.getOrNull(position) as? ShelfSectionModel - return item?.getTitle(context.resources) ?: "" + override fun getSectionText(context: Context, position: Int): CharSequence? { + val item = items.getOrNull(position) as? ShelfSectionModel ?: return null + return item.getTitle(context.resources) } private class DiffCallback : DiffUtil.ItemCallback() {