From dccaf6946a6e3bae15a612dcd6186bc19599f720 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 30 May 2013 20:09:41 -0700 Subject: Made it so that a different tab can be preselected --- .../daneren2005/dsub/activity/SubsonicActivity.java | 16 +++++++++------- .../daneren2005/dsub/fragments/SelectArtistFragment.java | 6 +++++- .../dsub/fragments/SelectPlaylistFragment.java | 6 +++++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java index 0c8d130a..80f4ffc0 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -416,7 +416,7 @@ public class SubsonicActivity extends SherlockFragmentActivity implements OnItem } else { frags.set(i, fragStack); } - if(currentFragment == null) { + if(currentFragment == null || currentPosition == i) { currentFragment = frag; currentFragment.setPrimaryFragment(true); } @@ -465,13 +465,15 @@ public class SubsonicActivity extends SherlockFragmentActivity implements OnItem if(currentFragment != null) { currentFragment.setPrimaryFragment(false); } - List fragStack = frags.get(position); - currentFragment = fragStack.get(fragStack.size() - 1); - if(currentFragment != null) { - currentFragment.setPrimaryFragment(true); + if(position <= frags.size()) { + List fragStack = frags.get(position); + currentFragment = fragStack.get(fragStack.size() - 1); + if(currentFragment != null) { + currentFragment.setPrimaryFragment(true); + } + activity.invalidateOptionsMenu(); + recreateSpinner(); } - activity.invalidateOptionsMenu(); - recreateSpinner(); } public void addTab(CharSequence title, Class fragmentClass, Bundle args) { diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java index 8485f342..0a35233e 100644 --- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java +++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java @@ -58,7 +58,11 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie folderButton = folderButtonParent.findViewById(R.id.select_artist_folder); registerForContextMenu(artistList); - invalidated = true; + if(!primaryFragment) { + invalidated = true; + } else { + refresh(false); + } return rootView; } diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java index 1369eef0..aa0ffcf8 100644 --- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java +++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java @@ -51,7 +51,11 @@ public class SelectPlaylistFragment extends SubsonicFragment implements AdapterV emptyTextView = rootView.findViewById(R.id.select_playlist_empty); list.setOnItemClickListener(this); registerForContextMenu(list); - invalidated = true; + if(!primaryFragment) { + invalidated = true; + } else { + refresh(false); + } return rootView; } -- cgit v1.2.3