本文整理汇总了Java中com.mikepenz.materialdrawer.model.PrimaryDrawerItem.withBadge方法的典型用法代码示例。如果您正苦于以下问题:Java PrimaryDrawerItem.withBadge方法的具体用法?Java PrimaryDrawerItem.withBadge怎么用?Java PrimaryDrawerItem.withBadge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mikepenz.materialdrawer.model.PrimaryDrawerItem
的用法示例。
在下文中一共展示了PrimaryDrawerItem.withBadge方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDrawerItem
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; //导入方法依赖的package包/类
private IDrawerItem getDrawerItem(Realm realm, TreeItem item) {
boolean shouldSelect;
PrimaryDrawerItem drawerItem = new TreeItemDrawerItem(item);
if (item instanceof Feed) {
shouldSelect = state.isFeedSelected();
} else {
shouldSelect = !state.isFeedSelected();
}
shouldSelect = shouldSelect && state.getStartDrawerItem().getId() == item.getId();
drawerItem.withBadge(item.getCount(realm));
return drawerItem.withSetSelected(shouldSelect);
}
示例2: reloadDrawerItems
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; //导入方法依赖的package包/类
@Override
protected List<IDrawerItem> reloadDrawerItems(Realm realm, boolean showOnlyUnread) {
List<Feed> feeds = state.getStartDrawerItem().getFeeds(realm, showOnlyUnread);
List<IDrawerItem> drawerItems = new ArrayList<>((feeds != null ? feeds.size() : 0) + 1);
if (state.isFeedSelected())
return drawerItems;
drawerItems.add(new SectionDrawerItem()
.withDivider(false)
.withName(state.getStartDrawerItem().getName()));
if (feeds != null) {
for (Feed feed : feeds) {
PrimaryDrawerItem drawerItem = new TreeItemDrawerItem(feed);
drawerItem.withIdentifier(feed.getId());
drawerItem.withBadge(feed.getUnreadCount());
drawerItem.withSetSelected(state.getEndDrawerItem() != null && state.getEndDrawerItem().getId() == feed.getId());
drawerItems.add(drawerItem);
}
}
return drawerItems;
}
示例3: onResume
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
startTimer();
getData();
((CoreApplication) getApplication()).mainActivityInstance=this;
checkLocationPermission();
//DrawerItems
PrimaryDrawerItem beaconItem = ((PrimaryDrawerItem)drawer.getDrawerItem(2));
PrimaryDrawerItem geofenceItem = ((PrimaryDrawerItem)drawer.getDrawerItem(3));
beaconItem.withBadge(AppPreferences.getBeaconDetectionState()? "On":"Off");
geofenceItem.withBadge(AppPreferences.getGeofenceDetectionState()? "On":"Off");
drawer.updateItem(beaconItem);
drawer.updateItem(geofenceItem);
}
示例4: onPharmacyModeChanged
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; //导入方法依赖的package包/类
public void onPharmacyModeChanged(boolean enabled) {
PrimaryDrawerItem item = (PrimaryDrawerItem) drawer.getDrawerItem(PHARMACIES);
BadgeStyle bs = new BadgeStyle();
if (enabled) {
addCalendarItem();
Drawable bg = new IconicsDrawable(home)
.icon(GoogleMaterial.Icon.gmd_check)
.color(home.getResources().getColor(R.color.dark_grey_text))
.sizeDp(18);
bs.withBadgeBackground(bg);
} else {
drawer.removeItem(CALENDAR);
bs.withBadgeBackground(new ColorDrawable(Color.TRANSPARENT));
}
item.withBadgeStyle(bs);
item.withBadge(" ");
drawer.updateItem(item);
}