diff options
author | linus_lee <llee@cyngn.com> | 2014-10-30 12:28:36 -0700 |
---|---|---|
committer | linus_lee <llee@cyngn.com> | 2014-11-20 12:51:36 -0800 |
commit | f6096a26a63b7af7bf36c8a0592c3a1614e390d7 (patch) | |
tree | 5b3b35d36e4b3c78dff65b07e25029dac376cfd1 /src | |
parent | 9dcf86bfdb01bca31a241f236f2b86dd582d3599 (diff) | |
download | android_packages_apps_Eleven-f6096a26a63b7af7bf36c8a0592c3a1614e390d7.tar.gz android_packages_apps_Eleven-f6096a26a63b7af7bf36c8a0592c3a1614e390d7.tar.bz2 android_packages_apps_Eleven-f6096a26a63b7af7bf36c8a0592c3a1614e390d7.zip |
Eleven: Fix Play next to work as expected
https://cyanogen.atlassian.net/browse/MUSIC-66
https://cyanogen.atlassian.net/browse/MUSIC-156
Change-Id: Ia3f7305ccdc7811246f205f52c739e60d408a4ed
Diffstat (limited to 'src')
-rw-r--r-- | src/com/cyngn/eleven/MusicPlaybackService.java | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/com/cyngn/eleven/MusicPlaybackService.java b/src/com/cyngn/eleven/MusicPlaybackService.java index 18024c4..f93f134 100644 --- a/src/com/cyngn/eleven/MusicPlaybackService.java +++ b/src/com/cyngn/eleven/MusicPlaybackService.java @@ -212,11 +212,6 @@ public class MusicPlaybackService extends Service { private static final int IDCOLIDX = 0; /** - * Moves a list to the front of the queue - */ - public static final int NOW = 1; - - /** * Moves a list to the next position in the queue */ public static final int NEXT = 2; @@ -306,6 +301,8 @@ public class MusicPlaybackService extends Service { /** * The max size allowed for the track history * TODO: Comeback and rewrite/fix all the whole queue code bugs after demo + * https://cyanogen.atlassian.net/browse/MUSIC-175 + * https://cyanogen.atlassian.net/browse/MUSIC-44 */ public static final int MAX_HISTORY_SIZE = 1000; @@ -1017,10 +1014,13 @@ public class MusicPlaybackService extends Service { position = mPlaylist.size(); } + final ArrayList<MusicPlaybackTrack> arrayList = new ArrayList<MusicPlaybackTrack>(addlen); for (int i = 0; i < list.length; i++) { - mPlaylist.add(new MusicPlaybackTrack(list[i], sourceId, sourceType, i)); + arrayList.add(new MusicPlaybackTrack(list[i], sourceId, sourceType, i)); } + mPlaylist.addAll(position, arrayList); + if (mPlaylist.size() == 0) { closeCursor(); notifyChange(META_CHANGED); @@ -1387,7 +1387,17 @@ public class MusicPlaybackService extends Service { } else if (what.equals(QUEUE_CHANGED)) { saveQueue(true); if (isPlaying()) { - setNextTrack(); + // if we are in shuffle mode and our next track is still valid, + // try to re-use the track + // We need to reimplement the queue to prevent hacky solutions like this + // https://cyanogen.atlassian.net/browse/MUSIC-175 + // https://cyanogen.atlassian.net/browse/MUSIC-44 + if (mNextPlayPos >= 0 && mNextPlayPos < mPlaylist.size() + && getShuffleMode() != SHUFFLE_NONE) { + setNextTrack(mNextPlayPos); + } else { + setNextTrack(); + } } } else { saveQueue(false); @@ -2411,18 +2421,13 @@ public class MusicPlaybackService extends Service { synchronized (this) { if (action == NEXT && mPlayPos + 1 < mPlaylist.size()) { addToPlayList(list, mPlayPos + 1, sourceId, sourceType); + mNextPlayPos = mPlayPos + 1; notifyChange(QUEUE_CHANGED); } else { addToPlayList(list, Integer.MAX_VALUE, sourceId, sourceType); notifyChange(QUEUE_CHANGED); - if (action == NOW) { - mPlayPos = mPlaylist.size() - list.length; - openCurrentAndNext(); - play(); - notifyChange(META_CHANGED); - return; - } } + if (mPlayPos < 0) { mPlayPos = 0; openCurrentAndNext(); |