Fixed the notification not showing up when starting playback from the fab
This commit is contained in:
parent
a3e94da232
commit
3cdf44e099
3 changed files with 20 additions and 16 deletions
|
|
@ -72,21 +72,25 @@ public class PlayingNotificationHelper {
|
|||
if (intent.getAction().equals(ACTION_NOTIFICATION_COLOR_PREFERENCE_CHANGED)) {
|
||||
boolean isColored = intent.getBooleanExtra(EXTRA_NOTIFICATION_COLORED, false);
|
||||
if (isNotificationShown && PlayingNotificationHelper.this.isColored != isColored) {
|
||||
buildNotification(currentSong, isPlaying, isColored);
|
||||
updateNotification(isColored);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void buildNotification(final Song song, final boolean isPlaying) {
|
||||
buildNotification(song, isPlaying, PreferenceUtils.getInstance(service).coloredNotification());
|
||||
public void updateNotification() {
|
||||
updateNotification(PreferenceUtils.getInstance(service).coloredNotification());
|
||||
}
|
||||
|
||||
private void buildNotification(final Song song, final boolean isPlaying, final boolean isColored) {
|
||||
if (song.id == -1) return;
|
||||
private void updateNotification(final boolean isColored) {
|
||||
Song song = service.getCurrentSong();
|
||||
if (song.id == -1) {
|
||||
service.stopForeground(true);
|
||||
return;
|
||||
}
|
||||
this.isColored = isColored;
|
||||
currentSong = song;
|
||||
this.isPlaying = isPlaying;
|
||||
this.isPlaying = service.isPlayingAndNotFadingDown();
|
||||
if (!isReceiverRegistered)
|
||||
service.registerReceiver(notificationColorPreferenceChangedReceiver, intentFilter);
|
||||
isReceiverRegistered = true;
|
||||
|
|
@ -258,8 +262,8 @@ public class PlayingNotificationHelper {
|
|||
public void updatePlayState(final boolean isPlaying) {
|
||||
this.isPlaying = isPlaying;
|
||||
|
||||
if (notification == null || notificationManager == null) {
|
||||
return;
|
||||
if (notification == null) {
|
||||
updateNotification();
|
||||
}
|
||||
if (notificationLayout != null) {
|
||||
notificationLayout.setImageViewResource(R.id.action_play_pause,
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ public class MusicService extends Service {
|
|||
}
|
||||
|
||||
private void updateNotification() {
|
||||
playingNotificationHelper.buildNotification(getCurrentSong(), isPlayingAndNotFadingDown());
|
||||
playingNotificationHelper.updateNotification();
|
||||
}
|
||||
|
||||
private void updateWidgets() {
|
||||
|
|
@ -570,11 +570,11 @@ public class MusicService extends Service {
|
|||
saveState();
|
||||
}
|
||||
|
||||
public void addSongs(int position, List<Song> songs) {
|
||||
playingQueue.addAll(position, songs);
|
||||
originalPlayingQueue.addAll(position, songs);
|
||||
saveState();
|
||||
}
|
||||
// public void addSongs(int position, List<Song> songs) {
|
||||
// playingQueue.addAll(position, songs);
|
||||
// originalPlayingQueue.addAll(position, songs);
|
||||
// saveState();
|
||||
// }
|
||||
|
||||
public void addSongs(List<Song> songs) {
|
||||
playingQueue.addAll(songs);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue