From 3a9632f6ad56b05033ebc499bf6473f30f9bce31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaquim=20St=C3=A4hli?= Date: Wed, 20 Dec 2023 15:55:01 +0100 Subject: [PATCH] Fix crash when decode bitmap throw an exception --- .../player/notification/PillarboxMediaDescriptionAdapter.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/notification/PillarboxMediaDescriptionAdapter.kt b/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/notification/PillarboxMediaDescriptionAdapter.kt index ffb56a3a2..444538867 100644 --- a/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/notification/PillarboxMediaDescriptionAdapter.kt +++ b/pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/notification/PillarboxMediaDescriptionAdapter.kt @@ -86,8 +86,10 @@ class PillarboxMediaDescriptionAdapter( outHeight = imageMaxHeight } runBlocking(Dispatchers.IO) { - val bitmap = BitmapFactory.decodeStream(imageUrl.openStream(), null, opts) - bitmap?.let { + val result = runCatching { + BitmapFactory.decodeStream(imageUrl.openStream(), null, opts) + } + result.getOrNull()?.let { bitmapCache.put(imageUri, it) callback.onBitmap(it) }