Fixed the notification not showing up when starting playback from the fab

This commit is contained in:
Karim Abou Zeid 2015-06-22 17:13:50 +02:00
commit 3cdf44e099
3 changed files with 20 additions and 16 deletions

View file

@ -26,8 +26,8 @@ android {
applicationId "com.kabouzeid.gramophone"
minSdkVersion 16
targetSdkVersion 22
versionCode 43
versionName "0.9.27b dev-1"
versionCode 45
versionName "0.9.29b dev-1"
}
buildTypes {

View file

@ -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,

View file

@ -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);