Shrink queue during getSong() call and call change().
This ensures that the ShowQueueAdapter gets notified about the change
This commit is contained in:
1 parent
8c482214ec
commit
5fe5308d6c
2 files changed
+10
-10
No files matched your search
@@ -1323,7 +1323,6 @@ public final class PlaybackService extends Service
|
||||
|
||||
updateNotification();
|
||||
|
||||
mTimeline.purge();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user