use of app.insti.fragment.UserFragment in project IITB-App by wncc.
the class MainActivity method updateFragment.
/**
* Change the active fragment to the supplied one
*/
public void updateFragment(Fragment fragment) {
if (session.isLoggedIn() && currentUser == null) {
currentUser = session.getCurrentUser();
}
Bundle bundle = fragment.getArguments();
if (bundle == null) {
bundle = new Bundle();
}
bundle.putString(Constants.SESSION_ID, session.pref.getString(Constants.SESSION_ID, ""));
if (fragment instanceof MessMenuFragment)
bundle.putString(Constants.USER_HOSTEL, session.isLoggedIn() && currentUser.getHostel() != null ? currentUser.getHostel() : "1");
if (fragment instanceof SettingsFragment && session.isLoggedIn())
bundle.putString(Constants.USER_ID, currentUser.getUserID());
if (fragment instanceof ComplaintsFragment && session.isLoggedIn()) {
bundle.putString(Constants.USER_ID, currentUser.getUserID());
bundle.putString(Constants.CURRENT_USER_PROFILE_PICTURE, currentUser.getUserProfilePictureUrl());
}
fragment.setArguments(bundle);
FragmentManager manager = getSupportFragmentManager();
if (fragment instanceof FeedFragment)
manager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction transaction = manager.beginTransaction();
/* Animate only for UserFragment */
if (fragment instanceof UserFragment) {
transaction.setCustomAnimations(R.anim.slide_in_up, R.anim.fade_out, R.anim.fade_in, R.anim.slide_out_down);
}
transaction.replace(R.id.framelayout_for_fragment, fragment, Utils.getTag(fragment));
transaction.addToBackStack(Utils.getTag(fragment)).commit();
}
Aggregations