@Override public void onTabSelected(Tab tab, FragmentTransaction ft) { TiUIActionBarTab tabView = (TiUIActionBarTab) tab.getTag(); if (tabView.fragment == null) { // If not we will create it here then attach it // to the tab group activity inside the "content" container. tabView.initializeFragment(); } tabGroupViewPager.setCurrentItem(tab.getPosition()); TabProxy tabProxy = (TabProxy) tabView.getProxy(); ((TabGroupProxy) proxy).onTabSelected(tabProxy); if (tabClicked) { tabProxy.fireEvent(TiC.EVENT_CLICK, null); } else { tabClicked = true; } tabProxy.fireEvent(TiC.EVENT_SELECTED, null, false); }
@Override public TabProxy getSelectedTab() { ActionBar.Tab tab; try { tab = actionBar.getSelectedTab(); } catch (NullPointerException e) { // This is a workaround for AppCompat actionbar 4.0+. There is a bug in AppCompat source that // will cause a null pointer exception if no tab is selected instead of returning null. See // source at: // https://android.googlesource.com/platform/frameworks/support/+/89208232f3b5d1451408d787872504a190bc7ee0/v7/appcompat/src/android/support/v7/app/ActionBarImplICS.java // line 259. tab = null; } if (tab == null) { // There is no selected tab currently for this action bar. // This probably means the tab group contains no tabs. return null; } TiUIActionBarTab tabView = (TiUIActionBarTab) tab.getTag(); return (TabProxy) tabView.getProxy(); }
@Override public void onTabUnselected(Tab tab, FragmentTransaction ft) { TiUIActionBarTab tabView = (TiUIActionBarTab) tab.getTag(); TabProxy tabProxy = (TabProxy) tabView.getProxy(); tabProxy.fireEvent(TiC.EVENT_UNSELECTED, null, false); }