Fix autoplay for videos in Media Preview.
This commit is contained in:
parent
168832c138
commit
2b4c01c106
2 changed files with 9 additions and 1 deletions
|
@ -44,4 +44,8 @@ class MediaPreviewV2Adapter(val fragment: Fragment) : FragmentStateAdapter(fragm
|
|||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
fun setAutoPlayItemPosition(position: Int) {
|
||||
autoPlayPosition = position
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,8 +158,12 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
|||
}
|
||||
|
||||
private fun bindDataLoadedState(currentState: MediaPreviewV2State) {
|
||||
(binding.mediaPager.adapter as MediaPreviewV2Adapter).updateBackingItems(currentState.mediaRecords.mapNotNull { it.attachment })
|
||||
val currentPosition = currentState.position
|
||||
val fragmentAdapter = binding.mediaPager.adapter as MediaPreviewV2Adapter
|
||||
|
||||
fragmentAdapter.setAutoPlayItemPosition(currentPosition)
|
||||
fragmentAdapter.updateBackingItems(currentState.mediaRecords.mapNotNull { it.attachment })
|
||||
|
||||
if (binding.mediaPager.currentItem != currentPosition) {
|
||||
binding.mediaPager.setCurrentItem(currentPosition, false)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue