bug fixed

- fixed a bug where the music controller activity won’t update when
song is changed from android wear
- clean up of some methods
This commit is contained in:
Karim Abou Zeid 2015-02-08 16:19:18 +01:00
commit 45f3f0d565
2 changed files with 6 additions and 9 deletions

View file

@ -257,7 +257,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
@Override @Override
public void onCompletion(MediaPlayer mp) { public void onCompletion(MediaPlayer mp) {
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.SONG_COMPLETED); notifyOnMusicRemoteEventListeners(MusicRemoteEvent.SONG_COMPLETED);
if (isLastTrack()) { if (isLastTrack() && getRepeatMode() == REPEAT_MODE_NONE) {
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.QUEUE_COMPLETED); notifyOnMusicRemoteEventListeners(MusicRemoteEvent.QUEUE_COMPLETED);
playingNotificationHelper.updatePlayState(isPlaying()); playingNotificationHelper.updatePlayState(isPlaying());
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED); remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);

View file

@ -76,8 +76,6 @@ public class MusicControllerActivity extends AbsFabActivity implements OnMusicRe
moveSeekBarIntoPlace(); moveSeekBarIntoPlace();
updateCurrentSong();
setUpMusicControllers(); setUpMusicControllers();
prepareViewsForOpenAnimation(); prepareViewsForOpenAnimation();
@ -86,7 +84,7 @@ public class MusicControllerActivity extends AbsFabActivity implements OnMusicRe
} }
private void updateCurrentSong() { private void updateCurrentSong() {
getCurrentSongAndQueue(); getCurrentSong();
setHeadersText(); setHeadersText();
setUpArtistArt(); setUpArtistArt();
setUpAlbumArtAndApplyPalette(); setUpAlbumArtAndApplyPalette();
@ -176,11 +174,9 @@ public class MusicControllerActivity extends AbsFabActivity implements OnMusicRe
} }
} }
private void getCurrentSongAndQueue() { private void getCurrentSong() {
if (getApp().getMusicPlayerRemote().getPosition() >= 0) { song = getApp().getMusicPlayerRemote().getCurrentSong();
song = getApp().getMusicPlayerRemote().getPlayingQueue().get(getApp().getMusicPlayerRemote().getPosition()); if(song.id == -1){
} else {
song = new Song();
finish(); finish();
} }
} }
@ -308,6 +304,7 @@ public class MusicControllerActivity extends AbsFabActivity implements OnMusicRe
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
startMusicControllerStateUpdateThread(); startMusicControllerStateUpdateThread();
updateCurrentSong();
} }
private void startMusicControllerStateUpdateThread() { private void startMusicControllerStateUpdateThread() {