Image loading: Use Activity scope if available

(cherry picked from commit 47ca6c76a7)
This commit is contained in:
Geoffrey Métais
2019-08-06 17:29:40 +02:00
parent dcee75d925
commit 62a3faf8da

View File

@@ -78,7 +78,10 @@ fun loadImage(v: View, item: MediaLibraryItem?, imageWidth: Int = 0) {
}
val bitmap = if (cacheKey !== null) BitmapCache.getBitmapFromMemCache(cacheKey) else null
if (bitmap !== null) updateImageView(bitmap, v, binding)
else AppScope.launch { getImage(v, findInLibrary(item, isMedia, isGroup), binding, imageWidth) }
else {
val scope = (v.context as? CoroutineScope) ?: AppScope
scope.launch { getImage(v, findInLibrary(item, isMedia, isGroup), binding, imageWidth) }
}
}
fun loadPlaylistImageWithWidth(v: ImageView, item: MediaLibraryItem?, imageWidth: Int) {