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