aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-04-01 17:58:16 -0700
committerScott Jackson <daneren2005@gmail.com>2016-04-01 17:58:16 -0700
commita5c45e631cbca4fd8e78d7ddc02ce1c19b973f50 (patch)
tree91286546514398207c136b439bc5c445d9caff8d /app/src
parent3b3a0eeaa6463c84e4cafb9d498e43ef9a5c3cc9 (diff)
downloaddsub-a5c45e631cbca4fd8e78d7ddc02ce1c19b973f50.tar.gz
dsub-a5c45e631cbca4fd8e78d7ddc02ce1c19b973f50.tar.bz2
dsub-a5c45e631cbca4fd8e78d7ddc02ce1c19b973f50.zip
Fixes #672: Resume entire album when clicking bookmarks
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java37
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java40
2 files changed, 55 insertions, 22 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
index 5f3ca38b..03c6663a 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
@@ -18,6 +18,7 @@
*/
package github.daneren2005.dsub.fragments;
+import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -28,6 +29,7 @@ import github.daneren2005.dsub.domain.Bookmark;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.service.MusicService;
+import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.MenuUtil;
import github.daneren2005.dsub.util.ProgressListener;
import github.daneren2005.dsub.util.SilentBackgroundTask;
@@ -89,19 +91,28 @@ public class SelectBookmarkFragment extends SelectRecyclerFragment<MusicDirector
return;
}
- new SilentBackgroundTask<Void>(context) {
- @Override
- protected Void doInBackground() throws Throwable {
- downloadService.clear();
- downloadService.download(Arrays.asList(bookmark), false, true, false, false, 0, bookmark.getBookmark().getPosition());
- return null;
- }
-
- @Override
- protected void done(Void result) {
- context.openNowPlaying();
- }
- }.execute();
+ if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_PLAY_NOW_AFTER, true) && ((!Util.isTagBrowsing(context) && bookmark.getParent() != null) || (Util.isTagBrowsing(context) && bookmark.getAlbumId() != null)) && !bookmark.isPodcast()) {
+ new RecursiveLoader(context) {
+ @Override
+ protected Boolean doInBackground() throws Throwable {
+ getSiblingsRecursively(bookmark);
+
+ if(songs.isEmpty() || !songs.contains(bookmark)) {
+ playNowInTask(Arrays.asList(bookmark), bookmark, bookmark.getBookmark().getPosition());
+ } else {
+ playNowInTask(songs, bookmark, bookmark.getBookmark().getPosition());
+ }
+ return null;
+ }
+
+ @Override
+ protected void done(Boolean result) {
+ context.openNowPlaying();
+ }
+ }.execute();
+ } else {
+ playNow(Arrays.asList(bookmark), bookmark, bookmark.getBookmark().getPosition());
+ }
}
private void displayBookmarkInfo(final MusicDirectory.Entry entry) {
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java
index f552127e..9bbc6f85 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -1675,15 +1675,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
new LoadingTask<Void>(context) {
@Override
protected Void doInBackground() throws Throwable {
- DownloadService downloadService = getDownloadService();
- if(downloadService == null) {
- return null;
- }
-
- downloadService.clear();
- downloadService.download(entries, false, true, true, false, entries.indexOf(song), position);
- downloadService.setSuggestedPlaylistName(playlistName, playlistId);
-
+ playNowInTask(entries, song, position, playlistName, playlistId);
return null;
}
@@ -1693,6 +1685,19 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
}
}.execute();
}
+ protected void playNowInTask(final List<Entry> entries, final Entry song, final int position) {
+ playNowInTask(entries, song, position, null, null);
+ }
+ protected void playNowInTask(final List<Entry> entries, final Entry song, final int position, final String playlistName, final String playlistId) {
+ DownloadService downloadService = getDownloadService();
+ if(downloadService == null) {
+ return;
+ }
+
+ downloadService.clear();
+ downloadService.download(entries, false, true, true, false, entries.indexOf(song), position);
+ downloadService.setSuggestedPlaylistName(playlistName, playlistId);
+ }
protected void deleteBookmark(final MusicDirectory.Entry entry, final SectionAdapter adapter) {
Util.confirmDialog(context, R.string.bookmark_delete_title, entry.getTitle(), new DialogInterface.OnClickListener() {
@@ -1933,6 +1938,23 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
musicService = MusicServiceFactory.getMusicService(context);
}
+ protected void getSiblingsRecursively(Entry entry) throws Exception {
+ MusicDirectory parent = new MusicDirectory();
+ if(Util.isTagBrowsing(context) && !Util.isOffline(context)) {
+ parent.setId(entry.getAlbumId());
+ } else {
+ parent.setId(entry.getParent());
+ }
+
+ if(parent.getId() == null) {
+ songs.add(entry);
+ } else {
+ MusicDirectory.Entry dir = new Entry(parent.getId());
+ dir.setDirectory(true);
+ parent.addChild(dir);
+ getSongsRecursively(parent, songs);
+ }
+ }
protected void getSongsRecursively(List<Entry> entry) throws Exception {
getSongsRecursively(entry, false);
}