Don't preserve timelien items after the chosen songs
This commit is contained in:
parent
d08344a44c
commit
acfc656cb9
@ -574,38 +574,30 @@ public final class PlaybackService extends Service implements Handler.Callback,
|
|||||||
|
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
synchronized (mSongTimeline) {
|
ArrayList<Song> timeline = mSongTimeline;
|
||||||
|
synchronized (timeline) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ACTION_ENQUEUE:
|
case ACTION_ENQUEUE:
|
||||||
int i = mTimelinePos + mQueuePos + 1;
|
int i = mTimelinePos + mQueuePos + 1;
|
||||||
|
if (i < timeline.size())
|
||||||
|
timeline.subList(i, timeline.size()).clear();
|
||||||
|
|
||||||
|
for (int j = 0; j != songs.length; ++j)
|
||||||
|
timeline.add(new Song(songs[j]));
|
||||||
|
|
||||||
if (mQueuePos == 0)
|
if (mQueuePos == 0)
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|
||||||
for (int j = 0; j != songs.length; ++i, ++j) {
|
|
||||||
Song song = new Song(songs[j]);
|
|
||||||
if (i < mSongTimeline.size())
|
|
||||||
mSongTimeline.set(i, song);
|
|
||||||
else
|
|
||||||
mSongTimeline.add(song);
|
|
||||||
}
|
|
||||||
|
|
||||||
mQueuePos += songs.length;
|
mQueuePos += songs.length;
|
||||||
break;
|
break;
|
||||||
case ACTION_PLAY:
|
case ACTION_PLAY:
|
||||||
List<Song> view = mSongTimeline.subList(mTimelinePos + 1, mSongTimeline.size());
|
timeline.subList(mTimelinePos + 1, timeline.size()).clear();
|
||||||
List<Song> queue = mQueuePos == 0 ? null : new ArrayList<Song>(view);
|
|
||||||
view.clear();
|
|
||||||
|
|
||||||
for (int j = 0; j != songs.length; ++j)
|
for (int j = 0; j != songs.length; ++j)
|
||||||
mSongTimeline.add(new Song(songs[j]));
|
timeline.add(new Song(songs[j]));
|
||||||
|
|
||||||
if (queue != null)
|
|
||||||
mSongTimeline.addAll(queue);
|
|
||||||
|
|
||||||
mQueuePos += songs.length - 1;
|
|
||||||
|
|
||||||
if (songs.length > 1)
|
if (songs.length > 1)
|
||||||
changed = true;
|
changed = true;
|
||||||
|
mQueuePos += songs.length - 1;
|
||||||
|
|
||||||
mHandler.sendEmptyMessage(TRACK_CHANGED);
|
mHandler.sendEmptyMessage(TRACK_CHANGED);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user