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
|
|
@ -26,8 +26,8 @@ android {
|
||||||
applicationId "com.kabouzeid.gramophone"
|
applicationId "com.kabouzeid.gramophone"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 22
|
targetSdkVersion 22
|
||||||
versionCode 43
|
versionCode 45
|
||||||
versionName "0.9.27b dev-1"
|
versionName "0.9.29b dev-1"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|
|
||||||
|
|
@ -72,21 +72,25 @@ public class PlayingNotificationHelper {
|
||||||
if (intent.getAction().equals(ACTION_NOTIFICATION_COLOR_PREFERENCE_CHANGED)) {
|
if (intent.getAction().equals(ACTION_NOTIFICATION_COLOR_PREFERENCE_CHANGED)) {
|
||||||
boolean isColored = intent.getBooleanExtra(EXTRA_NOTIFICATION_COLORED, false);
|
boolean isColored = intent.getBooleanExtra(EXTRA_NOTIFICATION_COLORED, false);
|
||||||
if (isNotificationShown && PlayingNotificationHelper.this.isColored != isColored) {
|
if (isNotificationShown && PlayingNotificationHelper.this.isColored != isColored) {
|
||||||
buildNotification(currentSong, isPlaying, isColored);
|
updateNotification(isColored);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public void buildNotification(final Song song, final boolean isPlaying) {
|
public void updateNotification() {
|
||||||
buildNotification(song, isPlaying, PreferenceUtils.getInstance(service).coloredNotification());
|
updateNotification(PreferenceUtils.getInstance(service).coloredNotification());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildNotification(final Song song, final boolean isPlaying, final boolean isColored) {
|
private void updateNotification(final boolean isColored) {
|
||||||
if (song.id == -1) return;
|
Song song = service.getCurrentSong();
|
||||||
|
if (song.id == -1) {
|
||||||
|
service.stopForeground(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.isColored = isColored;
|
this.isColored = isColored;
|
||||||
currentSong = song;
|
currentSong = song;
|
||||||
this.isPlaying = isPlaying;
|
this.isPlaying = service.isPlayingAndNotFadingDown();
|
||||||
if (!isReceiverRegistered)
|
if (!isReceiverRegistered)
|
||||||
service.registerReceiver(notificationColorPreferenceChangedReceiver, intentFilter);
|
service.registerReceiver(notificationColorPreferenceChangedReceiver, intentFilter);
|
||||||
isReceiverRegistered = true;
|
isReceiverRegistered = true;
|
||||||
|
|
@ -258,8 +262,8 @@ public class PlayingNotificationHelper {
|
||||||
public void updatePlayState(final boolean isPlaying) {
|
public void updatePlayState(final boolean isPlaying) {
|
||||||
this.isPlaying = isPlaying;
|
this.isPlaying = isPlaying;
|
||||||
|
|
||||||
if (notification == null || notificationManager == null) {
|
if (notification == null) {
|
||||||
return;
|
updateNotification();
|
||||||
}
|
}
|
||||||
if (notificationLayout != null) {
|
if (notificationLayout != null) {
|
||||||
notificationLayout.setImageViewResource(R.id.action_play_pause,
|
notificationLayout.setImageViewResource(R.id.action_play_pause,
|
||||||
|
|
|
||||||
|
|
@ -434,7 +434,7 @@ public class MusicService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateNotification() {
|
private void updateNotification() {
|
||||||
playingNotificationHelper.buildNotification(getCurrentSong(), isPlayingAndNotFadingDown());
|
playingNotificationHelper.updateNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateWidgets() {
|
private void updateWidgets() {
|
||||||
|
|
@ -570,11 +570,11 @@ public class MusicService extends Service {
|
||||||
saveState();
|
saveState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSongs(int position, List<Song> songs) {
|
// public void addSongs(int position, List<Song> songs) {
|
||||||
playingQueue.addAll(position, songs);
|
// playingQueue.addAll(position, songs);
|
||||||
originalPlayingQueue.addAll(position, songs);
|
// originalPlayingQueue.addAll(position, songs);
|
||||||
saveState();
|
// saveState();
|
||||||
}
|
// }
|
||||||
|
|
||||||
public void addSongs(List<Song> songs) {
|
public void addSongs(List<Song> songs) {
|
||||||
playingQueue.addAll(songs);
|
playingQueue.addAll(songs);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue