Play gifs in the timeline
Change-Id: I8405248329664b42c982a8e7a573d042e43b46d0
This commit is contained in:
parent
b28ca929a3
commit
5f1d0a7c8d
|
@ -32,6 +32,7 @@ import im.vector.app.core.glide.GlideApp
|
|||
import im.vector.app.features.home.room.detail.timeline.helper.ContentUploadStateTrackerBinder
|
||||
import im.vector.app.features.media.ImageContentRenderer
|
||||
import im.vector.app.features.themes.BubbleThemeUtils
|
||||
import org.matrix.android.sdk.api.util.MimeTypes
|
||||
|
||||
@EpoxyModelClass(layout = R.layout.item_timeline_event_base)
|
||||
abstract class MessageImageVideoItem : AbsMessageItem<MessageImageVideoItem.Holder>() {
|
||||
|
@ -75,7 +76,8 @@ abstract class MessageImageVideoItem : AbsMessageItem<MessageImageVideoItem.Hold
|
|||
}
|
||||
}
|
||||
}
|
||||
imageContentRenderer.render(mediaData, mode, holder.imageView, onImageSizeListener)
|
||||
val animate = mediaData.mimeType == MimeTypes.Gif
|
||||
imageContentRenderer.render(mediaData, mode, holder.imageView, onImageSizeListener, animate)
|
||||
if (!attributes.informationData.sendState.hasFailed()) {
|
||||
contentUploadStateTrackerBinder.bind(
|
||||
attributes.informationData.eventId,
|
||||
|
@ -90,7 +92,7 @@ abstract class MessageImageVideoItem : AbsMessageItem<MessageImageVideoItem.Hold
|
|||
ViewCompat.setTransitionName(holder.imageView, "imagePreview_${id()}")
|
||||
holder.mediaContentView.setOnClickListener(attributes.itemClickListener)
|
||||
holder.mediaContentView.setOnLongClickListener(attributes.itemLongClickListener)
|
||||
holder.playContentView.visibility = if (playable) View.VISIBLE else View.GONE
|
||||
holder.playContentView.visibility = if (playable && !animate) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
override fun unbind(holder: Holder) {
|
||||
|
|
|
@ -110,7 +110,7 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
|
|||
.into(imageView)
|
||||
}
|
||||
|
||||
fun render(data: Data, mode: Mode, imageView: ImageView, onImageSizeListener: OnImageSizeListener? = null) {
|
||||
fun render(data: Data, mode: Mode, imageView: ImageView, onImageSizeListener: OnImageSizeListener? = null, animate: Boolean = false) {
|
||||
val size = processSize(data, mode)
|
||||
imageView.updateLayoutParams {
|
||||
width = size.width
|
||||
|
@ -120,7 +120,7 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
|
|||
// a11y
|
||||
imageView.contentDescription = data.filename
|
||||
|
||||
createGlideRequest(data, mode, imageView, size)
|
||||
var request = createGlideRequest(data, mode, imageView, size)
|
||||
.listener(object : RequestListener<Drawable> {
|
||||
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
|
||||
return false
|
||||
|
@ -141,8 +141,15 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
|
|||
return false
|
||||
}
|
||||
})
|
||||
.dontAnimate()
|
||||
.transform(RoundedCorners(dimensionConverter.dpToPx(3)))
|
||||
request = if (animate) {
|
||||
// Glide seems to already do some dp to px calculation for animated gifs?
|
||||
request.transform(RoundedCorners(3))
|
||||
//request.apply(RequestOptions.bitmapTransform(RoundedCorners(3)))
|
||||
} else {
|
||||
request.dontAnimate()
|
||||
.transform(RoundedCorners(dimensionConverter.dpToPx(3)))
|
||||
}
|
||||
request
|
||||
// .thumbnail(0.3f)
|
||||
.into(imageView)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue