Unverified Commit a1255c05 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito Committed by GitHub

Merge pull request #1789 from RocketChat/fix/gif-upload

[FIX] Gif files not being animated.
parents 427d6ced 3f640077
...@@ -7,6 +7,7 @@ import androidx.core.view.isVisible ...@@ -7,6 +7,7 @@ import androidx.core.view.isVisible
import chat.rocket.android.emoji.internal.GlideApp import chat.rocket.android.emoji.internal.GlideApp
import chat.rocket.android.util.extensions.getFileName import chat.rocket.android.util.extensions.getFileName
import chat.rocket.android.util.extensions.getMimeType import chat.rocket.android.util.extensions.getMimeType
import com.bumptech.glide.load.resource.gif.GifDrawable
import com.bumptech.glide.request.target.SimpleTarget import com.bumptech.glide.request.target.SimpleTarget
import com.bumptech.glide.request.transition.Transition import com.bumptech.glide.request.transition.Transition
...@@ -21,22 +22,32 @@ fun ChatRoomFragment.showFileAttachmentDialog(uri: Uri) { ...@@ -21,22 +22,32 @@ fun ChatRoomFragment.showFileAttachmentDialog(uri: Uri) {
description.text.clear() description.text.clear()
when { when {
mimeType.startsWith("image") -> { mimeType.startsWith("image") -> {
GlideApp if (mimeType.contains("gif")) {
.with(context) GlideApp
.asBitmap() .with(context)
.load(uri) .asGif()
.override(imagePreview.width, imagePreview.height) .load(uri)
.fitCenter() .override(imagePreview.width, imagePreview.height)
.into(object : SimpleTarget<Bitmap>() { .fitCenter()
override fun onResourceReady( .into(imagePreview)
resource: Bitmap, } else {
transition: Transition<in Bitmap>? GlideApp
) { .with(context)
bitmap = resource .asBitmap()
imagePreview.setImageBitmap(resource) .load(uri)
imagePreview.isVisible = true .override(imagePreview.width, imagePreview.height)
} .fitCenter()
}) .into(object : SimpleTarget<Bitmap>() {
override fun onResourceReady(
resource: Bitmap,
transition: Transition<in Bitmap>?
) {
bitmap = resource
imagePreview.setImageBitmap(resource)
}
})
}
imagePreview.isVisible = true
} }
mimeType.startsWith("video") -> audioVideoAttachment.isVisible = true mimeType.startsWith("video") -> audioVideoAttachment.isVisible = true
else -> { else -> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment