Fix IndexOutOfBoundsException in onPause (#3581)
Use `getOrNull` instead of `get`, which was occasionally throwing IndexOutOfBoundsException.
This commit is contained in:
parent
d3a36be9e1
commit
2f512705e8
1 changed files with 1 additions and 1 deletions
|
@ -453,7 +453,7 @@ class NotificationsFragment :
|
||||||
// Save the ID of the first notification visible in the list
|
// Save the ID of the first notification visible in the list
|
||||||
val position = layoutManager.findFirstVisibleItemPosition()
|
val position = layoutManager.findFirstVisibleItemPosition()
|
||||||
if (position >= 0) {
|
if (position >= 0) {
|
||||||
adapter.snapshot()[position]?.id?.let { id ->
|
adapter.snapshot().getOrNull(position)?.id?.let { id ->
|
||||||
viewModel.accept(InfallibleUiAction.SaveVisibleId(visibleId = id))
|
viewModel.accept(InfallibleUiAction.SaveVisibleId(visibleId = id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue