Do not crash on/avoid index out of bounds

This commit is contained in:
Lakoja 2023-04-05 15:48:40 +02:00
parent cf50d0563f
commit bca98d2f48
2 changed files with 2 additions and 2 deletions

View File

@ -161,7 +161,7 @@ class NotificationsFragment :
binding.recyclerView, binding.recyclerView,
this this
) { pos: Int -> ) { pos: Int ->
val notification = adapter.snapshot()[pos] val notification = adapter.snapshot().getOrNull(pos)
// We support replies only for now // We support replies only for now
if (notification is NotificationViewData) { if (notification is NotificationViewData) {
notification.statusViewData notification.statusViewData

View File

@ -478,7 +478,7 @@ class TimelineFragment :
override fun onLoadMore(position: Int) { override fun onLoadMore(position: Int) {
val placeholder = adapter.peek(position)?.asPlaceholderOrNull() ?: return val placeholder = adapter.peek(position)?.asPlaceholderOrNull() ?: return
loadMorePosition = position loadMorePosition = position
statusIdBelowLoadMore = adapter.peek(position + 1)?.id statusIdBelowLoadMore = if (position + 1 < adapter.itemCount) adapter.peek(position + 1)?.id else null
viewModel.loadMore(placeholder.id) viewModel.loadMore(placeholder.id)
} }