diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java index dd84981..68a8f69 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java @@ -134,8 +134,8 @@ public class MainActivity extends AppCompatActivity implements conversationsListHelper = new ConversationsListHelper(this, dbHelper); //If it is the first time the application is launched, open notifications fragment - if (savedInstanceState == null) { - openNotificationsFragment(); + if (savedInstanceState == null){ + openNotificationsFragment(false); } } @@ -305,7 +305,7 @@ public class MainActivity extends AppCompatActivity implements //Notification fragment if(id == R.id.action_notifications){ - openNotificationsFragment(); + openNotificationsFragment(true); } //Friends list @@ -425,12 +425,16 @@ public class MainActivity extends AppCompatActivity implements /** * 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(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.main_fragment, notifications); - transaction.addToBackStack(null); + if(addToBackStack) + transaction.addToBackStack(null); transaction.commit(); } diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java index a9ed99f..a7f0eb2 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java @@ -116,7 +116,7 @@ public class UserPageFragment extends Fragment { super.onResume(); //Check if we got information about the user - if(userInfo == null){ + if(userInfo == null || mTabLayout.getTabCount() < 2){ //Show loading alert dialog loadingDialog = UiUtils.create_loading_dialog(getActivity()); @@ -197,5 +197,6 @@ public class UserPageFragment extends Fragment { mPager.setAdapter(adapter); mTabLayout.setupWithViewPager(mPager); + } }