use of com.ashokvarma.bottomnavigation.BottomNavigationBar in project StatusBarUtil by laobie.
the class UseInFragmentActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_use_in_fragment);
mVpHome = (ViewPager) findViewById(R.id.vp_home);
mBottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
mBottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.ic_favorite, "One")).addItem(new BottomNavigationItem(R.drawable.ic_gavel, "Two")).addItem(new BottomNavigationItem(R.drawable.ic_grade, "Three")).addItem(new BottomNavigationItem(R.drawable.ic_group_work, "Four")).initialise();
mBottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener() {
@Override
public void onTabSelected(int position) {
mVpHome.setCurrentItem(position);
}
@Override
public void onTabUnselected(int position) {
}
@Override
public void onTabReselected(int position) {
}
});
mFragmentList.add(new ImageFragment());
mFragmentList.add(new SimpleFragment());
mFragmentList.add(new SimpleFragment());
mFragmentList.add(new SimpleFragment());
mVpHome.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
mBottomNavigationBar.selectTab(position);
switch(position) {
case 0:
break;
default:
Random random = new Random();
int color = 0xff000000 | random.nextInt(0xffffff);
if (mFragmentList.get(position) instanceof SimpleFragment) {
((SimpleFragment) mFragmentList.get(position)).setTvTitleBackgroundColor(color);
}
break;
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
mVpHome.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
});
}
use of com.ashokvarma.bottomnavigation.BottomNavigationBar in project BottomNavigation by Ashok-Varma.
the class BottomNavBarFabBehaviour method getFabTranslationYForBottomNavigationBar.
///////////////////////////////////////////////////////////////////////////
// Fab Translation due to SnackBar and Due to BottomBar
///////////////////////////////////////////////////////////////////////////
private float[] getFabTranslationYForBottomNavigationBar(CoordinatorLayout parent, FloatingActionButton fab) {
float minOffset = 0;
float viewHeight = 0;
final List<View> dependencies = parent.getDependencies(fab);
for (int i = 0, z = dependencies.size(); i < z; i++) {
final View view = dependencies.get(i);
if (view instanceof BottomNavigationBar) {
viewHeight = view.getHeight();
minOffset = Math.min(minOffset, ViewCompat.getTranslationY(view) - viewHeight);
}
}
float[] returnValues = { minOffset, viewHeight };
return returnValues;
}
use of com.ashokvarma.bottomnavigation.BottomNavigationBar in project BottomNavigation by Ashok-Varma.
the class BottomVerticalScrollBehavior method handleDirection.
private void handleDirection(CoordinatorLayout parent, V child, int scrollDirection) {
BottomNavigationBar bottomNavigationBar = mViewRef.get();
if (bottomNavigationBar != null && bottomNavigationBar.isAutoHideEnabled()) {
if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_DOWN && bottomNavigationBar.isHidden()) {
updateSnackBarPosition(parent, child, getSnackBarInstance(parent, child), -mBottomNavHeight);
bottomNavigationBar.show();
} else if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_UP && !bottomNavigationBar.isHidden()) {
updateSnackBarPosition(parent, child, getSnackBarInstance(parent, child), 0);
bottomNavigationBar.hide();
}
}
}
Aggregations