Shortcuts: avoid crash when retrieving images
This commit is contained in:
parent
46378845e9
commit
10d78a3102
|
@ -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 New Issue