mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
Merge pull request #2788 from Bnyro/master
Fix the notification thumbnail vanishing
This commit is contained in:
commit
497bc9c2dd
@ -38,6 +38,7 @@ class NowPlayingNotification(
|
|||||||
) {
|
) {
|
||||||
private var videoId: String? = null
|
private var videoId: String? = null
|
||||||
private var streams: Streams? = null
|
private var streams: Streams? = null
|
||||||
|
private var bitmap: Bitmap? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The [MediaSessionCompat] for the [streams].
|
* The [MediaSessionCompat] for the [streams].
|
||||||
@ -105,8 +106,17 @@ class NowPlayingNotification(
|
|||||||
): Bitmap? {
|
): Bitmap? {
|
||||||
if (DataSaverMode.isEnabled(context)) return null
|
if (DataSaverMode.isEnabled(context)) return null
|
||||||
|
|
||||||
var bitmap: Bitmap? = null
|
if (bitmap == null) enqueueThumbnailRequest(callback)
|
||||||
|
|
||||||
|
return bitmap
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getCurrentSubText(player: Player): CharSequence? {
|
||||||
|
return streams?.uploader
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun enqueueThumbnailRequest(callback: PlayerNotificationManager.BitmapCallback) {
|
||||||
val request = ImageRequest.Builder(context)
|
val request = ImageRequest.Builder(context)
|
||||||
.data(streams?.thumbnailUrl)
|
.data(streams?.thumbnailUrl)
|
||||||
.target { result ->
|
.target { result ->
|
||||||
@ -123,13 +133,6 @@ class NowPlayingNotification(
|
|||||||
|
|
||||||
// enqueue the thumbnail loading request
|
// enqueue the thumbnail loading request
|
||||||
ImageHelper.imageLoader.enqueue(request)
|
ImageHelper.imageLoader.enqueue(request)
|
||||||
|
|
||||||
return bitmap
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getCurrentSubText(player: Player): CharSequence? {
|
|
||||||
return streams?.uploader
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val customActionReceiver = object : CustomActionReceiver {
|
private val customActionReceiver = object : CustomActionReceiver {
|
||||||
@ -257,6 +260,8 @@ class NowPlayingNotification(
|
|||||||
) {
|
) {
|
||||||
this.videoId = videoId
|
this.videoId = videoId
|
||||||
this.streams = streams
|
this.streams = streams
|
||||||
|
// reset the thumbnail bitmap in order to become reloaded for the new video
|
||||||
|
this.bitmap = null
|
||||||
|
|
||||||
if (playerNotification == null) {
|
if (playerNotification == null) {
|
||||||
createMediaSession()
|
createMediaSession()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user