From 4d4d29f0490f4f9110445c1bdc9c5043f68622d8 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Tue, 8 Jun 2021 17:52:16 +0200 Subject: [PATCH] Fix picture size for non-bitmaps (i.e. GIFs) when not known a priori Change-Id: Idcab1e3a4c99af5e51cbfc955eb5524bac3f7982 --- .../app/features/media/ImageContentRenderer.kt | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/media/ImageContentRenderer.kt b/vector/src/main/java/im/vector/app/features/media/ImageContentRenderer.kt index ba700c0f0c..3a76d1bc68 100644 --- a/vector/src/main/java/im/vector/app/features/media/ImageContentRenderer.kt +++ b/vector/src/main/java/im/vector/app/features/media/ImageContentRenderer.kt @@ -16,7 +16,6 @@ package im.vector.app.features.media -import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.Drawable import android.net.Uri import android.os.Parcelable @@ -130,16 +129,14 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc } override fun onResourceReady(resource: Drawable?, model: Any?, target: Target?, dataSource: DataSource?, isFirstResource: Boolean): Boolean { - if (data.width == null || data.height == null || data.width == 0 || data.height == 0) { - if (resource is BitmapDrawable) { - val updatedData = data.copy(width = resource.intrinsicWidth, height = resource.intrinsicHeight) - val newSize = processSize(updatedData, mode) - imageView.updateLayoutParams { - width = newSize.width - height = newSize.height - } - onImageSizeListener?.onImageSizeUpdated(newSize.width, newSize.height) + if (resource != null && (data.width == null || data.height == null || data.width == 0 || data.height == 0)) { + val updatedData = data.copy(width = resource.intrinsicWidth, height = resource.intrinsicHeight) + val newSize = processSize(updatedData, mode) + imageView.updateLayoutParams { + width = newSize.width + height = newSize.height } + onImageSizeListener?.onImageSizeUpdated(newSize.width, newSize.height) } return false }