diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/decoder/SvgGlideModule.kt b/android/app/src/main/kotlin/deckers/thibault/aves/decoder/SvgGlideModule.kt index 4a90afec2..c0bd10e44 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/decoder/SvgGlideModule.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/decoder/SvgGlideModule.kt @@ -50,7 +50,7 @@ internal class SvgFetcher(val model: SvgThumbnail, val width: Int, val height: I val context = model.context val uri = model.uri - StorageUtils.openInputStream(context, uri)?.use { input -> + val bitmap: Bitmap? = StorageUtils.openInputStream(context, uri)?.use { input -> try { SVG.getFromInputStream(input)?.let { svg -> svg.normalizeSize() @@ -71,12 +71,19 @@ internal class SvgFetcher(val model: SvgThumbnail, val width: Int, val height: I val canvas = Canvas(bitmap) svg.renderToCanvas(canvas) - callback.onDataReady(bitmap) + bitmap } } catch (ex: SVGParseException) { callback.onLoadFailed(ex) + return } } + + if (bitmap == null) { + callback.onLoadFailed(Exception("failed to load SVG for uri=$uri")) + } else { + callback.onDataReady(bitmap) + } } override fun cleanup() {} diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/decoder/VideoThumbnailGlideModule.kt b/android/app/src/main/kotlin/deckers/thibault/aves/decoder/VideoThumbnailGlideModule.kt index 37bc13071..d0f2138ff 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/decoder/VideoThumbnailGlideModule.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/decoder/VideoThumbnailGlideModule.kt @@ -52,7 +52,9 @@ internal class VideoThumbnailFetcher(private val model: VideoThumbnail) : DataFe override fun loadData(priority: Priority, callback: DataCallback) { GlobalScope.launch(Dispatchers.IO) { val retriever = openMetadataRetriever(model.context, model.uri) - if (retriever != null) { + if (retriever == null) { + callback.onLoadFailed(Exception("failed to initialize MediaMetadataRetriever for uri=${model.uri}")) + } else { try { var bytes = retriever.embeddedPicture if (bytes == null) {