From 59d61ce8dd98d7cf40f67d9877eb4dc7d2757786 Mon Sep 17 00:00:00 2001 From: Adrian Ulrich Date: Sat, 18 Oct 2014 15:17:11 +0200 Subject: [PATCH] use generic approach to detect if we removed the end of our queue --- .../blinkenlights/android/vanilla/SongTimeline.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ch/blinkenlights/android/vanilla/SongTimeline.java b/src/ch/blinkenlights/android/vanilla/SongTimeline.java index 35bc8d64..07778bff 100644 --- a/src/ch/blinkenlights/android/vanilla/SongTimeline.java +++ b/src/ch/blinkenlights/android/vanilla/SongTimeline.java @@ -816,14 +816,15 @@ public final class SongTimeline { while (it.hasNext()) { int i = it.nextIndex(); if (Song.getId(it.next()) == id) { - if (i == mCurrentPos && isEndOfQueue()) - mCurrentPos = 0; if (i < mCurrentPos) --mCurrentPos; it.remove(); } } + if (getSong(1) == null) + mCurrentPos = 0; + broadcastChangedSongs(); } @@ -838,12 +839,12 @@ public final class SongTimeline { synchronized (this) { saveActiveSongs(); - if (pos == mCurrentPos && isEndOfQueue()) // currently playing and at the and -> go to start - mCurrentPos = 0; + mSongs.remove(pos); + if (pos < mCurrentPos) mCurrentPos--; - - mSongs.remove(pos); + if (getSong(1) == null) // wrap around if this was the last song + mCurrentPos = 0; broadcastChangedSongs(); }