fix avatars with non-square aspect ratio display (#1528)

This commit is contained in:
Konrad Pozniak 2019-10-10 18:43:48 +02:00 committed by GitHub
parent f0a2dd4c6a
commit 1e0515f4ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,12 +5,12 @@ package com.keylesspalace.tusky.util
import android.widget.ImageView
import androidx.annotation.Px
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.FitCenter
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.keylesspalace.tusky.R
private val fitCenterTransformation = FitCenter()
private val centerCropTransformation = CenterCrop()
fun loadAvatar(url: String?, imageView: ImageView, @Px radius: Int, animate: Boolean) {
@ -23,7 +23,7 @@ fun loadAvatar(url: String?, imageView: ImageView, @Px radius: Int, animate: Boo
Glide.with(imageView)
.load(url)
.transform(
fitCenterTransformation,
centerCropTransformation,
RoundedCorners(radius)
)
.placeholder(R.drawable.avatar_default)
@ -34,7 +34,7 @@ fun loadAvatar(url: String?, imageView: ImageView, @Px radius: Int, animate: Boo
.asBitmap()
.load(url)
.transform(
fitCenterTransformation,
centerCropTransformation,
RoundedCorners(radius)
)
.placeholder(R.drawable.avatar_default)