OsmAnd/OsmAnd-telegram/src/net/osmand/telegram/helpers/TelegramUiHelper.kt

30 lines
725 B
Kotlin
Raw Normal View History

package net.osmand.telegram.helpers
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.widget.ImageView
import net.osmand.telegram.R
import net.osmand.telegram.TelegramApplication
object TelegramUiHelper {
fun setupPhoto(app: TelegramApplication, iv: ImageView?, photoPath: String?) {
if (iv == null) {
return
}
var drawable: Drawable? = null
var bitmap: Bitmap? = null
if (photoPath != null && photoPath.isNotEmpty()) {
bitmap = app.uiUtils.getCircleBitmap(photoPath)
}
if (bitmap == null) {
drawable = app.uiUtils.getThemedIcon(R.drawable.ic_group)
}
if (bitmap != null) {
iv.setImageBitmap(bitmap)
} else {
iv.setImageDrawable(drawable)
}
}
}