Skip to content

Instantly share code, notes, and snippets.

@wesleyfsmith
Created June 14, 2013 21:54
Show Gist options
  • Select an option

  • Save wesleyfsmith/5785589 to your computer and use it in GitHub Desktop.

Select an option

Save wesleyfsmith/5785589 to your computer and use it in GitHub Desktop.
public void selectTab(int itemPosition) {
//hide whatever was previously showing
hideCurrentFragment();
currentTab = availableTabs.get(itemPosition);
//haven't determined where to go yet
if (currentTab == null) {
return;
}
//set animation here
showFragment(tabFragments.get(currentTab.getLabel()));
}
private void showDefaultTab() {
//create fragments
createFragments();
try {
selectTab(getString(R.string.home));
} catch (IndexOutOfBoundsException e) {
//catch this exception, and keep navigation item
//null if we don't have any tabs
hideLoadingMessages();
showErrorMessage();
//kick them off the current fragment
hideCurrentFragment();
currentTab = null;
}
//if the list has where we want to go
if (availableTabs.contains(currentTab)) {
hideLoadingMessages();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment