#61 properly finalize thumbnail fetch when MMR cannot open video
This commit is contained in:
parent
e5867515e3
commit
ff53776697
2 changed files with 12 additions and 3 deletions
|
@ -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() {}
|
||||
|
|
|
@ -52,7 +52,9 @@ internal class VideoThumbnailFetcher(private val model: VideoThumbnail) : DataFe
|
|||
override fun loadData(priority: Priority, callback: DataCallback<in InputStream>) {
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue