Skip to content

Commit

Permalink
Finish media preview activity if no media present.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-signal committed Oct 31, 2022
1 parent 72aac07 commit 34f6d52
Showing 1 changed file with 10 additions and 1 deletion.
Expand Up @@ -163,7 +163,12 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
val fragmentAdapter = binding.mediaPager.adapter as MediaPreviewV2Adapter

fragmentAdapter.setAutoPlayItemPosition(currentPosition)
fragmentAdapter.updateBackingItems(currentState.mediaRecords.mapNotNull { it.attachment })
val backingItems = currentState.mediaRecords.mapNotNull { it.attachment }
if (backingItems.isEmpty()) {
onMediaNotAvailable()
return
}
fragmentAdapter.updateBackingItems(backingItems)

if (binding.mediaPager.currentItem != currentPosition) {
binding.mediaPager.setCurrentItem(currentPosition, false)
Expand All @@ -176,6 +181,10 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
* {@link OnPageChangeCallback}.
*/
private fun bindMediaReadyState(currentState: MediaPreviewV2State) {
if (currentState.mediaRecords.isEmpty()) {
onMediaNotAvailable()
return
}
val currentPosition = currentState.position
val currentItem: MediaDatabase.MediaRecord = currentState.mediaRecords[currentPosition]

Expand Down

0 comments on commit 34f6d52

Please sign in to comment.