Fixed empty notification when Classic Notification is on
This commit is contained in:
parent
93ad0d0a90
commit
f719068325
4 changed files with 11 additions and 7 deletions
|
@ -945,8 +945,8 @@ public class MusicService extends MediaBrowserServiceCompat
|
|||
break;
|
||||
case CLASSIC_NOTIFICATION:
|
||||
updateNotification();
|
||||
playingNotification.setPlaying(isPlaying());
|
||||
playingNotification.updateMetadata(getCurrentSong(), this::startForegroundOrNotify);
|
||||
playingNotification.setPlaying(isPlaying(),this::startForegroundOrNotify);
|
||||
break;
|
||||
case PLAYBACK_SPEED:
|
||||
updateMediaSessionPlaybackState();
|
||||
|
@ -1435,7 +1435,7 @@ public class MusicService extends MediaBrowserServiceCompat
|
|||
savePositionInTrack();
|
||||
}
|
||||
songPlayCountHelper.notifyPlayStateChanged(isPlaying);
|
||||
playingNotification.setPlaying(isPlaying);
|
||||
playingNotification.setPlaying(isPlaying, this::startForegroundOrNotify);
|
||||
startForegroundOrNotify();
|
||||
break;
|
||||
case FAVORITE_STATE_CHANGED:
|
||||
|
|
|
@ -29,7 +29,7 @@ abstract class PlayingNotification(context: Context) :
|
|||
|
||||
abstract fun updateMetadata(song: Song, onUpdate: () -> Unit)
|
||||
|
||||
abstract fun setPlaying(isPlaying: Boolean)
|
||||
abstract fun setPlaying(isPlaying: Boolean, onUpdate: () -> Unit)
|
||||
|
||||
abstract fun updateFavorite(song: Song, onUpdate: () -> Unit)
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ class PlayingNotificationClassic(
|
|||
) : PlayingNotification(context) {
|
||||
|
||||
private var primaryColor: Int = 0
|
||||
private var isInitialized = false
|
||||
|
||||
init {
|
||||
val notificationLayout = getCombinedRemoteViews(true)
|
||||
|
@ -95,8 +96,8 @@ class PlayingNotificationClassic(
|
|||
return remoteViews
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
override fun updateMetadata(song: Song, onUpdate: () -> Unit) {
|
||||
isInitialized = true
|
||||
val bigNotificationImageSize = context.resources
|
||||
.getDimensionPixelSize(R.dimen.notification_big_image_size)
|
||||
GlideApp.with(context).asBitmapPalette().songCoverOptions(song)
|
||||
|
@ -258,7 +259,7 @@ class PlayingNotificationClassic(
|
|||
), NOTIFICATION_CONTROLS_SIZE_MULTIPLIER)
|
||||
}
|
||||
|
||||
override fun setPlaying(isPlaying: Boolean) {
|
||||
override fun setPlaying(isPlaying: Boolean, onUpdate: () -> Unit) {
|
||||
getPlayPauseBitmap(isPlaying).also {
|
||||
contentView.setImageViewBitmap(R.id.action_play_pause, it)
|
||||
bigContentView.setImageViewBitmap(R.id.action_play_pause, it)
|
||||
|
@ -266,7 +267,9 @@ class PlayingNotificationClassic(
|
|||
}
|
||||
|
||||
override fun updateFavorite(song: Song, onUpdate: () -> Unit) {
|
||||
|
||||
if (!isInitialized) {
|
||||
updateMetadata(song, onUpdate)
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildPendingIntent(
|
||||
|
|
|
@ -195,8 +195,9 @@ class PlayingNotificationImpl24(
|
|||
).build()
|
||||
}
|
||||
|
||||
override fun setPlaying(isPlaying: Boolean) {
|
||||
override fun setPlaying(isPlaying: Boolean, onUpdate: () -> Unit) {
|
||||
mActions[2] = buildPlayAction(isPlaying)
|
||||
onUpdate()
|
||||
}
|
||||
|
||||
override fun updateFavorite(song: Song, onUpdate: () -> Unit) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue