aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005
diff options
context:
space:
mode:
authorWalter Huf <hufman@gmail.com>2018-01-15 08:55:18 -0800
committerWalter Huf <hufman@gmail.com>2018-01-15 09:15:02 -0800
commita4a92f128ac80726482503af670f248e17d1c4fb (patch)
treedc5dfa45ea5d9e24cd217263eb78397fcc8a18a6 /app/src/main/java/github/daneren2005
parentc04999f5859fe9d0569e77bcfaacc13af8439c42 (diff)
downloaddsub-a4a92f128ac80726482503af670f248e17d1c4fb.tar.gz
dsub-a4a92f128ac80726482503af670f248e17d1c4fb.tar.bz2
dsub-a4a92f128ac80726482503af670f248e17d1c4fb.zip
Better enqueues a selected bookmark's directory
Fixes a bug with multiple bookmarks in the same directory: The first file encountered with a saved bookmark would be played, not the bookmark that was selected
Diffstat (limited to 'app/src/main/java/github/daneren2005')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java43
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);
}
}
}