Skip to content

Commit

Permalink
Fix crash when decode bitmap throw an exception (#383)
Browse files Browse the repository at this point in the history
Co-authored-by: Gaëtan Muller <[email protected]>
  • Loading branch information
StaehliJ and MGaetan89 authored Dec 21, 2023
1 parent 69177df commit b8f166c
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ class PillarboxMediaDescriptionAdapter(
outHeight = imageMaxHeight
}
runBlocking(Dispatchers.IO) {
val bitmap = BitmapFactory.decodeStream(imageUrl.openStream(), null, opts)
bitmap?.let {
val result = runCatching {
imageUrl.openStream().use {
BitmapFactory.decodeStream(it, null, opts)
}
}
result.getOrNull()?.let {
bitmapCache.put(imageUri, it)
callback.onBitmap(it)
}
Expand Down

0 comments on commit b8f166c

Please sign in to comment.