diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-05-30 21:52:38 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-05-30 21:52:38 -0700 |
commit | 664e654884281b0342d38b1f35d3029d02592693 (patch) | |
tree | c14788ba695972e92bd2ca4f65f21706a78e6b73 | |
parent | 4cb0e73aaf59f46b93657d94ee19d9270c9db0f7 (diff) | |
download | dsub-664e654884281b0342d38b1f35d3029d02592693.tar.gz dsub-664e654884281b0342d38b1f35d3029d02592693.tar.bz2 dsub-664e654884281b0342d38b1f35d3029d02592693.zip |
Show Album puts artist on back stack
5 files changed, 56 insertions, 4 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java index 9a118e32..ba6d7230 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java @@ -197,13 +197,25 @@ public class MainActivity extends SubsonicActivity { if(getIntent().hasExtra(Constants.INTENT_EXTRA_VIEW_ALBUM)) { viewPager.setCurrentItem(1); + int fragmentID = R.id.select_artist_layout; + if(getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_PARENT_ID)) { + SubsonicFragment fragment = new SelectDirectoryFragment(); + Bundle args = new Bundle(); + args.putString(Constants.INTENT_EXTRA_NAME_ID, getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PARENT_ID)); + args.putString(Constants.INTENT_EXTRA_NAME_NAME, getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PARENT_NAME)); + fragment.setArguments(args); + + pagerAdapter.queueFragment(fragment, R.id.select_artist_layout); + fragmentID = R.id.select_album_layout; + } + SubsonicFragment fragment = new SelectDirectoryFragment(); Bundle args = new Bundle(); args.putString(Constants.INTENT_EXTRA_NAME_ID, getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ID)); args.putString(Constants.INTENT_EXTRA_NAME_NAME, getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_NAME)); fragment.setArguments(args); - pagerAdapter.queueFragment(fragment, R.id.select_artist_layout); + pagerAdapter.queueFragment(fragment, fragmentID); } executorService = Executors.newSingleThreadScheduledExecutor(); diff --git a/subsonic-android/src/github/daneren2005/dsub/domain/MusicDirectory.java b/subsonic-android/src/github/daneren2005/dsub/domain/MusicDirectory.java index 14cb6694..153c590e 100644 --- a/subsonic-android/src/github/daneren2005/dsub/domain/MusicDirectory.java +++ b/subsonic-android/src/github/daneren2005/dsub/domain/MusicDirectory.java @@ -30,6 +30,8 @@ import java.util.Comparator; public class MusicDirectory { private String name; + private String id; + private String parent; private List<Entry> children = new ArrayList<Entry>(); public String getName() { @@ -39,6 +41,22 @@ public class MusicDirectory { public void setName(String name) { this.name = name; } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getParent() { + return parent; + } + + public void setParent(String parent) { + this.parent = parent; + } public void addChild(Entry child) { children.add(child); @@ -69,6 +87,7 @@ public class MusicDirectory { public static class Entry implements Serializable { private String id; private String parent; + private String grandParent; private boolean directory; private String title; private String album; @@ -105,6 +124,14 @@ public class MusicDirectory { public void setParent(String parent) { this.parent = parent; } + + public String getGrandParent() { + return grandParent; + } + + public void setGrandParent(String grandParent) { + this.grandParent = grandParent; + } public boolean isDirectory() { return directory; diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java index 9ccc136f..9113cd74 100644 --- a/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java +++ b/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java @@ -519,10 +519,17 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe private boolean menuItemSelected(int menuItemId, final DownloadFile song) {
switch (menuItemId) {
case R.id.menu_show_album:
+ MusicDirectory.Entry entry = song.getSong();
+
Intent intent = new Intent(context, MainActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_VIEW_ALBUM, true);
- intent.putExtra(Constants.INTENT_EXTRA_NAME_ID, song.getSong().getParent());
- intent.putExtra(Constants.INTENT_EXTRA_NAME_NAME, song.getSong().getAlbum());
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_ID, entry.getParent());
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_NAME, entry.getAlbum());
+
+ if(entry.getGrandParent() != null) {
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_PARENT_ID, entry.getGrandParent());
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_PARENT_NAME, entry.getArtist());
+ }
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Util.startActivityWithoutTransition(context, intent);
return true;
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java b/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java index 0bf6ded1..ce1a70fc 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java @@ -51,9 +51,13 @@ public class MusicDirectoryParser extends MusicDirectoryEntryParser { if (eventType == XmlPullParser.START_TAG) { String name = getElementName(); if ("child".equals(name)) { - dir.addChild(parseEntry(artist)); + MusicDirectory.Entry entry = parseEntry(artist); + entry.setGrandParent(dir.getParent()); + dir.addChild(entry); } else if ("directory".equals(name)) { dir.setName(get("name")); + dir.setId(get("id")); + dir.setParent(get("parent")); } else if ("error".equals(name)) { handleError(); } diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java index 03213ce4..d5399017 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java @@ -36,6 +36,8 @@ public final class Constants { // Names for intent extras. public static final String INTENT_EXTRA_NAME_ID = "subsonic.id"; public static final String INTENT_EXTRA_NAME_NAME = "subsonic.name"; + public static final String INTENT_EXTRA_NAME_PARENT_ID = "subsonic.parent_id"; + public static final String INTENT_EXTRA_NAME_PARENT_NAME = "subsonic.parent_name"; public static final String INTENT_EXTRA_NAME_ARTIST = "subsonic.artist"; public static final String INTENT_EXTRA_NAME_TITLE = "subsonic.title"; public static final String INTENT_EXTRA_NAME_AUTOPLAY = "subsonic.playall"; |