mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 19:05:56 +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
|
@AnyThread
|
||||||
|
@Throws
|
||||||
fun shortcutDrawable(context: Context, glideRequest: GlideRequests, matrixItem: MatrixItem, iconSize: Int): Bitmap {
|
fun shortcutDrawable(context: Context, glideRequest: GlideRequests, matrixItem: MatrixItem, iconSize: Int): Bitmap {
|
||||||
return glideRequest
|
return glideRequest
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
|
|
|
@ -61,11 +61,14 @@ class ShortcutsHandler @Inject constructor(
|
||||||
.take(n = 4) // Android only allows us to create 4 shortcuts
|
.take(n = 4) // Android only allows us to create 4 shortcuts
|
||||||
.map { room ->
|
.map { room ->
|
||||||
val intent = RoomDetailActivity.shortcutIntent(context, room.roomId)
|
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)
|
ShortcutInfoCompat.Builder(context, room.roomId)
|
||||||
.setShortLabel(room.displayName)
|
.setShortLabel(room.displayName)
|
||||||
.setIcon(bitmap.toProfileImageIcon())
|
.setIcon(bitmap?.toProfileImageIcon())
|
||||||
.setIntent(intent)
|
.setIntent(intent)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue