Prevent IndexOutOfBounds exception when media is deleted.
This commit is contained in:
parent
1f196f74ff
commit
ff47f784a3
1 changed files with 3 additions and 3 deletions
|
@ -210,7 +210,7 @@ class MediaPreviewV2Fragment : LoggingFragment(R.layout.fragment_media_preview_v
|
|||
}
|
||||
|
||||
private fun bindCurrentState(currentState: MediaPreviewV2State) {
|
||||
if (currentState.position == -1 && currentState.mediaRecords.isEmpty()) {
|
||||
if (currentState.position < 0 && currentState.mediaRecords.isEmpty()) {
|
||||
onMediaNotAvailable()
|
||||
return
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ class MediaPreviewV2Fragment : LoggingFragment(R.layout.fragment_media_preview_v
|
|||
val currentPosition = currentState.position
|
||||
|
||||
val backingItems = currentState.mediaRecords.mapNotNull { it.attachment }
|
||||
if (backingItems.isEmpty()) {
|
||||
if (backingItems.isEmpty() || currentPosition < 0) {
|
||||
onMediaNotAvailable()
|
||||
return
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ class MediaPreviewV2Fragment : LoggingFragment(R.layout.fragment_media_preview_v
|
|||
* {@link OnPageChangeCallback}.
|
||||
*/
|
||||
private fun bindMediaReadyState(currentState: MediaPreviewV2State) {
|
||||
if (currentState.mediaRecords.isEmpty()) {
|
||||
if (currentState.mediaRecords.isEmpty() || currentState.position < 0) {
|
||||
onMediaNotAvailable()
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue