diff options
-rw-r--r-- | src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 328e25a1..5b54305b 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -64,6 +64,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter String albumListExtra;
int albumListSize;
boolean refreshListing = false;
+ boolean showAll = false;
public SelectDirectoryFragment() {
@@ -130,6 +131,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter albumListExtra = args.getString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_EXTRA);
albumListSize = args.getInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0);
refreshListing = args.getBoolean(Constants.INTENT_EXTRA_REFRESH_LISTINGS);
+ showAll = args.getBoolean(Constants.INTENT_EXTRA_VIEW_ALBUM, false);
if(entries == null) {
entries = (List<MusicDirectory.Entry>) args.getSerializable(Constants.FRAGMENT_LIST);
}
@@ -358,7 +360,11 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter } else if (albumListType != null) {
getAlbumList(albumListType, albumListSize);
} else {
- getMusicDirectory(id, name, refresh);
+ if(showAll) {
+ getRecursiveMusicDirectory(id, name, refresh);
+ } else {
+ getMusicDirectory(id, name, refresh);
+ }
}
}
@@ -378,6 +384,34 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
}.execute();
}
+
+ private void getRecursiveMusicDirectory(final String id, final String name, final boolean refresh) {
+ setTitle(name);
+
+ new LoadTask() {
+ @Override
+ protected MusicDirectory load(MusicService service) throws Exception {
+ MusicDirectory root = service.getMusicDirectory(id, name, refresh, context, this);
+ List<MusicDirectory.Entry> songs = new ArrayList<MusicDirectory.Entry>();
+ getSongsRecursively(root, songs);
+ root.replaceChildren(songs);
+ }
+
+ private void getSongsRecursively(MusicDirectory parent, List<MusicDirectory.Entry> songs) throws Exception {
+ songs.addAll(parent.getChildren(false, true));
+ for (MusicDirectory.Entry dir : parent.getChildren(true, false)) {
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ getSongsRecursively(musicService.getMusicDirectory(dir.getId(), dir.getTitle(), refresh, context, this), songs);
+ }
+ }
+
+ @Override
+ protected void done(Pair<MusicDirectory, Boolean> result) {
+ super.done(result);
+ setTitle(result.getFirst().getName());
+ }
+ }.execute();
+ }
private void getPlaylist(final String playlistId, final String playlistName, final boolean refresh) {
setTitle(playlistName);
|