Disable repeat option when there are no songs

This commit is contained in:
Christopher Eby 2011-09-11 15:14:33 -05:00
parent cf776d40bb
commit cb1221e00c
3 changed files with 6 additions and 4 deletions

View File

@ -310,6 +310,8 @@ public class PlaybackActivity extends Activity implements Handler.Callback, View
menu.findItem(MENU_SHUFFLE).setTitle(isShuffling ? R.string.shuffle_disable : R.string.shuffle_enable);
boolean isRepeating = (mState & PlaybackService.FLAG_REPEAT) != 0;
menu.findItem(MENU_REPEAT).setTitle(isRepeating ? R.string.repeat_disable : R.string.repeat_enable);
if ((mState & PlaybackService.FLAG_NO_MEDIA) != 0)
menu.findItem(MENU_REPEAT).setEnabled(false);
return true;
}

View File

@ -431,9 +431,6 @@ public final class PlaybackService extends Service implements Handler.Callback,
Toast.makeText(this, text, Toast.LENGTH_LONG).show();
}
if (mCurrentSong == null)
state &= ~FLAG_REPEAT;
int oldState = mState;
mState = state;

View File

@ -238,10 +238,13 @@ public final class SongTimeline {
synchronized (this) {
if (repeat) {
Song song = getSong(0);
if (song == null)
return;
mRepeatStart = mCurrentPos;
// Ensure that we will at least repeat one song (the current song),
// even if all of our songs were selected randomly.
getSong(0).flags &= ~Song.FLAG_RANDOM;
song.flags &= ~Song.FLAG_RANDOM;
} else {
mRepeatStart = -1;
mRepeatedSongs = null;