Unverified Commit 296eb5a5 authored by Lucio Maciel's avatar Lucio Maciel Committed by GitHub

Merge pull request #1653 from RocketChat/fix/image-aspect-ratio

[FIX] Preserves the image aspect ratio
parents 88332df2 638d456c
...@@ -11,6 +11,9 @@ import com.bumptech.glide.request.target.SimpleTarget ...@@ -11,6 +11,9 @@ import com.bumptech.glide.request.target.SimpleTarget
import com.bumptech.glide.request.transition.Transition import com.bumptech.glide.request.transition.Transition
fun ChatRoomFragment.showFileAttachmentDialog(uri: Uri) { fun ChatRoomFragment.showFileAttachmentDialog(uri: Uri) {
imagePreview.isVisible = false
audioVideoAttachment.isVisible = false
textFile.isVisible = false
var bitmap: Bitmap? = null var bitmap: Bitmap? = null
activity?.let { context -> activity?.let { context ->
...@@ -22,16 +25,16 @@ fun ChatRoomFragment.showFileAttachmentDialog(uri: Uri) { ...@@ -22,16 +25,16 @@ fun ChatRoomFragment.showFileAttachmentDialog(uri: Uri) {
.with(context) .with(context)
.asBitmap() .asBitmap()
.load(uri) .load(uri)
.override(500, 500) .override(imagePreview.width, imagePreview.height)
.centerCrop() .fitCenter()
.into(object : SimpleTarget<Bitmap>() { .into(object : SimpleTarget<Bitmap>() {
override fun onResourceReady( override fun onResourceReady(
resource: Bitmap, resource: Bitmap,
transition: Transition<in Bitmap>? transition: Transition<in Bitmap>?
) { ) {
bitmap = resource bitmap = resource
imagePreview.isVisible = true
imagePreview.setImageBitmap(resource) imagePreview.setImageBitmap(resource)
imagePreview.isVisible = true
} }
}) })
} }
......
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