aboutsummaryrefslogtreecommitdiff
path: root/src/github/daneren2005
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-11-01 16:39:07 -0700
committerdaneren2005 <daneren2005@gmail.com>2013-11-01 16:39:07 -0700
commit059194578364f657c803736b53e5a7c7519a3d24 (patch)
tree1e3d25528fff8eed3a25a609f6dabb75fa19abdc /src/github/daneren2005
parentccc585a4c3468c7ec7e1ad83da8a8c8f0c1743db (diff)
downloaddsub-059194578364f657c803736b53e5a7c7519a3d24.tar.gz
dsub-059194578364f657c803736b53e5a7c7519a3d24.tar.bz2
dsub-059194578364f657c803736b53e5a7c7519a3d24.zip
#123 Added logic in add/remove functions to keep a left/right fragment
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicActivity.java58
1 files changed, 52 insertions, 6 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
index e5b62878..3a41bd91 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -73,6 +73,8 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
private boolean finished = false;
protected List<SubsonicFragment> backStack = new ArrayList<SubsonicFragment>();
protected SubsonicFragment currentFragment;
+ protected View primaryContainer;
+ protected View secondaryContainer;
Spinner actionBarSpinner;
ArrayAdapter<CharSequence> spinnerAdapter;
ViewGroup rootView;
@@ -105,6 +107,12 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState has occurred.
drawerToggle.syncState();
+
+ // Check whether this is a tablet or not
+ secondaryContainer = findViewById(R.id.fragment_second_container);
+ if(secondaryContainer != null) {
+ primaryContainer = findViewById(R.id.fragment_container);
+ }
}
@Override
@@ -370,9 +378,34 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
currentFragment.setPrimaryFragment(true);
supportInvalidateOptionsMenu();
- FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
- trans.add(id, fragment, tag + "");
- trans.commit();
+ if(secondaryContainer == null) {
+ FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
+ trans.add(id, fragment, tag + "");
+ trans.commit();
+ } else {
+ // Make sure secondary container is visible now
+ secondaryContainer.setVisibility(View.VISIBLE);
+
+ // Check to see if you need to put on top of old left or not
+ int leftId = R.id.fragment_container;
+ if(backStack.size() > 1) {
+ SubsonicFragment oldLeftFragment = backStack.get(backStack.size() - 2);
+ leftId = oldLeftFragment.getRootId();
+ }
+
+ FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
+
+ // Move old right to left
+ SubsonicFragment newLeftFragment = backStack.get(backStack.size() - 1);
+ trans.remove(newLeftFragment);
+ trans.add(leftId, newLeftFragment, newLeftFragment.getSupportTag() + "");
+
+ // Add fragment to the right container
+ trans.add(R.id.fragment_second_container, fragment, tag + "");
+
+ // Commit it all
+ trans.commit();
+ }
recreateSpinner();
}
protected void removeCurrent() {
@@ -385,9 +418,22 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
currentFragment.setPrimaryFragment(true);
supportInvalidateOptionsMenu();
- FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
- trans.remove(oldFrag);
- trans.commit();
+ if(secondaryContainer == null) {
+ FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
+ trans.remove(oldFrag);
+ trans.commit();
+ } else {
+ FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
+
+ // Remove old right fragment
+ trans.remove(oldFrag);
+
+ // Add current left fragment to right side
+ trans.remove(currentFragment);
+ trans.add(R.id.fragment_second_container, currentFragment, currentFragment.getSupportTag() + "");
+
+ trans.commit();
+ }
recreateSpinner();
}