Fixed application navigation issues.

This commit is contained in:
Pierre HUBERT 2018-08-01 11:41:35 +02:00
parent 22c51480a6
commit f856cc471f
2 changed files with 11 additions and 6 deletions

View File

@ -134,8 +134,8 @@ public class MainActivity extends AppCompatActivity implements
conversationsListHelper = new ConversationsListHelper(this, dbHelper); conversationsListHelper = new ConversationsListHelper(this, dbHelper);
//If it is the first time the application is launched, open notifications fragment //If it is the first time the application is launched, open notifications fragment
if (savedInstanceState == null) { if (savedInstanceState == null){
openNotificationsFragment(); openNotificationsFragment(false);
} }
} }
@ -305,7 +305,7 @@ public class MainActivity extends AppCompatActivity implements
//Notification fragment //Notification fragment
if(id == R.id.action_notifications){ if(id == R.id.action_notifications){
openNotificationsFragment(); openNotificationsFragment(true);
} }
//Friends list //Friends list
@ -425,12 +425,16 @@ public class MainActivity extends AppCompatActivity implements
/** /**
* Open notifications fragment * Open notifications fragment
*
* @param addToBackStack Specify whether the change must
* be added to backstack or not
*/ */
void openNotificationsFragment() { void openNotificationsFragment(boolean addToBackStack) {
NotificationsFragment notifications = new NotificationsFragment(); NotificationsFragment notifications = new NotificationsFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.main_fragment, notifications); transaction.replace(R.id.main_fragment, notifications);
transaction.addToBackStack(null); if(addToBackStack)
transaction.addToBackStack(null);
transaction.commit(); transaction.commit();
} }

View File

@ -116,7 +116,7 @@ public class UserPageFragment extends Fragment {
super.onResume(); super.onResume();
//Check if we got information about the user //Check if we got information about the user
if(userInfo == null){ if(userInfo == null || mTabLayout.getTabCount() < 2){
//Show loading alert dialog //Show loading alert dialog
loadingDialog = UiUtils.create_loading_dialog(getActivity()); loadingDialog = UiUtils.create_loading_dialog(getActivity());
@ -197,5 +197,6 @@ public class UserPageFragment extends Fragment {
mPager.setAdapter(adapter); mPager.setAdapter(adapter);
mTabLayout.setupWithViewPager(mPager); mTabLayout.setupWithViewPager(mPager);
} }
} }