Workaround for crash when loading avatar

Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
This commit is contained in:
Dariusz Olszewski 2022-03-11 21:45:57 +01:00 committed by Tim Krüger
parent cdc4e89e54
commit ddcf1c48aa
No known key found for this signature in database
GPG Key ID: FECE3A7222C52A4E

View File

@ -424,12 +424,17 @@ class ChatController(args: Bundle) :
if (actionBar != null && bitmap != null && resources != null) {
val avatarSize = (actionBar?.height!! / 1.5).roundToInt()
val bitmapResized = Bitmap.createScaledBitmap(bitmap, avatarSize, avatarSize, false)
if (avatarSize > 0) {
val bitmapResized = Bitmap.createScaledBitmap(bitmap, avatarSize, avatarSize, false)
val roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(resources!!, bitmapResized)
roundedBitmapDrawable.isCircular = true
roundedBitmapDrawable.setAntiAlias(true)
actionBar?.setIcon(roundedBitmapDrawable)
val roundedBitmapDrawable =
RoundedBitmapDrawableFactory.create(resources!!, bitmapResized)
roundedBitmapDrawable.isCircular = true
roundedBitmapDrawable.setAntiAlias(true)
actionBar?.setIcon(roundedBitmapDrawable)
} else {
Log.d(TAG, "loadAvatarForStatusBar avatarSize <= 0")
}
}
}