Fix picture size for non-bitmaps (i.e. GIFs) when not known a priori

Change-Id: Idcab1e3a4c99af5e51cbfc955eb5524bac3f7982
This commit is contained in:
SpiritCroc 2021-06-08 17:52:16 +02:00
parent e293771dda
commit 4d4d29f049

View file

@ -16,7 +16,6 @@
package im.vector.app.features.media package im.vector.app.features.media
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.net.Uri import android.net.Uri
import android.os.Parcelable 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<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean { override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
if (data.width == null || data.height == null || data.width == 0 || data.height == 0) { if (resource != null && (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 updatedData = data.copy(width = resource.intrinsicWidth, height = resource.intrinsicHeight) val newSize = processSize(updatedData, mode)
val newSize = processSize(updatedData, mode) imageView.updateLayoutParams {
imageView.updateLayoutParams { width = newSize.width
width = newSize.width height = newSize.height
height = newSize.height
}
onImageSizeListener?.onImageSizeUpdated(newSize.width, newSize.height)
} }
onImageSizeListener?.onImageSizeUpdated(newSize.width, newSize.height)
} }
return false return false
} }