mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 10:17:56 +00:00
Prevent IndexOutOfBounds exception when media is deleted.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user