Animate gif avatars (#1279)
* animate gif avatars * add setting to enable avatar animation * cleanup code
This commit is contained in:
parent
da1089184c
commit
83696b5c7f
40 changed files with 381 additions and 547 deletions
|
@ -0,0 +1,43 @@
|
|||
@file:JvmName("ImageLoadingHelper")
|
||||
|
||||
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.RoundedCorners
|
||||
import com.keylesspalace.tusky.R
|
||||
|
||||
|
||||
private val fitCenterTransformation = FitCenter()
|
||||
|
||||
fun loadAvatar(url: String?, imageView: ImageView, @Px radius: Int, animate: Boolean) {
|
||||
|
||||
if(url.isNullOrBlank()) {
|
||||
Glide.with(imageView)
|
||||
.load(R.drawable.avatar_default)
|
||||
.into(imageView)
|
||||
} else {
|
||||
if (animate) {
|
||||
Glide.with(imageView)
|
||||
.load(url)
|
||||
.transform(
|
||||
fitCenterTransformation,
|
||||
RoundedCorners(radius)
|
||||
)
|
||||
.into(imageView)
|
||||
|
||||
} else {
|
||||
Glide.with(imageView)
|
||||
.asBitmap()
|
||||
.load(url)
|
||||
.transform(
|
||||
fitCenterTransformation,
|
||||
RoundedCorners(radius)
|
||||
)
|
||||
.into(imageView)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue