Fix IndexOutOfBoundsException in onPause (#3581)

Use `getOrNull` instead of `get`, which was occasionally throwing IndexOutOfBoundsException.
This commit is contained in:
Nik Clayton 2023-04-27 12:59:32 +02:00 committed by GitHub
parent d3a36be9e1
commit 2f512705e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -453,7 +453,7 @@ class NotificationsFragment :
// Save the ID of the first notification visible in the list
val position = layoutManager.findFirstVisibleItemPosition()
if (position >= 0) {
adapter.snapshot()[position]?.id?.let { id ->
adapter.snapshot().getOrNull(position)?.id?.let { id ->
viewModel.accept(InfallibleUiAction.SaveVisibleId(visibleId = id))
}
}