Search in sources :

Example 26 with BadgeDrawable

use of com.google.android.material.badge.BadgeDrawable in project GreenHouse by utsanjan.

the class BottomNavigationMenuView method getOrCreateBadge.

/* JADX INFO: Access modifiers changed from: package-private */
public BadgeDrawable getOrCreateBadge(int menuItemId) {
    validateMenuItemId(menuItemId);
    BadgeDrawable badgeDrawable = this.badgeDrawables.get(menuItemId);
    if (badgeDrawable == null) {
        badgeDrawable = BadgeDrawable.create(getContext());
        this.badgeDrawables.put(menuItemId, badgeDrawable);
    }
    BottomNavigationItemView itemView = findItemView(menuItemId);
    if (itemView != null) {
        itemView.setBadge(badgeDrawable);
    }
    return badgeDrawable;
}
Also used : BadgeDrawable(com.google.android.material.badge.BadgeDrawable)

Example 27 with BadgeDrawable

use of com.google.android.material.badge.BadgeDrawable in project sesl by OneUIProject.

the class NavigationBarMenuView method setBadgeIfNeeded.

private void setBadgeIfNeeded(@NonNull NavigationBarItemView child) {
    int childId = child.getId();
    if (!isValidId(childId)) {
        // Child doesn't have a valid id, do not set any BadgeDrawable on the view.
        return;
    }
    BadgeDrawable badgeDrawable = badgeDrawables.get(childId);
    if (badgeDrawable != null) {
        child.setBadge(badgeDrawable);
    }
}
Also used : BadgeDrawable(com.google.android.material.badge.BadgeDrawable) SuppressLint(android.annotation.SuppressLint)

Example 28 with BadgeDrawable

use of com.google.android.material.badge.BadgeDrawable in project AppManager by MuntashirAkon.

the class ReflowMenuView method removeBadge.

void removeBadge(int menuItemId) {
    validateMenuItemId(menuItemId);
    BadgeDrawable badgeDrawable = badgeDrawables.get(menuItemId);
    ReflowMenuItemView itemView = findItemView(menuItemId);
    if (itemView != null) {
        itemView.removeBadge();
    }
    if (badgeDrawable != null) {
        badgeDrawables.remove(menuItemId);
    }
}
Also used : BadgeDrawable(com.google.android.material.badge.BadgeDrawable)

Example 29 with BadgeDrawable

use of com.google.android.material.badge.BadgeDrawable in project ods-android by Orange-OpenSource.

the class TabsMainDemoFragment method setupBadging.

private void setupBadging() {
    for (TabLayout tabLayout : tabLayouts) {
        // An icon only badge will be displayed.
        BadgeDrawable badgeDrawable = tabLayout.getTabAt(0).getOrCreateBadge();
        badgeDrawable.setVisible(true);
        // A badge with the text "99" will be displayed.
        badgeDrawable = tabLayout.getTabAt(1).getOrCreateBadge();
        badgeDrawable.setVisible(true);
        badgeDrawable.setNumber(99);
        // A badge with the text "999+" will be displayed.
        badgeDrawable = tabLayout.getTabAt(2).getOrCreateBadge();
        badgeDrawable.setVisible(true);
        badgeDrawable.setNumber(9999);
        tabLayout.addOnTabSelectedListener(new OnTabSelectedListener() {

            @Override
            public void onTabSelected(Tab tab) {
                clearAndHideBadge(tab.getPosition());
            }

            @Override
            public void onTabUnselected(Tab tab) {
            }

            @Override
            public void onTabReselected(Tab tab) {
                clearAndHideBadge(tab.getPosition());
            }
        });
    }
}
Also used : BadgeDrawable(com.google.android.material.badge.BadgeDrawable) Tab(com.google.android.material.tabs.TabLayout.Tab) TabLayout(com.google.android.material.tabs.TabLayout) OnTabSelectedListener(com.google.android.material.tabs.TabLayout.OnTabSelectedListener)

Example 30 with BadgeDrawable

use of com.google.android.material.badge.BadgeDrawable in project ods-android by Orange-OpenSource.

the class TabsMainDemoFragment method incrementBadgeNumber.

private void incrementBadgeNumber() {
    for (TabLayout tabLayout : tabLayouts) {
        // Increase the badge number on the first tab position.
        // In case the first tab has been selected and the badge was hidden, call
        // BadgeDrawable#setVisible() to ensure the badge is visible.
        BadgeDrawable badgeDrawable = tabLayout.getTabAt(0).getOrCreateBadge();
        badgeDrawable.setVisible(true);
        badgeDrawable.setNumber(badgeDrawable.getNumber() + 1);
    }
}
Also used : BadgeDrawable(com.google.android.material.badge.BadgeDrawable) TabLayout(com.google.android.material.tabs.TabLayout)

Aggregations

BadgeDrawable (com.google.android.material.badge.BadgeDrawable)34 MenuItem (android.view.MenuItem)7 BottomNavigationView (com.google.android.material.bottomnavigation.BottomNavigationView)7 SuppressLint (android.annotation.SuppressLint)5 TabLayout (com.google.android.material.tabs.TabLayout)5 View (android.view.View)4 TextView (android.widget.TextView)4 Bundle (android.os.Bundle)3 ViewGroup (android.view.ViewGroup)3 ImageView (android.widget.ImageView)3 NonNull (androidx.annotation.NonNull)3 Intent (android.content.Intent)2 SharedPreferences (android.content.SharedPreferences)2 Resources (android.content.res.Resources)2 Bitmap (android.graphics.Bitmap)2 Handler (android.os.Handler)2 Message (android.os.Message)2 TextUtils (android.text.TextUtils)2 KeyEvent (android.view.KeyEvent)2 WindowManager (android.view.WindowManager)2