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);
}
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());
}
}
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);
}
}
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;
}
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;
}
Aggregations