use of com.thebluealliance.androidclient.adapters.EventsByWeekFragmentPagerAdapter in project the-blue-alliance-android by the-blue-alliance.
the class EventsByWeekFragment method getIndexForWeek.
/**
* Finds the index in the adapter of the given week.
* If the week is skipped over, return the next week (assumes sorted adapter items)
*
* @return Adapter index containing the week, -1 if not found
*/
private int getIndexForWeek(int week) {
Preconditions.checkState(mViewPager.getAdapter() instanceof EventsByWeekFragmentPagerAdapter, "EventsByWeekFragment must use EventsByWeekFragmentPagerAdapter");
List<EventWeekTab> tabs = ((EventsByWeekFragmentPagerAdapter) mViewPager.getAdapter()).getTabs();
for (int i = 0; i < tabs.size(); i++) {
if (tabs.get(i).getWeek() >= week) {
return i;
}
}
return -1;
}
use of com.thebluealliance.androidclient.adapters.EventsByWeekFragmentPagerAdapter in project the-blue-alliance-android by the-blue-alliance.
the class EventsByWeekFragment method updateLabels.
public void updateLabels(List<EventWeekTab> labels) {
if (getView() != null) {
getView().findViewById(R.id.tabs_progress).setVisibility(View.GONE);
}
mFragmentAdapter = new EventsByWeekFragmentPagerAdapter(getChildFragmentManager(), mYear, labels);
mFragmentBinder.setAdapter(mFragmentAdapter);
mViewPager.setAdapter(mFragmentAdapter);
mTabs.setViewPager(mViewPager);
if (mPagerState != null) {
mViewPager.onRestoreInstanceState(mPagerState);
mFragmentAdapter.restoreState(mAdapterState, ClassLoader.getSystemClassLoader());
} else if (mSelectedTab != -1) {
mViewPager.setCurrentItem(mSelectedTab);
mFragmentBinder.onPageSelected(mSelectedTab);
} else {
setPagerWeek();
mViewPager.setCurrentItem(mSelectedTab);
mFragmentBinder.onPageSelected(mSelectedTab);
}
mFragmentAdapter.setAutoBindOnceAtPosition(mViewPager.getCurrentItem(), true);
}
Aggregations