Shortcuts: avoid crash when retrieving images

This commit is contained in:
ganfra 2020-06-16 17:50:43 +02:00
parent 46378845e9
commit 10d78a3102
2 changed files with 7 additions and 3 deletions

View File

@ -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()

View File

@ -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()
}