Fix that the notification thumbnail doesn't load sometimes

This commit is contained in:
Bnyro 2023-01-16 14:44:37 +01:00
parent 930df73efa
commit 1641c75146

View File

@ -110,20 +110,19 @@ class NowPlayingNotification(
val request = ImageRequest.Builder(context)
.data(streams?.thumbnailUrl)
.target { result ->
bitmap = (result as BitmapDrawable).bitmap
val bm = (result as BitmapDrawable).bitmap
// returns the bitmap on Android 13+, for everything below scaled down to a square
bitmap = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
ImageHelper.getSquareBitmap(bm)
} else bm
callback.onBitmap(bitmap!!)
}
.build()
// enqueue the thumbnail loading request
ImageHelper.imageLoader.enqueue(request)
// returns the bitmap on Android 13+, for everything below scaled down to a square
return if (
Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU
) {
ImageHelper.getSquareBitmap(bitmap)
} else {
bitmap
}
return bitmap
}
override fun getCurrentSubText(player: Player): CharSequence? {