diff options
author | daneren2005 <daneren2005@gmail.com> | 2013-10-21 16:33:00 -0700 |
---|---|---|
committer | daneren2005 <daneren2005@gmail.com> | 2013-10-21 16:33:00 -0700 |
commit | a7202d11d8cb4831e0ce3ea24756f1d32ea4f71a (patch) | |
tree | 15e8388fc14b0c500cb46ba2c8216f47178b0213 | |
parent | 0908bdf7ce01e7bf5051d4d43a0ed956c676071e (diff) | |
download | dsub-a7202d11d8cb4831e0ce3ea24756f1d32ea4f71a.tar.gz dsub-a7202d11d8cb4831e0ce3ea24756f1d32ea4f71a.tar.bz2 dsub-a7202d11d8cb4831e0ce3ea24756f1d32ea4f71a.zip |
Don't recreate when just switching between basic frag activities
-rw-r--r-- | src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java index c8d43f31..6d1231ca 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -87,20 +87,13 @@ public class SubsonicFragmentActivity extends SubsonicActivity { if (findViewById(R.id.fragment_container) != null && savedInstanceState == null) {
String fragmentType = getIntent().getStringExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE);
- if("Artist".equals(fragmentType)) {
- currentFragment = new SelectArtistFragment();
- } else if("Playlist".equals(fragmentType)) {
- currentFragment = new SelectPlaylistFragment();
- } else if("Chat".equals(fragmentType)) {
- currentFragment = new ChatFragment();
- } else if("Podcast".equals(fragmentType)) {
- currentFragment = new SelectPodcastsFragment();
- } else {
- currentFragment = new MainFragment();
-
+ currentFragment = getNewFragment(fragmentType);
+
+ if("".equals(fragmentType)) {
// Initial startup stuff
loadSettings();
}
+
currentFragment.setPrimaryFragment(true);
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, currentFragment, currentFragment.getSupportTag() + "").commit();
}
@@ -277,6 +270,42 @@ public class SubsonicFragmentActivity extends SubsonicActivity { }
}
}
+
+ @Override
+ public void startFragmentActivity(String fragmentType) {
+ // Create a transaction that does all of this
+ FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
+
+ // Clear existing stack
+ for(int i = backStack.size() - 1; i >= 0; i--) {
+ trans.remove((Fragment) backStack.get(i));
+ }
+ backStack.clear();
+
+ // Create new stack
+ currentFragment = getNewFragment(fragmentType);
+ currentFragment.setPrimaryFragment(true);
+ trans.add(R.id.fragment_container, currentFragment, currentFragment.getSupportTag() + "");
+
+ // Done, cleanup
+ trans.commit();
+ supportInvalidateOptionsMenu();
+ recreateSpinner();
+ }
+
+ private SubsonicFragment getNewFragment(String fragmentType) {
+ if("Artist".equals(fragmentType)) {
+ return new SelectArtistFragment();
+ } else if("Playlist".equals(fragmentType)) {
+ return new SelectPlaylistFragment();
+ } else if("Chat".equals(fragmentType)) {
+ return new ChatFragment();
+ } else if("Podcast".equals(fragmentType)) {
+ return new SelectPodcastsFragment();
+ } else {
+ return new MainFragment();
+ }
+ }
private void update() {
if (getDownloadService() == null) {
|