diff options
author | Scott Jackson <daneren2005@users.noreply.github.com> | 2018-01-17 09:09:04 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-17 09:09:04 -0800 |
commit | e11e62a8bf021e2bf3e563050ebe5c788678b7ef (patch) | |
tree | dc5dfa45ea5d9e24cd217263eb78397fcc8a18a6 /app/src | |
parent | c04999f5859fe9d0569e77bcfaacc13af8439c42 (diff) | |
parent | a4a92f128ac80726482503af670f248e17d1c4fb (diff) | |
download | dsub-e11e62a8bf021e2bf3e563050ebe5c788678b7ef.tar.gz dsub-e11e62a8bf021e2bf3e563050ebe5c788678b7ef.tar.bz2 dsub-e11e62a8bf021e2bf3e563050ebe5c788678b7ef.zip |
Merge pull request #841 from hufman/aa-multiple-bookmarks
Better enqueues a selected bookmark's directory
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java index 00bca833..c175671b 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java +++ b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java @@ -370,6 +370,30 @@ public class RemoteControlClientLP extends RemoteControlClientBase { private void playMusicDirectory(Entry dir, boolean shuffle, boolean append, boolean playFromBookmark) { playMusicDirectory(dir.getId(), shuffle, append, playFromBookmark); } + private void playMusicDirectory(final String dirId, final boolean shuffle, final boolean append, final Entry startEntry) { + new SilentServiceTask<Void>(downloadService) { + @Override + protected Void doInBackground(MusicService musicService) throws Throwable { + MusicDirectory musicDirectory; + if(Util.isTagBrowsing(downloadService) && !Util.isOffline(downloadService)) { + musicDirectory = musicService.getAlbum(dirId, "dir", false, downloadService, null); + } else { + musicDirectory = musicService.getMusicDirectory(dirId, "dir", false, downloadService, null); + } + + List<Entry> playEntries = new ArrayList<>(); + List<Entry> allEntries = musicDirectory.getChildren(false, true); + for(Entry song: allEntries) { + if (!song.isVideo() && song.getRating() != 1) { + playEntries.add(song); + } + } + playSongs(playEntries, shuffle, append, startEntry); + + return null; + } + }.execute(); + } private void playMusicDirectory(final String dirId, final boolean shuffle, final boolean append, final boolean playFromBookmark) { new SilentServiceTask<Void>(downloadService) { @Override @@ -409,6 +433,19 @@ public class RemoteControlClientLP extends RemoteControlClientBase { private void playSongs(List<Entry> entries, boolean shuffle, boolean append) { playSongs(entries, shuffle, append, false); } + private void playSongs(List<Entry> entries, boolean shuffle, boolean append, Entry startEntry) { + if(!append) { + downloadService.clear(); + } + + int startIndex = entries.indexOf(startEntry); + int startPosition = 0; + if(startEntry.getBookmark() != null) { + Bookmark bookmark = startEntry.getBookmark(); + startPosition = bookmark.getPosition(); + } + downloadService.download(entries, false, true, !append, shuffle, startIndex, startPosition); + } private void playSongs(List<Entry> entries, boolean shuffle, boolean append, boolean resumeFromBookmark) { if(!append) { downloadService.clear(); @@ -429,7 +466,7 @@ public class RemoteControlClientLP extends RemoteControlClientBase { } } - downloadService.download(entries, false, !append, false, shuffle, startIndex, startPosition); + downloadService.download(entries, false, true, !append, shuffle, startIndex, startPosition); } private void noResults() { @@ -568,9 +605,9 @@ public class RemoteControlClientLP extends RemoteControlClientBase { String childId = extras.getString(Constants.INTENT_EXTRA_NAME_CHILD_ID, null); if(childId != null) { if(Util.isTagBrowsing(downloadService) && !Util.isOffline(downloadService)) { - playMusicDirectory(entry.getAlbumId(), shuffle, playLast, true); + playMusicDirectory(entry.getAlbumId(), shuffle, playLast, entry); } else { - playMusicDirectory(entry.getParent(), shuffle, playLast, true); + playMusicDirectory(entry.getParent(), shuffle, playLast, entry); } } } |