Skip to content

Commit

Permalink
Just use native tag instead of hacky solution of setSupportTag
Browse files Browse the repository at this point in the history
  • Loading branch information
daneren2005 committed May 16, 2013
1 parent 40a18dc commit 982cf6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ public void finish() {
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
if(viewPager == null) {
int[] ids = new int[backStack.size() + 1];
ids[0] = currentFragment.getSupportTag();
String[] ids = new String[backStack.size() + 1];
ids[0] = currentFragment.getTag();
int i = 1;
for(SubsonicFragment frag: backStack) {
ids[i] = frag.getSupportTag();
ids[i] = frag.getTag();
i++;
}
savedInstanceState.putIntArray(Constants.MAIN_BACK_STACK, ids);
savedInstanceState.putStringArray(Constants.MAIN_BACK_STACK, ids);
savedInstanceState.putInt(Constants.MAIN_BACK_STACK_SIZE, backStack.size() + 1);
} else {
pagerAdapter.onSaveInstanceState(savedInstanceState);
Expand All @@ -115,15 +115,13 @@ public void onRestoreInstanceState(Bundle savedInstanceState) {
if(viewPager == null) {
super.onRestoreInstanceState(savedInstanceState);
int size = savedInstanceState.getInt(Constants.MAIN_BACK_STACK_SIZE);
int[] ids = savedInstanceState.getIntArray(Constants.MAIN_BACK_STACK);
String[] ids = savedInstanceState.getStringArray(Constants.MAIN_BACK_STACK);
FragmentManager fm = getSupportFragmentManager();
currentFragment = (SubsonicFragment)fm.findFragmentByTag(ids[0] + "");
currentFragment.setSupportTag(ids[0]);
currentFragment = (SubsonicFragment)fm.findFragmentByTag(ids[0]);
currentFragment.setPrimaryFragment(true);
invalidateOptionsMenu();
for(int i = 1; i < size; i++) {
SubsonicFragment frag = (SubsonicFragment)fm.findFragmentByTag(ids[i] + "");
frag.setSupportTag(ids[i]);
SubsonicFragment frag = (SubsonicFragment)fm.findFragmentByTag(ids[i]);
backStack.add(frag);
}
recreateSpinner();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,6 @@ public void replaceFragment(SubsonicFragment fragment, int id) {
context.replaceFragment(fragment, id, fragment.getSupportTag());
}

public void setSupportTag(int tag) {
this.tag = tag;
}
public int getSupportTag() {
return tag;
}
Expand Down

0 comments on commit 982cf6d

Please sign in to comment.