Shrink queue during getSong() call and call change().

This ensures that the ShowQueueAdapter gets notified about the change
This commit is contained in:
Adrian Ulrich 2015-09-12 11:56:20 +02:00
parent 8c482214ec
commit 5fe5308d6c
2 changed files with 10 additions and 10 deletions

View File

@ -1323,7 +1323,6 @@ public final class PlaybackService extends Service
updateNotification();
mTimeline.purge();
}
@Override

View File

@ -552,6 +552,10 @@ public final class SongTimeline {
if (song == null)
return null;
timeline.add(song);
// Keep the queue at 20 items to avoid growing forever
// Note that we do not broadcast the addition of this song, as it
// was virtually 'always there'
shrinkQueue(20);
} else {
if (size == 0)
// empty queue
@ -790,19 +794,16 @@ public final class SongTimeline {
}
/**
* Removes any songs greater than 10 songs before the current song when in
* random mode.
* Removes any songs greater than `len' songs before the current song.
*/
public void purge()
{
private void shrinkQueue(int len) {
synchronized (this) {
if (mFinishAction == FINISH_RANDOM) {
while (mCurrentPos > 10) {
mSongs.remove(0);
--mCurrentPos;
}
while (mCurrentPos > len) {
mSongs.remove(0);
mCurrentPos--;
}
}
changed();
}
/**