aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-01-10 13:26:49 -0800
committerScott Jackson <daneren2005@gmail.com>2016-01-10 13:26:49 -0800
commita80a31f2f8790f0d24357dd356da469fea271aaf (patch)
tree0e70d101a96750f79a4701f78d5bb79fc51dc64d /app/src/main
parent45d6efe02b48fc297f5cd4ef6cb241c43c1d8f82 (diff)
downloaddsub-a80a31f2f8790f0d24357dd356da469fea271aaf.tar.gz
dsub-a80a31f2f8790f0d24357dd356da469fea271aaf.tar.bz2
dsub-a80a31f2f8790f0d24357dd356da469fea271aaf.zip
#618 Resume podcasts/album lists from Bookmarks
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java35
1 files changed, 29 insertions, 6 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 bf025849..907f80ac 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
@@ -43,6 +43,7 @@ import java.util.List;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.activity.SubsonicActivity;
import github.daneren2005.dsub.activity.SubsonicFragmentActivity;
+import github.daneren2005.dsub.domain.Bookmark;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.MusicDirectory.Entry;
import github.daneren2005.dsub.domain.Playlist;
@@ -352,7 +353,7 @@ public class RemoteControlClientLP extends RemoteControlClientBase {
}
}.execute();
}
- private void playMusicDirectory(final Entry dir, final boolean shuffle, final boolean append) {
+ private void playMusicDirectory(final Entry dir, final boolean shuffle, final boolean append, final boolean playFromBookmark) {
new SilentServiceTask<Void>(downloadService) {
@Override
protected Void doInBackground(MusicService musicService) throws Throwable {
@@ -362,7 +363,7 @@ public class RemoteControlClientLP extends RemoteControlClientBase {
} else {
musicDirectory = musicService.getMusicDirectory(dir.getId(), "dir", false, downloadService, null);
}
- playSongs(musicDirectory.getChildren(false, true), shuffle, append);
+ playSongs(musicDirectory.getChildren(false, true), shuffle, append, playFromBookmark);
return null;
}
@@ -370,18 +371,40 @@ public class RemoteControlClientLP extends RemoteControlClientBase {
}
private void playSong(Entry entry) {
+
+ }
+ private void playSong(Entry entry, boolean resumeFromBookmark) {
List<Entry> entries = new ArrayList<>();
entries.add(entry);
- playSongs(entries);
+ playSongs(entries, false, false, resumeFromBookmark);
}
private void playSongs(List<Entry> entries) {
playSongs(entries, false, false);
}
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, boolean resumeFromBookmark) {
if(!append) {
downloadService.clear();
}
- downloadService.download(entries, false, true, false, shuffle);
+
+ int startIndex = 0;
+ int startPosition = 0;
+ if(resumeFromBookmark) {
+ int bookmarkIndex = 0;
+ for(Entry entry: entries) {
+ if(entry.getBookmark() != null) {
+ Bookmark bookmark = entry.getBookmark();
+ startIndex = bookmarkIndex;
+ startPosition = bookmark.getPosition();
+ break;
+ }
+ bookmarkIndex++;
+ }
+ }
+
+ downloadService.download(entries, false, true, false, shuffle, startIndex, startPosition);
}
private void noResults() {
@@ -504,12 +527,12 @@ public class RemoteControlClientLP extends RemoteControlClientBase {
String musicDirectoryId = extras.getString(Constants.INTENT_EXTRA_NAME_ID);
if(musicDirectoryId != null) {
Entry dir = new Entry(musicDirectoryId);
- playMusicDirectory(dir, shuffle, playLast);
+ playMusicDirectory(dir, shuffle, playLast, true);
}
String podcastId = extras.getString(Constants.INTENT_EXTRA_NAME_PODCAST_ID, null);
if(podcastId != null) {
- playSong((PodcastEpisode) entry);
+ playSong((PodcastEpisode) entry, true);
}
}