本文整理汇总了Java中com.mikepenz.materialdrawer.model.PrimaryDrawerItem类的典型用法代码示例。如果您正苦于以下问题:Java PrimaryDrawerItem类的具体用法?Java PrimaryDrawerItem怎么用?Java PrimaryDrawerItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrimaryDrawerItem类属于com.mikepenz.materialdrawer.model包,在下文中一共展示了PrimaryDrawerItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialDrawerItems
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; //导入依赖的package包/类
private void initialDrawerItems() {
//Menu Items
mDrawerItem_Parser = new PrimaryDrawerItem().withName("Source").withIcon(R.mipmap.ic_launcher).withIdentifier(1);
mDrawerItem_Catalog = new PrimaryDrawerItem().withName(R.string.menu_title_catalog).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_public_black_24dp : R.drawable.ic_public_white_24dp).withIdentifier(2);
mDrawerItem_Library = new PrimaryDrawerItem().withName(R.string.menu_title_library).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_home_black_24dp : R.drawable.ic_home_white_24dp).withIdentifier(3);
mDrawerItem_Favorites = new PrimaryDrawerItem().withName(R.string.menu_title_favorites).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_favorite_black_24dp : R.drawable.ic_favorite_white_24dp).withIdentifier(4);
mDrawerItem_History = new PrimaryDrawerItem().withName(R.string.menu_title_history).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_history_black_24dp : R.drawable.ic_history_white_24dp).withIdentifier(5);
mDrawerItem_Downloads = new PrimaryDrawerItem().withName(R.string.menu_title_downloads).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_save_black_24dp : R.drawable.ic_save_white_24dp).withIdentifier(6);
mDrawerItem_AllManga = new PrimaryDrawerItem().withName(R.string.menu_title_all_anime).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_public_black_24dp : R.drawable.ic_public_white_24dp).withIdentifier(7);
mDrawerItem_Genres = new PrimaryDrawerItem().withName(R.string.menu_title_genres).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_filter_list_black_24dp : R.drawable.ic_filter_list_white_24dp).withIdentifier(8);
mDrawerItem_LatestReleases = new PrimaryDrawerItem().withName(R.string.menu_title_latest_releases).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_new_releases_black_24dp : R.drawable.ic_new_releases_white_24dp).withIdentifier(9);
mDrawerItem_RandomManga = new PrimaryDrawerItem().withName(R.string.menu_title_random_anime).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_help_outline_black_24dp : R.drawable.ic_help_outline_white_24dp).withIdentifier(10);
mDrawerItem_AdvancedSearch = new PrimaryDrawerItem().withName(R.string.menu_title_advanced_search).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_search_black_24dp : R.drawable.ic_search_white_24dp).withIdentifier(11);
mDrawerItem_NewSeries = new PrimaryDrawerItem().withName(R.string.menu_title_new_series).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_today_black_24dp : R.drawable.ic_today_white_24dp).withIdentifier(12);
//new PrimaryDrawerItem().withName(R.string.menu_title_queue).withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_comment_list)).withIdentifier(14);
mDrawerItem_ServerSearch = new PrimaryDrawerItem().withName("Search Online").withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_search_black_24dp : R.drawable.ic_search_white_24dp).withIdentifier(15);
mDrawerItem_Settings = new PrimaryDrawerItem().withName(R.string.menu_title_settings).withIcon(ThemeManager.getInstance().isLightBackground() ? R.drawable.ic_settings_black_24dp : R.drawable.ic_settings_white_24dp).withIdentifier(16);
mDrawerItem_Patreon = new PrimaryDrawerItem().withName(R.string.menu_title_patreon).withIcon(R.drawable.patreon).withIdentifier(17);
mDrawerItem_Version = new SecondaryDrawerItem().withName("Version: " + BuildConfig.VERSION_NAME).withSelectable(false);
}
示例2: switchMenu
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; //导入依赖的package包/类
private void switchMenu(PrimaryDrawerItem item) {
String tag = item.getName().getText(this);
AppLog.d("switch menu tag:" + tag);
Fragment fragment = mFragmentManager.findFragmentByTag(tag);
AppLog.d("switch menu fragment:" + fragment);
if (fragment != null) {
if (fragment == mCurrentFragment) return;
mFragmentManager.beginTransaction().show(fragment).commit();
}
else {
fragment = Fragment.instantiate(this, (String) item.getTag());
mFragmentManager.beginTransaction().add(R.id.content_frame, fragment, tag).commit();
}
if (mCurrentFragment != null) {
mFragmentManager.beginTransaction().hide(mCurrentFragment).commit();
}
mCurrentFragment = fragment;
setTitle(tag);
}
示例3: 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);
}
示例4: 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;
}
示例5: initDrawer
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; //导入依赖的package包/类
@UiThread void initDrawer() {
PrimaryDrawerItem home =
new PrimaryDrawerItem().withName(R.string.home).withIcon(GoogleMaterial.Icon.gmd_home);
new DrawerBuilder().withActivity((Activity) act)
.withToolbar(toolbar)
.withHasStableIds(true)
.withTranslucentStatusBar(true)
.withSelectedItem(-1)
.withAccountHeader(headerResult)
.addDrawerItems(home)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
switch (position) {
case 1:
context.startActivity(new Intent(context, MainActivity_.class));
return true;
default:
return true;
}
}
})
.build();
}
示例6: 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);
}
示例7: onCreateView
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
// don't look at this layout it's just a listView to show how to handle the keyboard
View view = inflater.inflate(R.layout.fragment_simple_sample, container, false);
result = new DrawerBuilder()
.withActivity(getActivity())
.withRootView((ViewGroup) view.findViewById(R.id.rootView))
.withDisplayBelowStatusBar(false)
.withSavedInstance(savedInstanceState)
.addDrawerItems(
new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home).withIdentifier(1),
new PrimaryDrawerItem().withName(R.string.drawer_item_free_play).withIcon(FontAwesome.Icon.faw_gamepad),
new PrimaryDrawerItem().withName(R.string.drawer_item_custom).withIcon(FontAwesome.Icon.faw_eye)
)
.buildForFragment();
TextView textView = (TextView) view.findViewById(R.id.title);
textView.setText(getArguments().getString(KEY_TITLE));
result.getDrawerLayout().setFitsSystemWindows(false);
result.getSlider().setFitsSystemWindows(false);
return view;
}
示例8: addGiveawayItems
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; //导入依赖的package包/类
/**
* Add all Navbar icons related to giveaways.
*/
private void addGiveawayItems(SteamGiftsUserData account) {
// All different giveaway views
drawer.addItems(
new SectionDrawerItem().withName(R.string.navigation_giveaways).withDivider(!account.isLoggedIn()),
new PrimaryDrawerItem().withName(R.string.navigation_giveaways_all).withIdentifier(R.string.navigation_giveaways_all).withIcon(FontAwesome.Icon.faw_gift));
// If we're logged in, we can look at group and wishlist giveaways.
if (account.isLoggedIn()) {
drawer.addItems(
new PrimaryDrawerItem().withName(R.string.navigation_giveaways_group).withIdentifier(R.string.navigation_giveaways_group).withIcon(FontAwesome.Icon.faw_users),
new PrimaryDrawerItem().withName(R.string.navigation_giveaways_wishlist).withIdentifier(R.string.navigation_giveaways_wishlist).withIcon(FontAwesome.Icon.faw_heart),
new PrimaryDrawerItem().withName(R.string.navigation_giveaways_recommended).withIdentifier(R.string.navigation_giveaways_recommended).withIcon(FontAwesome.Icon.faw_thumbs_up));
}
drawer.addItems(new PrimaryDrawerItem().withName(R.string.navigation_giveaways_new).withIdentifier(R.string.navigation_giveaways_new).withIcon(FontAwesome.Icon.faw_refresh));
}
示例9: addDiscussionItems
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; //导入依赖的package包/类
/**
* Add all discussion-related items.
*/
private void addDiscussionItems(SteamGiftsUserData account, String mode) {
if ("full".equals(mode)) {
// Full mode: Show all different categories in the navbar
drawer.addItem(new SectionDrawerItem().withName(R.string.navigation_discussions).withDivider(true));
for (DiscussionListFragment.Type type : DiscussionListFragment.Type.values()) {
// We only want to have 'Created Discussions' if we're actually logged in.
if (type == DiscussionListFragment.Type.CREATED && !account.isLoggedIn())
continue;
drawer.addItem(new PrimaryDrawerItem().withName(type.getNavbarResource()).withIdentifier(type.getNavbarResource()).withIcon(type.getIcon()));
}
} else if ("compact".equals(mode)) {
// Compact mode: we only add a single item called 'Discussions' that links to all discussions,
// and there's a menu item in the 'discussions' list to switch between different categories.
drawer.addItem(new PrimaryDrawerItem().withName(R.string.navigation_discussions).withIdentifier(DiscussionListFragment.Type.ALL.getNavbarResource()).withIcon(DiscussionListFragment.Type.ALL.getIcon()));
}
}
示例10: 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);
}
示例11: onFetchUserInfoSuccess
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; //导入依赖的package包/类
private void onFetchUserInfoSuccess(Account me, String domain) {
// Add the header image and avatar from the account, into the navigation drawer header.
ImageView background = headerResult.getHeaderBackgroundView();
background.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background_dark));
Picasso.with(MainActivity.this)
.load(me.header)
.placeholder(R.drawable.account_header_default)
.into(background);
headerResult.clear();
headerResult.addProfiles(
new ProfileDrawerItem()
.withName(me.getDisplayName())
.withEmail(String.format("%[email protected]%s", me.username, domain))
.withIcon(me.avatar)
);
// Show follow requests in the menu, if this is a locked account.
if (me.locked) {
PrimaryDrawerItem followRequestsItem = new PrimaryDrawerItem()
.withIdentifier(DRAWER_ITEM_FOLLOW_REQUESTS)
.withName(R.string.action_view_follow_requests)
.withSelectable(false)
.withIcon(GoogleMaterial.Icon.gmd_person_add);
drawer.addItemAtPosition(followRequestsItem, 3);
}
// Update the current login information.
loggedInAccountId = me.id;
loggedInAccountUsername = me.username;
getPrivatePreferences().edit()
.putString("loggedInAccountId", loggedInAccountId)
.putString("loggedInAccountUsername", loggedInAccountUsername)
.putBoolean("loggedInAccountLocked", me.locked)
.apply();
}
示例12: getDrawerItems
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; //导入依赖的package包/类
/**
* @return the list of items
*/
public ArrayList<IDrawerItem> getDrawerItems() {
// The menu items in the drawer
ArrayList<IDrawerItem> items = new ArrayList<>();
// Dashboard
//if you want to update the items at a later time it is recommended to keep it in a variable
//@formatter:off
items.add(new PrimaryDrawerItem()
.withName(MenuItem.MENU_ITEM1.mLabel).withIcon(Octicons.Icon.oct_dashboard)
.withIconColorRes(R.color.menu_item_1).withSelectedIconColorRes(R.color.menu_item_1));
items.add(new PrimaryDrawerItem()
.withName(MenuItem.MENU_ITEM2.mLabel).withIcon(Octicons.Icon.oct_graph)
.withIconColorRes(R.color.menu_item_2).withSelectedIconColorRes(R.color.menu_item_2));
items.add(new PrimaryDrawerItem()
.withName(MenuItem.MENU_ITEM3.mLabel).withIcon(FontAwesome.Icon.faw_sign_out)
.withIconColorRes(R.color.menu_item_3).withSelectedIconColorRes(R.color.menu_item_3));
items.add(new PrimaryDrawerItem()
.withName(MenuItem.MENU_ITEM4.mLabel).withIcon(FontAwesome.Icon.faw_sign_out)
.withIconColorRes(R.color.menu_item_4).withSelectedIconColorRes(R.color.menu_item_4));
items.add(new PrimaryDrawerItem()
.withName(MenuItem.MENU_ITEM5.mLabel).withIcon(FontAwesome.Icon.faw_sign_out)
.withIconColorRes(R.color.menu_item_5).withSelectedIconColorRes(R.color.menu_item_5));
//@formatter:on
decorate(items);
return items;
}
示例13: decorate
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; //导入依赖的package包/类
private void decorate(ArrayList<IDrawerItem> items) {
for (IDrawerItem item : items) {
if (item instanceof PrimaryDrawerItem) {
((PrimaryDrawerItem) item).withSelectedColorRes(R.color.menu_item_selected);
}
}
}
示例14: getDrawerItems
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; //导入依赖的package包/类
private IDrawerItem[] getDrawerItems(){
int primaryColor = Color.parseColor(SSColorTheme.getInstance().getColorPrimary());
ssDrawerItems[0] = new PrimaryDrawerItem().withName(getString(R.string.ss_menu_read_now)).withIcon(GoogleMaterial.Icon.gmd_book).withIdentifier(MENU_READ_ID).withSelectable(false).withSelectedIconColor(primaryColor).withSelectedTextColor(primaryColor);
ssDrawerItems[1] = new PrimaryDrawerItem().withName(getString(R.string.ss_menu_my_highlights)).withIcon(GoogleMaterial.Icon.gmd_border_color).withIdentifier(MENU_HIGHLIGHTS_ID).withSelectable(false).withSelectedIconColor(primaryColor).withSelectedTextColor(primaryColor);
ssDrawerItems[2] = new PrimaryDrawerItem().withName(getString(R.string.ss_menu_my_notes)).withIcon(GoogleMaterial.Icon.gmd_comment).withIdentifier(MENU_NOTES_ID).withSelectable(false).withSelectedIconColor(primaryColor).withSelectedTextColor(primaryColor);
ssDrawerItems[3] = new PrimaryDrawerItem().withName(getString(R.string.ss_menu_settings)).withIcon(GoogleMaterial.Icon.gmd_settings).withIdentifier(MENU_SETTINGS_ID).withSelectable(false).withSelectedIconColor(primaryColor).withSelectedTextColor(primaryColor);
ssDrawerItems[4] = new DividerDrawerItem();
ssDrawerItems[5] = new PrimaryDrawerItem().withName(getString(R.string.ss_menu_share_app)).withIdentifier(MENU_SHARE_ID).withSelectable(false).withSelectedTextColor(primaryColor);
ssDrawerItems[6] = new PrimaryDrawerItem().withName(getString(R.string.ss_menu_about)).withIdentifier(MENU_ABOUT_ID).withSelectable(false).withSelectedTextColor(primaryColor);
return ssDrawerItems;
}
示例15: setDrawer
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; //导入依赖的package包/类
protected void setDrawer(Boolean upEnabled) {
Toolbar toolbar_main = (Toolbar) findViewById(R.id.toolbar_main);
setSupportActionBar(toolbar_main);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null)
if (upEnabled) {
supportActionBar.setDisplayHomeAsUpEnabled(true);
} else {
final Intent intent = new Intent(this, FormActivity.class);
new DrawerBuilder()
.withActivity(this)
.withToolbar(toolbar_main)
.addDrawerItems(
new PrimaryDrawerItem()
.withName(R.string.new_task)
.withIcon(MaterialDesignIconic.Icon.gmi_plus)
.withSelectable(false)
.withIdentifier(1)
).withSelectedItem(-1)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
switch (drawerItem.getIdentifier()) {
case 1:
startActivityForResult(intent, NEW_TASK);
break;
}
return false;
}
})
.build();
}
}