mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 01:15:54 +03:00
Shortcuts: avoid crash when retrieving images
This commit is contained in:
parent
46378845e9
commit
10d78a3102
2 changed files with 7 additions and 3 deletions
|
@ -75,6 +75,7 @@ class AvatarRenderer @Inject constructor(private val activeSessionHolder: Active
|
|||
}
|
||||
|
||||
@AnyThread
|
||||
@Throws
|
||||
fun shortcutDrawable(context: Context, glideRequest: GlideRequests, matrixItem: MatrixItem, iconSize: Int): Bitmap {
|
||||
return glideRequest
|
||||
.asBitmap()
|
||||
|
|
|
@ -61,11 +61,14 @@ class ShortcutsHandler @Inject constructor(
|
|||
.take(n = 4) // Android only allows us to create 4 shortcuts
|
||||
.map { room ->
|
||||
val intent = RoomDetailActivity.shortcutIntent(context, room.roomId)
|
||||
val bitmap = avatarRenderer.shortcutDrawable(context, GlideApp.with(context), room.toMatrixItem(), iconSize)
|
||||
|
||||
val bitmap = try {
|
||||
avatarRenderer.shortcutDrawable(context, GlideApp.with(context), room.toMatrixItem(), iconSize)
|
||||
} catch (failure: Throwable) {
|
||||
null
|
||||
}
|
||||
ShortcutInfoCompat.Builder(context, room.roomId)
|
||||
.setShortLabel(room.displayName)
|
||||
.setIcon(bitmap.toProfileImageIcon())
|
||||
.setIcon(bitmap?.toProfileImageIcon())
|
||||
.setIntent(intent)
|
||||
.build()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue