use of com.rey.material.widget.TabIndicatorView in project material by rey5137.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dl_navigator = (DrawerLayout) findViewById(R.id.main_dl);
fl_drawer = (FrameLayout) findViewById(R.id.main_fl_drawer);
lv_drawer = (ListView) findViewById(R.id.main_lv_drawer);
mToolbar = (Toolbar) findViewById(R.id.main_toolbar);
vp = (CustomViewPager) findViewById(R.id.main_vp);
tiv = (TabIndicatorView) findViewById(R.id.main_tiv);
mSnackBar = (SnackBar) findViewById(R.id.main_sn);
mToolbarManager = new ToolbarManager(getDelegate(), mToolbar, R.id.tb_group_main, R.style.ToolbarRippleStyle, R.anim.abc_fade_in, R.anim.abc_fade_out);
mToolbarManager.setNavigationManager(new ToolbarManager.ThemableNavigationManager(R.array.navigation_drawer, getSupportFragmentManager(), mToolbar, dl_navigator) {
@Override
public void onNavigationClick() {
// if (mToolbarManager.getCurrentGroup() != R.id.tb_group_main)
// mToolbarManager.setCurrentGroup(R.id.tb_group_main);
// else
// dl_navigator.openDrawer(GravityCompat.START);
mToolbarManager.setNavigationVisisble(false, true);
}
@Override
public boolean isBackState() {
return super.isBackState() || mToolbarManager.getCurrentGroup() != R.id.tb_group_main;
}
@Override
protected boolean shouldSyncDrawerSlidingProgress() {
return super.shouldSyncDrawerSlidingProgress() && mToolbarManager.getCurrentGroup() == R.id.tb_group_main;
}
});
mToolbarManager.registerOnToolbarGroupChangedListener(this);
mDrawerAdapter = new DrawerAdapter(this);
lv_drawer.setAdapter(mDrawerAdapter);
mPagerAdapter = new PagerAdapter(getSupportFragmentManager(), mItems);
vp.setAdapter(mPagerAdapter);
tiv.setTabIndicatorFactory(new TabIndicatorView.ViewPagerIndicatorFactory(vp));
vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
mDrawerAdapter.setSelected(mItems[position]);
mSnackBar.dismiss();
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
mDrawerAdapter.setSelected(Tab.PROGRESS);
vp.setCurrentItem(0);
ViewUtil.setBackground(getWindow().getDecorView(), new ThemeDrawable(R.array.bg_window));
ViewUtil.setBackground(mToolbar, new ThemeDrawable(R.array.bg_toolbar));
}
Aggregations