diff options
author | daneren2005 <daneren2005@gmail.com> | 2013-12-03 16:23:39 -0800 |
---|---|---|
committer | daneren2005 <daneren2005@gmail.com> | 2013-12-03 16:23:39 -0800 |
commit | 102d6aa9f59e54c9f6dff2663fd8b04f29a62c70 (patch) | |
tree | 55d11087e253271498a0aead82b4d8e247eece2e | |
parent | 6de31db42dcae180bb3e4ba25f4c4b4574542a60 (diff) | |
download | dsub-102d6aa9f59e54c9f6dff2663fd8b04f29a62c70.tar.gz dsub-102d6aa9f59e54c9f6dff2663fd8b04f29a62c70.tar.bz2 dsub-102d6aa9f59e54c9f6dff2663fd8b04f29a62c70.zip |
#161 Added logic to load a directory recursively
-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);
|