diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-09-14 17:06:02 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-09-14 17:06:02 -0700 |
commit | 59dca36ab7a630332bb7ee6afb025f5c0c414541 (patch) | |
tree | 938c02a60d03c36dfe6748c83bbb3d3615889b5b /app | |
parent | e7062e98e77991a8f32cffcb4f0942b88e370bf0 (diff) | |
download | dsub-59dca36ab7a630332bb7ee6afb025f5c0c414541.tar.gz dsub-59dca36ab7a630332bb7ee6afb025f5c0c414541.tar.bz2 dsub-59dca36ab7a630332bb7ee6afb025f5c0c414541.zip |
Auto redirect to user tab when not logged in as an admin
Diffstat (limited to 'app')
3 files changed, 18 insertions, 1 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java index f1dd21e9..cd746516 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -805,6 +805,15 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte } recreateSpinner(); } + public void replaceExistingFragment(SubsonicFragment fragment, int tag) { + FragmentTransaction trans = getSupportFragmentManager().beginTransaction(); + trans.remove(currentFragment); + trans.add(R.id.fragment_container, fragment, tag + ""); + trans.commit(); + + currentFragment = fragment; + currentFragment.setPrimaryFragment(true); + } public void invalidate() { if(currentFragment != null) { diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/AdminFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/AdminFragment.java index 69164036..d4afa67e 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/AdminFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/AdminFragment.java @@ -117,7 +117,12 @@ public class AdminFragment extends SelectRecyclerFragment<User> { List<User> users = new ArrayList<User>(); User user = musicService.getUser(refresh, UserUtil.getCurrentUsername(context), context, listener); if(user != null) { - users.add(user); + SubsonicFragment fragment = new UserFragment(); + Bundle args = new Bundle(); + args.putSerializable(Constants.INTENT_EXTRA_NAME_ID, user); + fragment.setArguments(args); + + replaceExistingFragment(fragment); } UserUtil.refreshCurrentUser(context, false); diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java index 6c895edc..c5a2b022 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -399,6 +399,9 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR public void replaceFragment(SubsonicFragment fragment, boolean replaceCurrent) { context.replaceFragment(fragment, fragment.getSupportTag(), secondaryFragment && replaceCurrent); } + public void replaceExistingFragment(SubsonicFragment fragment) { + context.replaceExistingFragment(fragment, fragment.getSupportTag()); + } public int getRootId() { return rootView.getId(); |