mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
scale imgages differently
This commit is contained in:
parent
588f99edba
commit
91fc986f41
@ -105,28 +105,33 @@ class NowPlayingNotification(
|
||||
callback: PlayerNotificationManager.BitmapCallback
|
||||
): Bitmap? {
|
||||
var bitmap: Bitmap? = null
|
||||
var resizedBitmap: Bitmap? = null
|
||||
|
||||
val request = ImageRequest.Builder(context)
|
||||
.data(streams?.thumbnailUrl)
|
||||
.target { result ->
|
||||
bitmap = (result as BitmapDrawable).bitmap
|
||||
resizedBitmap = Bitmap.createScaledBitmap(
|
||||
bitmap!!,
|
||||
bitmap!!.width,
|
||||
bitmap!!.width,
|
||||
false
|
||||
)
|
||||
}
|
||||
.build()
|
||||
|
||||
ImageHelper.imageLoader.enqueue(request)
|
||||
|
||||
// returns the scaled bitmap if it got fetched successfully
|
||||
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) resizedBitmap else bitmap
|
||||
// returns the bitmap on Android 13+, for everything below scaled down to a square
|
||||
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) getSquareBitmap(bitmap) else bitmap
|
||||
}
|
||||
}
|
||||
|
||||
private fun getSquareBitmap(bitmap: Bitmap?): Bitmap? {
|
||||
bitmap ?: return null
|
||||
val newSize = minOf(bitmap.width, bitmap.height)
|
||||
return Bitmap.createBitmap(
|
||||
bitmap,
|
||||
(bitmap.width - newSize) / 2,
|
||||
(bitmap.height - newSize) / 2,
|
||||
newSize,
|
||||
newSize
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a [MediaSessionCompat] amd a [MediaSessionConnector] for the player
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user