Search in sources :

Example 1 with BadgeDrawable

use of com.google.android.material.badge.BadgeDrawable in project Hentoid by avluis.

the class BaseWebActivity method setActionMode.

/**
 * Switch the action button to either of the available modes
 *
 * @param mode Mode to switch to
 */
private void setActionMode(@ActionMode int mode) {
    @DrawableRes int resId = R.drawable.ic_info;
    if (ActionMode.DOWNLOAD == mode || ActionMode.DOWNLOAD_PLUS == mode) {
        resId = downloadIcon;
    } else if (ActionMode.VIEW_QUEUE == mode) {
        resId = R.drawable.ic_action_queue;
    } else if (ActionMode.READ == mode) {
        resId = R.drawable.ic_action_play;
    }
    BadgeDrawable badge = bottomToolbar.getOrCreateBadge(R.id.web_menu_action);
    badge.setVisible(ActionMode.DOWNLOAD_PLUS == mode);
    actionButtonMode = mode;
    actionMenu.setIcon(resId);
    actionMenu.setEnabled(true);
}
Also used : BadgeDrawable(com.google.android.material.badge.BadgeDrawable) DrawableRes(androidx.annotation.DrawableRes) SuppressLint(android.annotation.SuppressLint)

Example 2 with BadgeDrawable

use of com.google.android.material.badge.BadgeDrawable in project Hentoid by avluis.

the class QueueActivity method onErrorsChanged.

private void onErrorsChanged(List<Content> result) {
    // Update errors tab
    if (result.isEmpty())
        errorsTab.removeBadge();
    else {
        BadgeDrawable badge = errorsTab.getOrCreateBadge();
        badge.setVisible(true);
        badge.setNumber(result.size());
    }
}
Also used : BadgeDrawable(com.google.android.material.badge.BadgeDrawable)

Example 3 with BadgeDrawable

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

the class BottomNavigationMenuView method setBadgeIfNeeded.

private void setBadgeIfNeeded(BottomNavigationItemView child) {
    BadgeDrawable badgeDrawable;
    int childId = child.getId();
    if (isValidId(childId) && (badgeDrawable = this.badgeDrawables.get(childId)) != null) {
        child.setBadge(badgeDrawable);
    }
}
Also used : BadgeDrawable(com.google.android.material.badge.BadgeDrawable)

Example 4 with BadgeDrawable

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

the class BadgeUtils method createBadgeDrawablesFromSavedStates.

public static SparseArray<BadgeDrawable> createBadgeDrawablesFromSavedStates(Context context, ParcelableSparseArray badgeStates) {
    SparseArray<BadgeDrawable> badgeDrawables = new SparseArray<>(badgeStates.size());
    for (int i = 0; i < badgeStates.size(); i++) {
        int key = badgeStates.keyAt(i);
        BadgeDrawable.SavedState savedState = (BadgeDrawable.SavedState) badgeStates.valueAt(i);
        if (savedState != null) {
            BadgeDrawable badgeDrawable = BadgeDrawable.createFromSavedState(context, savedState);
            badgeDrawables.put(key, badgeDrawable);
        } else {
            throw new IllegalArgumentException("BadgeDrawable's savedState cannot be null");
        }
    }
    return badgeDrawables;
}
Also used : BadgeDrawable(com.google.android.material.badge.BadgeDrawable) SparseArray(android.util.SparseArray) ParcelableSparseArray(com.google.android.material.internal.ParcelableSparseArray)

Example 5 with BadgeDrawable

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

the class BadgeUtils method createParcelableBadgeStates.

public static ParcelableSparseArray createParcelableBadgeStates(SparseArray<BadgeDrawable> badgeDrawables) {
    ParcelableSparseArray badgeStates = new ParcelableSparseArray();
    for (int i = 0; i < badgeDrawables.size(); i++) {
        int key = badgeDrawables.keyAt(i);
        BadgeDrawable badgeDrawable = badgeDrawables.valueAt(i);
        if (badgeDrawable != null) {
            badgeStates.put(key, badgeDrawable.getSavedState());
        } else {
            throw new IllegalArgumentException("badgeDrawable cannot be null");
        }
    }
    return badgeStates;
}
Also used : BadgeDrawable(com.google.android.material.badge.BadgeDrawable) ParcelableSparseArray(com.google.android.material.internal.ParcelableSparseArray)

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