@Override public Fragment getItem(int position) { Log.i("FRAGMENT", "GETITEM " + position); FriendFragment mf; // MAKE THE FIRST PAGER BIGGER THAN OTHERS if (position == MainActivity.FIRST_PAGE) scale = MainActivity.BIG_SCALE; else scale = MainActivity.SMALL_SCALE; mf = (FriendFragment) FriendFragment.newInstance(context, position, scale, item.get(position)); mFragments.add(mf); return mf; }
@SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_game) { currentGameFragment = GameFragment.getGameFragment(username, MainActivity.this); getFragmentManager().beginTransaction().replace(R.id.container, currentGameFragment).commit(); currentFriendFragment = null; currentGroupFragment = null; currentMessageFragment = null; } else if (id == R.id.nav_friend) { currentFriendFragment = FriendFragment.getFriendFragment(username); getFragmentManager() .beginTransaction() .replace(R.id.container, currentFriendFragment) .commit(); currentGameFragment = null; currentGroupFragment = null; currentMessageFragment = null; } else if (id == R.id.nav_group) { currentGroupFragment = GroupFragment.getGroupFragment(username); getFragmentManager() .beginTransaction() .replace(R.id.container, currentGroupFragment) .commit(); currentGameFragment = null; currentFriendFragment = null; currentMessageFragment = null; } else if (id == R.id.nav_message) { currentMessageFragment = MessageFragment.getMessageFragment(username); getFragmentManager() .beginTransaction() .replace(R.id.container, currentMessageFragment) .commit(); currentGameFragment = null; currentFriendFragment = null; currentGroupFragment = null; } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }