kopia lustrzana https://github.com/ryukoposting/Signal-Android
Autoplay all videos.
rodzic
5d76f13c51
commit
74c542099a
|
@ -8,7 +8,6 @@ import org.thoughtcrime.securesms.util.MediaUtil
|
||||||
|
|
||||||
class MediaPreviewV2Adapter(val fragment: Fragment) : FragmentStateAdapter(fragment) {
|
class MediaPreviewV2Adapter(val fragment: Fragment) : FragmentStateAdapter(fragment) {
|
||||||
private var items: List<Attachment> = listOf()
|
private var items: List<Attachment> = listOf()
|
||||||
private var autoPlayPosition = -1
|
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
return items.count()
|
return items.count()
|
||||||
|
@ -22,7 +21,7 @@ class MediaPreviewV2Adapter(val fragment: Fragment) : FragmentStateAdapter(fragm
|
||||||
MediaPreviewFragment.DATA_URI to attachment.uri,
|
MediaPreviewFragment.DATA_URI to attachment.uri,
|
||||||
MediaPreviewFragment.DATA_CONTENT_TYPE to contentType,
|
MediaPreviewFragment.DATA_CONTENT_TYPE to contentType,
|
||||||
MediaPreviewFragment.DATA_SIZE to attachment.size,
|
MediaPreviewFragment.DATA_SIZE to attachment.size,
|
||||||
MediaPreviewFragment.AUTO_PLAY to (position == autoPlayPosition),
|
MediaPreviewFragment.AUTO_PLAY to true,
|
||||||
MediaPreviewFragment.VIDEO_GIF to attachment.isVideoGif,
|
MediaPreviewFragment.VIDEO_GIF to attachment.isVideoGif,
|
||||||
)
|
)
|
||||||
val fragment = if (MediaUtil.isVideo(contentType)) {
|
val fragment = if (MediaUtil.isVideo(contentType)) {
|
||||||
|
@ -44,8 +43,4 @@ class MediaPreviewV2Adapter(val fragment: Fragment) : FragmentStateAdapter(fragm
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setAutoPlayItemPosition(position: Int) {
|
|
||||||
autoPlayPosition = position
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,6 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||||
val currentPosition = currentState.position
|
val currentPosition = currentState.position
|
||||||
val fragmentAdapter = binding.mediaPager.adapter as MediaPreviewV2Adapter
|
val fragmentAdapter = binding.mediaPager.adapter as MediaPreviewV2Adapter
|
||||||
|
|
||||||
fragmentAdapter.setAutoPlayItemPosition(currentPosition)
|
|
||||||
val backingItems = currentState.mediaRecords.mapNotNull { it.attachment }
|
val backingItems = currentState.mediaRecords.mapNotNull { it.attachment }
|
||||||
if (backingItems.isEmpty()) {
|
if (backingItems.isEmpty()) {
|
||||||
onMediaNotAvailable()
|
onMediaNotAvailable()
|
||||||
|
|
Ładowanie…
Reference in New Issue