I am new to android fragments. I have 3 tabs, first one is for authentication and next 2 are used for some other info which requires a user authentication in first tab to visit these tabs. I am not getting this how can I stop navigating to other fragments until user authentication is performed. I have sample code:
public class SiteSectionsPagerAdapter extends FragmentPagerAdapter {
public SiteSectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return authFragment;
case 1:
return siteInfoFragment;
case 2:
return userInfoFragment;
}
return null;
}
@Override
public int getCount() {
return 3;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "Auth";
case 1:
return "Site info";
case 2:
return "user info";
}
return null;
}
}
In main activity class OnCreate method have like this:
mViewPager = (ViewPager) findViewById(R.id.siteContainer);
mViewPager.setAdapter(mSectionsPagerAdapter);
final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
mViewPager.setCurrentItem(tab.getPosition());
}
Start of application is showing Authfragment first. When user authenticates in this fragment, I have a application in which I am adding a status flag isUserAuthenticate=true;
I am confused on which step I should check that if isUserAuthenticate is true then let him go for next fragment otherwise stop and remain on auth fragment. Can someone give me hint or example.