mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
only resize bitmap on SDK < 33
This commit is contained in:
parent
eaf115e489
commit
f66f5aa9db
@ -6,6 +6,7 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.drawable.BitmapDrawable
|
import android.graphics.drawable.BitmapDrawable
|
||||||
|
import android.os.Build
|
||||||
import android.support.v4.media.session.MediaSessionCompat
|
import android.support.v4.media.session.MediaSessionCompat
|
||||||
import coil.request.ImageRequest
|
import coil.request.ImageRequest
|
||||||
import com.github.libretube.activities.MainActivity
|
import com.github.libretube.activities.MainActivity
|
||||||
@ -82,16 +83,17 @@ class NowPlayingNotification(
|
|||||||
player: Player,
|
player: Player,
|
||||||
callback: PlayerNotificationManager.BitmapCallback
|
callback: PlayerNotificationManager.BitmapCallback
|
||||||
): Bitmap? {
|
): Bitmap? {
|
||||||
|
var bitmap: Bitmap? = null
|
||||||
var resizedBitmap: Bitmap? = null
|
var resizedBitmap: Bitmap? = null
|
||||||
|
|
||||||
val request = ImageRequest.Builder(context)
|
val request = ImageRequest.Builder(context)
|
||||||
.data(streams?.thumbnailUrl)
|
.data(streams?.thumbnailUrl)
|
||||||
.target { result ->
|
.target { result ->
|
||||||
val bitmap = (result as BitmapDrawable).bitmap
|
bitmap = (result as BitmapDrawable).bitmap
|
||||||
resizedBitmap = Bitmap.createScaledBitmap(
|
resizedBitmap = Bitmap.createScaledBitmap(
|
||||||
bitmap,
|
bitmap!!,
|
||||||
bitmap.width,
|
bitmap!!.width,
|
||||||
bitmap.width,
|
bitmap!!.width,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -100,7 +102,7 @@ class NowPlayingNotification(
|
|||||||
ImageHelper.imageLoader.enqueue(request)
|
ImageHelper.imageLoader.enqueue(request)
|
||||||
|
|
||||||
// returns the scaled bitmap if it got fetched successfully
|
// returns the scaled bitmap if it got fetched successfully
|
||||||
return resizedBitmap
|
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) resizedBitmap else bitmap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user