use of com.google.android.material.badge.BadgeDrawable in project ods-android by Orange-OpenSource.
the class NavigationRailDemoFragment method updateBadgeGravity.
private void updateBadgeGravity(@BadgeGravity int badgeGravity) {
for (int i = 0; i < navigationRailView.getMenu().size(); i++) {
// Update the badge gravity on all the menu items.
MenuItem menuItem = navigationRailView.getMenu().getItem(i);
int menuItemId = menuItem.getItemId();
BadgeDrawable badgeDrawable = navigationRailView.getBadge(menuItemId);
if (badgeDrawable != null) {
badgeDrawable.setBadgeGravity(badgeGravity);
}
}
}
use of com.google.android.material.badge.BadgeDrawable in project ods-android by Orange-OpenSource.
the class NavigationRailDemoFragment method clearAndHideBadge.
private void clearAndHideBadge(int menuItemId) {
MenuItem menuItem = navigationRailView.getMenu().getItem(0);
if (menuItem.getItemId() == menuItemId) {
// Hide instead of removing the badge associated with the first menu item because the user
// can trigger it to be displayed again.
BadgeDrawable badgeDrawable = navigationRailView.getBadge(menuItemId);
if (badgeDrawable != null) {
badgeDrawable.setVisible(false);
badgeDrawable.clearNumber();
}
} else {
// Remove the badge associated with this menu item because cannot be displayed again.
navigationRailView.removeBadge(menuItemId);
}
}
use of com.google.android.material.badge.BadgeDrawable in project ods-android by Orange-OpenSource.
the class BottomNavigationDemoFragment method clearAndHideBadge.
private void clearAndHideBadge(int menuItemId) {
for (BottomNavigationView bn : bottomNavigationViews) {
MenuItem menuItem = bn.getMenu().getItem(0);
if (menuItem.getItemId() == menuItemId) {
// Hide instead of removing the badge associated with the first menu item because the user
// can trigger it to be displayed again.
BadgeDrawable badgeDrawable = bn.getBadge(menuItemId);
if (badgeDrawable != null) {
badgeDrawable.setVisible(false);
badgeDrawable.clearNumber();
}
} else {
// Remove the badge associated with this menu item because cannot be displayed again.
bn.removeBadge(menuItemId);
}
}
}
use of com.google.android.material.badge.BadgeDrawable in project ods-android by Orange-OpenSource.
the class BottomNavigationDemoFragment method setupBadging.
private void setupBadging() {
for (BottomNavigationView bn : bottomNavigationViews) {
int menuItemId = bn.getMenu().getItem(0).getItemId();
// An icon only badge will be displayed.
BadgeDrawable badge = bn.getOrCreateBadge(menuItemId);
badge.setVisible(true);
menuItemId = bn.getMenu().getItem(1).getItemId();
// A badge with the text "99" will be displayed.
badge = bn.getOrCreateBadge(menuItemId);
badge.setVisible(true);
badge.setNumber(99);
menuItemId = bn.getMenu().getItem(2).getItemId();
// A badge with the text "999+" will be displayed.
badge = bn.getOrCreateBadge(menuItemId);
badge.setVisible(true);
badge.setNumber(9999);
}
}
Aggregations