use of ch.hsr.sa.radiotour.controller.adapter.ViewPageAdapter in project app by TourLive.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
activity = this;
initViewsAndHandlers();
TabLayout tabLayout = findViewById(R.id.tabs);
viewPager = findViewById(R.id.viewpager);
viewPageAdapter = new ViewPageAdapter(getSupportFragmentManager());
viewPager.setAdapter(viewPageAdapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
viewPager.setOffscreenPageLimit(5);
setTabMenu();
viewPageAdapter.notifyDataSetChanged();
tabLayout.setupWithViewPager(viewPager);
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
// Has to be implemented but not needed
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
if (tab.getText().toString().equals(getString(R.string.header_special_class))) {
closeDetailJudgmentFragment();
}
if (tab.getText().toString().equals(getString(R.string.header_ridergroup))) {
resetStateRiders(viewPageAdapter.getItem(tab.getPosition()));
}
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
if (tab.getText().toString().equals(getString(R.string.header_special_class))) {
closeDetailJudgmentFragment();
}
}
});
}
Aggregations