Search in sources :

Example 1 with BadgeItem

use of com.ashokvarma.bottomnavigation.BadgeItem in project BottomNavigation by Ashok-Varma.

the class HomeActivity method refresh.

private void refresh() {
    bottomNavigationBar.clearAll();
    //        bottomNavigationBar.setFab(fabHome, BottomNavigationBar.FAB_BEHAVIOUR_TRANSLATE_AND_STICK);
    bottomNavigationBar.setFab(fabHome);
    setScrollableText(lastSelectedPosition);
    numberBadgeItem = new BadgeItem().setBorderWidth(4).setBackgroundColorResource(R.color.blue).setText("" + lastSelectedPosition).setHideOnSelect(autoHide.isChecked());
    if (modeFixed.isChecked()) {
        bottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED);
    } else if (modeShifting.isChecked()) {
        bottomNavigationBar.setMode(BottomNavigationBar.MODE_SHIFTING);
    }
    if (bgStatic.isChecked()) {
        bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC);
    } else if (bgRipple.isChecked()) {
        bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_RIPPLE);
    }
    if (items3.isChecked()) {
        if (showTextFlag) {
            bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.ic_location_on_white_24dp, "Nearby").setActiveColorResource(R.color.orange).setBadgeItem(numberBadgeItem)).addItem(new BottomNavigationItem(R.drawable.ic_find_replace_white_24dp, "Find").setActiveColorResource(R.color.teal)).addItem(new BottomNavigationItem(R.drawable.ic_favorite_white_24dp, "Categories").setActiveColorResource(R.color.blue)).setFirstSelectedPosition(lastSelectedPosition > 2 ? 2 : lastSelectedPosition).initialise();
        } else {
            bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.ic_location_on_white_24dp).setActiveColorResource(R.color.orange).setBadgeItem(numberBadgeItem)).addItem(new BottomNavigationItem(R.drawable.ic_find_replace_white_24dp).setActiveColorResource(R.color.teal)).addItem(new BottomNavigationItem(R.drawable.ic_favorite_white_24dp).setActiveColorResource(R.color.blue)).setFirstSelectedPosition(lastSelectedPosition > 2 ? 2 : lastSelectedPosition).initialise();
        }
    } else if (items4.isChecked()) {
        if (showTextFlag) {
            bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.ic_home_white_24dp, "Home").setActiveColorResource(R.color.orange).setBadgeItem(numberBadgeItem)).addItem(new BottomNavigationItem(R.drawable.ic_book_white_24dp, "Books").setActiveColorResource(R.color.teal)).addItem(new BottomNavigationItem(R.drawable.ic_music_note_white_24dp, "Music").setActiveColorResource(R.color.blue)).addItem(new BottomNavigationItem(R.drawable.ic_tv_white_24dp, "Movies & TV").setActiveColorResource(R.color.brown)).setFirstSelectedPosition(lastSelectedPosition > 3 ? 3 : lastSelectedPosition).initialise();
        } else {
            bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.ic_home_white_24dp).setActiveColorResource(R.color.orange).setBadgeItem(numberBadgeItem)).addItem(new BottomNavigationItem(R.drawable.ic_book_white_24dp).setActiveColorResource(R.color.teal)).addItem(new BottomNavigationItem(R.drawable.ic_music_note_white_24dp).setActiveColorResource(R.color.blue)).addItem(new BottomNavigationItem(R.drawable.ic_tv_white_24dp).setActiveColorResource(R.color.brown)).setFirstSelectedPosition(lastSelectedPosition > 3 ? 3 : lastSelectedPosition).initialise();
        }
    } else if (items5.isChecked()) {
        if (showTextFlag) {
            bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.ic_home_white_24dp, "Home").setActiveColorResource(R.color.orange).setBadgeItem(numberBadgeItem)).addItem(new BottomNavigationItem(R.drawable.ic_book_white_24dp, "Books").setActiveColorResource(R.color.teal)).addItem(new BottomNavigationItem(R.drawable.ic_music_note_white_24dp, "Music").setActiveColorResource(R.color.blue)).addItem(new BottomNavigationItem(R.drawable.ic_tv_white_24dp, "Movies & TV").setActiveColorResource(R.color.brown)).addItem(new BottomNavigationItem(R.drawable.ic_videogame_asset_white_24dp, "Games").setActiveColorResource(R.color.grey)).setFirstSelectedPosition(lastSelectedPosition).initialise();
        } else {
            bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.ic_home_white_24dp).setActiveColorResource(R.color.orange).setBadgeItem(numberBadgeItem)).addItem(new BottomNavigationItem(R.drawable.ic_book_white_24dp).setActiveColorResource(R.color.teal)).addItem(new BottomNavigationItem(R.drawable.ic_music_note_white_24dp).setActiveColorResource(R.color.blue)).addItem(new BottomNavigationItem(R.drawable.ic_tv_white_24dp).setActiveColorResource(R.color.brown)).addItem(new BottomNavigationItem(R.drawable.ic_videogame_asset_white_24dp).setActiveColorResource(R.color.grey)).setFirstSelectedPosition(lastSelectedPosition).initialise();
        }
    }
}
Also used : BadgeItem(com.ashokvarma.bottomnavigation.BadgeItem) BottomNavigationItem(com.ashokvarma.bottomnavigation.BottomNavigationItem)

Aggregations

BadgeItem (com.ashokvarma.bottomnavigation.BadgeItem)1 BottomNavigationItem (com.ashokvarma.bottomnavigation.BottomNavigationItem)1