Java Code Examples for com.mikepenz.materialdrawer.model.PrimaryDrawerItem
The following are top voted examples for showing how to use
com.mikepenz.materialdrawer.model.PrimaryDrawerItem. These examples are extracted from open source projects.
You can vote up the examples you like and your votes will be used in our system to generate
more good examples.
Example 1
Project: MyAnimeViewer File: MainActivity.java View source code | 6 votes |
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); }
Example 2
Project: githubclient File: MainActivity.java View source code | 6 votes |
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); }
Example 3
Project: ocreader File: DrawerManager.java View source code | 6 votes |
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); }
Example 4
Project: ocreader File: DrawerManager.java View source code | 6 votes |
@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; }
Example 5
Project: cartolapp File: ToolbarBase.java View source code | 6 votes |
@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(); }
Example 6
Project: LETO-Toggl_Android File: MainActivity.java View source code | 6 votes |
@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); }
Example 7
Project: MaterialDrawer File: SecondDrawerFragment.java View source code | 6 votes |
@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; }
Example 8
Project: SteamGifts File: Navbar.java View source code | 6 votes |
/** * 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)); }
Example 9
Project: SteamGifts File: Navbar.java View source code | 6 votes |
/** * 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())); } }
Example 10
Project: SteamGifts File: Navbar.java View source code | 6 votes |
/** * 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)); }
Example 11
Project: SteamGifts File: Navbar.java View source code | 6 votes |
/** * 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())); } }
Example 12
Project: calendula File: LeftDrawerMgr.java View source code | 6 votes |
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); }
Example 13
Project: Tusky File: MainActivity.java View source code | 5 votes |
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(); }
Example 14
Project: FragmentNavigationPatternDemo File: DrawerManager.java View source code | 5 votes |
/** * @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; }
Example 15
Project: FragmentNavigationPatternDemo File: DrawerManager.java View source code | 5 votes |
private void decorate(ArrayList<IDrawerItem> items) { for (IDrawerItem item : items) { if (item instanceof PrimaryDrawerItem) { ((PrimaryDrawerItem) item).withSelectedColorRes(R.color.menu_item_selected); } } }
Example 16
Project: sabbath-school-android File: SSBaseActivity.java View source code | 5 votes |
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; }
Example 17
Project: duedo File: BaseActivity.java View source code | 5 votes |
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(); } }
Example 18
Project: ocreader File: DrawerManager.java View source code | 5 votes |
@Override protected List<IDrawerItem> reloadDrawerItems(Realm realm, boolean showOnlyUnread) { List<IDrawerItem> drawerItems = new ArrayList<>(); ((AbstractSwitchableDrawerItem)topDrawerItems.get(0)).withChecked(showOnlyUnread); drawerItems.addAll(topDrawerItems); for(IDrawerItem drawerItem: topDrawerItems) { if(drawerItem.getTag() instanceof TreeItem) { TreeItem item = (TreeItem) drawerItem.getTag(); int count = item.getCount(realm); if(count > 0 && drawerItem instanceof Badgeable) ((Badgeable) drawerItem).withBadge(String.valueOf(count)); if (state.getStartDrawerItem().getId() == item.getId()) { drawerItem.withSetSelected(true); break; } } } final List<TreeItem> treeItems = new ArrayList<>(); treeItems.addAll(Folder.getAll(realm, showOnlyUnread)); treeItems.addAll(Queries.getFeedsWithoutFolder(realm, showOnlyUnread)); if(treeItems.isEmpty()) { drawerItems.add( new PrimaryDrawerItem() .withEnabled(false) .withName(R.string.no_folders_to_show) ); } else { for (TreeItem treeItem : treeItems) { drawerItems.add(getDrawerItem(realm, treeItem)); } } return drawerItems; }
Example 19
Project: Droid2JoyStick File: MainActivity.java View source code | 5 votes |
private void setupNavigationDrawer() { ProfileDrawerItem section = new ProfileDrawerItem() .withSetSelected(false) .withSetSelected(false) .withEnabled(false); PrimaryDrawerItem joyType0DrawerItem = new PrimaryDrawerItem().withName("Basic Gamepad").withTag(KEY_BASIC_GAMEPAD_1).withLevel(2); PrimaryDrawerItem joyType1DrawerItem = new PrimaryDrawerItem().withName("Assault Horizon").withTag(KEY_ASSAULT_HORIZON).withLevel(2); PrimaryDrawerItem joyType2DrawerItem = new PrimaryDrawerItem().withName("Awesomenauts").withTag(KEY_AWESOMENAUTS).withLevel(2); PrimaryDrawerItem joyType3DrawerItem = new PrimaryDrawerItem().withName("BombSquad").withTag(KEY_BOMBSQUAD).withLevel(2); PrimaryDrawerItem joyType4DrawerItem = new PrimaryDrawerItem().withName("Final Fantasy XIII").withTag(KEY_FINAL_FANTASY_XIII).withLevel(2); SectionDrawerItem sectionDrawerItem = new SectionDrawerItem().withName("Joystick Type").withTextColorRes(R.color.colorAccent); PrimaryDrawerItem deviceDrawerItem = new PrimaryDrawerItem().withName("Device Connection").withTag(KEY_DEVICE_CONNECTION).withIcon(GoogleMaterial.Icon.gmd_devices); PrimaryDrawerItem settingsDrawerItem = new PrimaryDrawerItem().withName("Settings").withTag("settings").withIcon(GoogleMaterial.Icon.gmd_settings); ndMenu = new DrawerBuilder() .withActivity(this) .withToolbar(tbMain) .withCloseOnClick(true) .withFireOnInitialOnClick(true) .withSelectedItemByPosition(6) .withDelayDrawerClickEvent(300) .withDisplayBelowStatusBar(true) .withTranslucentStatusBar(false) .withOnDrawerItemClickListener(this) .addDrawerItems(section, deviceDrawerItem, settingsDrawerItem, sectionDrawerItem, joyType0DrawerItem, joyType1DrawerItem, joyType2DrawerItem, joyType3DrawerItem, joyType4DrawerItem) .build(); }
Example 20
Project: LanCamera File: MainActivity.java View source code | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); PrimaryDrawerItem liveItem = new PrimaryDrawerItem().withName(R.string.live) .withIdentifier(ID_LIVE); mHistoryItem = new ExpandableDrawerItem().withName(history) .withSubItems(mHistoryItems) .withIdentifier(ID_HISTORY); PrimaryDrawerItem settingItem = new PrimaryDrawerItem().withName(R.string.setting) .withIdentifier(ID_SETTING); mDrawer = new DrawerBuilder() .withActivity(this) .withToolbar(toolbar) .withRootView(R.id.container) .withActionBarDrawerToggle(true) .withActionBarDrawerToggleAnimated(true) .addDrawerItems(liveItem) .addDrawerItems(mHistoryItem) .addDrawerItems(new DividerDrawerItem()) .addDrawerItems(settingItem) .withOnDrawerItemClickListener(this) .build(); mPrefs = PreferenceManager.getDefaultSharedPreferences(this); player = new GiraffePlayer(this); playLive(); prepareHistory(); }
Example 21
Project: librus-client File: FragmentPresenter.java View source code | 5 votes |
public PrimaryDrawerItem convertToDrawerItem(java8.util.function.Consumer<FragmentPresenter> displayFragment) { return new PrimaryDrawerItem() .withIconTintingEnabled(true) .withSelectable(false) .withName(getTitle()) .withIcon(getIcon()) .withIdentifier(getTitle()) .withIconTintingEnabled(true) .withOnDrawerItemClickListener((v, p, d) -> { displayFragment.accept(this); return false; }); }
Example 22
Project: HACKxFDU-CrisisProbingUAV File: BaseActivity.java View source code | 5 votes |
@NonNull protected List<IDrawerItem> drawerItems() { return Arrays.<IDrawerItem>asList( new PrimaryDrawerItem() .withName(R.string.drawer_item_recognize_tags) .withOnDrawerItemClickListener(goToActivityListener(RecognizeConceptsActivity.class)), new SecondaryDrawerItem() .withName(R.string.drawer_item_recognize_colors) .withOnDrawerItemClickListener(goToActivityListener(RecognizeColorsActivity.class)) ); }
Example 23
Project: MaterialDrawer File: DrawerFragment.java View source code | 5 votes |
@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), new SectionDrawerItem().withName(R.string.drawer_item_section_header), new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog), new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question).withEnabled(false), new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github), new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withIcon(FontAwesome.Icon.faw_bullhorn) ) .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; }
Example 24
Project: MaterialDrawer File: CollapsingToolbarActivity.java View source code | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sample_collapsing_toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbarLayout.setTitle(getString(R.string.drawer_item_collapsing_toolbar_drawer)); headerResult = new AccountHeaderBuilder() .withActivity(this) .withCompactStyle(false) .withHeaderBackground(R.drawable.header) .withSavedInstance(savedInstanceState) .build(); result = new DrawerBuilder() .withActivity(this) .withAccountHeader(headerResult) .withToolbar(toolbar) .withFullscreen(true) .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), new SectionDrawerItem().withName(R.string.drawer_item_section_header), new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog), new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question).withEnabled(false), new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github), new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withIcon(FontAwesome.Icon.faw_bullhorn) ) .withSavedInstance(savedInstanceState) .build(); fillFab(); loadBackdrop(); }
Example 25
Project: MaterialDrawer File: CustomContainerActivity.java View source code | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sample_custom_container_dark_toolbar); // Handle Toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setTitle(R.string.drawer_item_custom_container_drawer); //Create the drawer result = new DrawerBuilder(this) //this layout have to contain child layouts .withRootView(R.id.drawer_container) .withToolbar(toolbar) .withDisplayBelowStatusBar(false) .withActionBarDrawerToggleAnimated(true) .addDrawerItems( new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home), 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), new SectionDrawerItem().withName(R.string.drawer_item_section_header), new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog), new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question).withEnabled(false), new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github), new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withIcon(FontAwesome.Icon.faw_bullhorn) ) .withSavedInstance(savedInstanceState) .build(); }
Example 26
Project: MaterialDrawer File: ActionBarActivity.java View source code | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { //supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); setContentView(R.layout.activity_sample_actionbar); setTitle(R.string.drawer_item_action_bar_drawer); // Handle Toolbar result = new DrawerBuilder() .withActivity(this) .withSavedInstance(savedInstanceState) .withDisplayBelowStatusBar(false) .withTranslucentStatusBar(false) .withDrawerLayout(R.layout.material_drawer_fits_not) .addDrawerItems( new PrimaryDrawerItem().withName(R.string.drawer_item_home).withIcon(FontAwesome.Icon.faw_home), new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog) ) .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { if (drawerItem instanceof Nameable) { Toast.makeText(ActionBarActivity.this, ((Nameable) drawerItem).getName().getText(ActionBarActivity.this), Toast.LENGTH_SHORT).show(); } return false; } }).build(); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(false); }
Example 27
Project: MaterialDrawer File: MiniDrawer.java View source code | 5 votes |
/** * generates a MiniDrawerItem from a IDrawerItem * * @param drawerItem * @return */ public IDrawerItem generateMiniDrawerItem(IDrawerItem drawerItem) { if (drawerItem instanceof SecondaryDrawerItem) { return mIncludeSecondaryDrawerItems ? new MiniDrawerItem((SecondaryDrawerItem) drawerItem).withEnableSelectedBackground(mEnableSelectedMiniDrawerItemBackground) : null; } else if (drawerItem instanceof PrimaryDrawerItem) { return new MiniDrawerItem((PrimaryDrawerItem) drawerItem).withEnableSelectedBackground(mEnableSelectedMiniDrawerItemBackground); } else if (drawerItem instanceof ProfileDrawerItem) { MiniProfileDrawerItem mpdi = new MiniProfileDrawerItem((ProfileDrawerItem) drawerItem); mpdi.withEnabled(mEnableProfileClick); return mpdi; } return null; }
Example 28
Project: YouJoin-Android File: DrawerUtils.java View source code | 5 votes |
/** * helper method to fill the sticky footer with it's elements * * @param drawer * @param container * @param onClickListener */ public static void fillStickyDrawerItemFooter(DrawerBuilder drawer, ViewGroup container, View.OnClickListener onClickListener) { //add all drawer items for (IDrawerItem drawerItem : drawer.mStickyDrawerItems) { //get the selected_color int selected_color = UIUtils.getThemeColorFromAttrOrRes(container.getContext(), R.attr.material_drawer_selected, R.color.material_drawer_selected); if (drawerItem instanceof PrimaryDrawerItem) { selected_color = ColorHolder.color(((PrimaryDrawerItem) drawerItem).getSelectedColor(), container.getContext(), R.attr.material_drawer_selected, R.color.material_drawer_selected); } else if (drawerItem instanceof SecondaryDrawerItem) { selected_color = ColorHolder.color(((SecondaryDrawerItem) drawerItem).getSelectedColor(), container.getContext(), R.attr.material_drawer_selected, R.color.material_drawer_selected); } View view = drawerItem.generateView(container.getContext(), container); view.setTag(drawerItem); if (drawerItem.isEnabled()) { UIUtils.setBackground(view, DrawerUIUtils.getSelectableBackground(container.getContext(), selected_color)); view.setOnClickListener(onClickListener); } container.addView(view); //for android API 17 --> Padding not applied via xml DrawerUIUtils.setDrawerVerticalPadding(view); } //and really. don't ask about this. it won't set the padding if i don't set the padding for the container container.setPadding(0, 0, 0, 0); }
Example 29
Project: YouJoin-Android File: MiniDrawer.java View source code | 5 votes |
/** * generates a MiniDrawerItem from a IDrawerItem * * @param drawerItem * @return */ public IDrawerItem generateMiniDrawerItem(IDrawerItem drawerItem) { if (drawerItem instanceof PrimaryDrawerItem) { return new MiniDrawerItem((PrimaryDrawerItem) drawerItem).withEnableSelectedBackground(mEnableSelectedMiniDrawerItemBackground); } else if (drawerItem instanceof SecondaryDrawerItem && mIncludeSecondaryDrawerItems) { return new MiniDrawerItem((SecondaryDrawerItem) drawerItem).withEnableSelectedBackground(mEnableSelectedMiniDrawerItemBackground); } else if (drawerItem instanceof ProfileDrawerItem) { MiniProfileDrawerItem mpdi = new MiniProfileDrawerItem((ProfileDrawerItem) drawerItem); mpdi.withEnabled(mEnableProfileClick); return mpdi; } return null; }
Example 30
Project: Komica File: KomicaHomeFragment.java View source code | 5 votes |
private List<IDrawerItem> getMainDrawerItems() { List<IDrawerItem> drawerItemList = new ArrayList<>(); drawerItemList.add(getColorSetting(new PrimaryDrawerItem().withIdentifier(1001).withName(R.string.home_page).withIcon(R.drawable.ic_home))); drawerItemList.add(getColorSetting(new PrimaryDrawerItem().withIdentifier(1005).withName(R.string.refresh_menu).withIcon(R.drawable.ic_loop).withSelectable(false))); drawerItemList.add(getColorSetting(new PrimaryDrawerItem().withIdentifier(1006).withName(R.string.clear_cache).withIcon(R.drawable.ic_clear_cache).withSelectable(false))); drawerItemList.add(getColorSetting(new PrimaryDrawerItem().withIdentifier(1002).withName(R.string.sponsor).withIcon(R.drawable.ic_sponsor).withSelectable(false))); drawerItemList.add(new DividerDrawerItem()); drawerItemList.add(new SecondaryDrawerItem().withName(R.string.others).withSelectable(false)); drawerItemList.add(getColorSetting(new PrimaryDrawerItem().withIdentifier(1003).withName(R.string.rating).withIcon(R.drawable.ic_rate).withSelectable(false))); drawerItemList.add(getColorSetting(new PrimaryDrawerItem().withIdentifier(1004).withName(R.string.feedback).withIcon(R.drawable.ic_feedback).withSelectable(false))); return drawerItemList; }
Example 31
Project: Komica File: KomicaHomeFragment.java View source code | 5 votes |
private IDrawerItem[] getDynamicalDrawerItems() { List<IDrawerItem> drawerItemList = getMainDrawerItems(); for (KomicaMenuGroup group : KomicaManager.getInstance().getMenuGroupList()) { drawerItemList.add(new DividerDrawerItem()); // drawerItemList.add(new SecondaryDrawerItem().withName(group.getTitle()).withTextColor(Color.RED)); List<IDrawerItem> memberList = new ArrayList<>(); List<Long> identifiers = new ArrayList<>(); for (KomicaMenuMember member : group.getMemberList()) { if (!KomicaManager.getInstance().checkVisible(member.getTitle())) { continue; } memberList.add( getColorSetting( new PrimaryDrawerItem().withIdentifier(member.getMemberId()).withName(member.getTitle()) ) ); identifiers.add((long) member.getMemberId()); } drawerIdentifiers = new long[identifiers.size()]; for (int i = 0; i < identifiers.size(); i++) { drawerIdentifiers[i] = identifiers.get(i); } ExpandableDrawerItem expandableDrawerItem = new ExpandableDrawerItem().withArrowColorRes(R.color.colorPrimary) .withName(group.getTitle()) .withTextColor(Color.RED) .withSelectable(false).withSubItems(memberList); drawerItemList.add(expandableDrawerItem); } IDrawerItem[] items = new IDrawerItem[drawerItemList.size()]; return drawerItemList.toArray(items); }
Example 32
Project: Roach File: MainActivity.java View source code | 5 votes |
private void initialiseDrawerItems() { mDrawerItems = new HashMap<>(); mDrawerItems.put(R.id.tab_card_db, new PrimaryDrawerItem() .withIdentifier(R.id.tab_card_db) .withName(R.string.card_database) .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_database, getTheme()))); mDrawerItems.put(R.id.tab_public_decks, new PrimaryDrawerItem() .withIdentifier(R.id.tab_public_decks) .withName(R.string.public_decks) .withSelectable(BuildConfig.DEBUG) .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_public, getTheme()))); mDrawerItems.put(R.id.tab_decks, new PrimaryDrawerItem() .withIdentifier(R.id.tab_decks) .withName(R.string.deck_builder) .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_cards_filled, getTheme()))); mDrawerItems.put(R.id.tab_collection, new PrimaryDrawerItem() .withIdentifier(R.id.tab_collection) .withName(R.string.collection_manager) .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_cards_outline, getTheme()))); mDrawerItems.put(R.id.tab_results, new PrimaryDrawerItem() .withIdentifier(R.id.tab_results) .withName(R.string.results) .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_chart, getTheme()))); mDrawerItems.put(R.id.tab_helper, new PrimaryDrawerItem() .withIdentifier(R.id.tab_helper) .withSelectable(false) .withName(R.string.keg_helper) .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_help, getTheme()))); mDrawerItems.put(R.id.tab_news, new PrimaryDrawerItem() .withIdentifier(R.id.tab_news) .withSelectable(false) .withName(R.string.news) .withIcon(VectorDrawableCompat.create(getResources(), R.drawable.ic_news, getTheme()))); }
Example 33
Project: xTun-android File: MainActivity.java View source code | 5 votes |
private ArrayList<IDrawerItem> getDrawerItems() { SectionDrawerItem profileItem = new SectionDrawerItem().withName(R.string.profiles) .withTextColorRes(R.color.accentColor).setDivider(false); PrimaryDrawerItem addItem = new PrimaryDrawerItem().withName(R.string.add_profile) .withIdentifier(Action.ADD.ordinal()).withIcon(GoogleMaterial.Icon.gmd_add_circle_outline) .withCheckable(false); SectionDrawerItem settingItem = new SectionDrawerItem().withName(R.string.settings) .withTextColorRes(R.color.accentColor); PrimaryDrawerItem recoveryItem = new PrimaryDrawerItem().withName(R.string.recovery) .withIdentifier(Action.RECOVERY.ordinal()).withIcon(GoogleMaterial.Icon.gmd_restore) .withCheckable(false); PrimaryDrawerItem aboutItem = new PrimaryDrawerItem().withName(R.string.about) .withIdentifier(Action.ABOUT.ordinal()).withIcon(GoogleMaterial.Icon.gmd_info_outline) .withCheckable(false); ArrayList<IDrawerItem> items = new ArrayList<>(); items.add(profileItem); items.addAll(getProfileList()); items.add(addItem); items.add(settingItem); items.add(recoveryItem); items.add(aboutItem); return items; }
Example 34
Project: minx File: MainActivity.java View source code | 5 votes |
private void setUpDrawer() { AccountHeader accountHeader = new AccountHeaderBuilder() .withActivity(MainActivity.this) .withHeaderBackground(R.drawable.minx_small) .withHeaderBackgroundScaleType(ImageView.ScaleType.FIT_CENTER) .withHeightDp(200) .build(); result = new DrawerBuilder() .withHeaderDivider(true) .withActivity(this) .withAccountHeader(accountHeader) .withToolbar(toolbar) .addDrawerItems( new PrimaryDrawerItem().withName(R.string.drawer_item_home), new DividerDrawerItem(), new SecondaryDrawerItem().withName(R.string.drawer_item_saved), new SecondaryDrawerItem().withName(R.string.drawer_item_share), new SecondaryDrawerItem().withName(R.string.drawer_item_settings), new SecondaryDrawerItem().withName(R.string.drawer_item_about) ) .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(AdapterView<?> parent, View view, int position, long id, IDrawerItem drawerItem) { // do something with the clicked item :D Toast.makeText(MainActivity.this, "You clicked on item : " + position, Toast.LENGTH_SHORT).show(); loadFragment(position); return false; } }) .build(); getSupportActionBar().setDisplayHomeAsUpEnabled(false); result.getActionBarDrawerToggle().setDrawerIndicatorEnabled(true); }
Example 35
Project: top-github File: MainActivity.java View source code | 5 votes |
private void setupDrawer() { // Create the drawer mDrawer = new DrawerBuilder() .withActivity(this) .withToolbar(mToolbar) .withTranslucentStatusBar(false) .withActionBarDrawerToggle(true) .withHeader(R.layout.drawer_header) .build(); // Add the items to it addItemsToDrawer(); // Set a Click Listener on every drawer's item. // If the item is clicked start a new search mDrawer.setOnDrawerItemClickListener((View view, int i, IDrawerItem iDrawerItem) -> { PrimaryDrawerItem drawerItem = (PrimaryDrawerItem) iDrawerItem; String language = drawerItem.getName().getText(); mMyDataStore.selectedLanguage().put(language); mSelectedLanguage = language; getSupportActionBar().setTitle(mSelectedLanguage); startSearch(); return false; }); // Set the selected drawer's item mDrawer.setSelection(mSelectedItemId, false); // Set the Click Listener on the drawer header button // If it is clicked show the LanguagesFragment mDrawer.getHeader().findViewById(R.id.imageview_change_languages).setOnClickListener((View v) -> { LanguagesFragment newFragment = new LanguagesFragment(); newFragment.show(getSupportFragmentManager().beginTransaction(), LanguagesFragment.TAG); }); }
Example 36
Project: top-github File: MainActivity.java View source code | 5 votes |
private void addItemsToDrawer() { int itemId = 0; // Add the "All" programming language PrimaryDrawerItem allDrawerItem = new PrimaryDrawerItem() .withName("All") .withIdentifier(itemId) .withIcon(Utilities.getDrawableFromLanguage(this, "All")) .withIconTintingEnabled(true) .withSelectedIconColor(Color.WHITE) .withIconColorRes(R.color.primary_dark) .withTintSelectedIcon(true); mDrawer.addItem(allDrawerItem); mSelectedItemId = 0; // Add the every other programming language for (String languageName : mLanguages.getUserLanguages()) { itemId++; PrimaryDrawerItem drawerItem = new PrimaryDrawerItem() .withName(languageName) .withIdentifier(itemId) .withIcon(Utilities.getDrawableFromLanguage(this, languageName)) .withIconTintingEnabled(true) .withSelectedIconColor(Color.WHITE) .withIconColorRes(R.color.primary_dark) .withTintSelectedIcon(true); mDrawer.addItem(drawerItem); if (mSelectedLanguage.equals(languageName)) { mSelectedItemId = itemId; } } }
Example 37
Project: BabyFace File: MainDrawerActivity.java View source code | 5 votes |
private List<IDrawerItem> facesToDrawerItems() { List<IDrawerItem> drawerItems = new ArrayList<>(); for (Face face : facesManager.getFaces()) { drawerItems.add(new PrimaryDrawerItem() .withName(face.getName()) .withIconTintingEnabled(true) .withIcon(R.drawable.ic_faces) .withTag(face)); } return drawerItems; }
Example 38
Project: BabyFace File: MainDrawerActivity.java View source code | 5 votes |
private IDrawerItem createAddFaceDrawerItem() { return new PrimaryDrawerItem() .withName(getString(R.string.add_album)) .withIconTintingEnabled(true) .withIcon(R.drawable.ic_add_white_36px) .withIdentifier(ID_NEW_ALBUM); }
Example 39
Project: MaterialDrawer-Xamarin File: DrawerUtils.java View source code | 5 votes |
/** * helper method to fill the sticky footer with it's elements * * @param drawer * @param container * @param onClickListener */ public static void fillStickyDrawerItemFooter(DrawerBuilder drawer, ViewGroup container, View.OnClickListener onClickListener) { //add all drawer items for (IDrawerItem drawerItem : drawer.mStickyDrawerItems) { //get the selected_color int selected_color = UIUtils.getThemeColorFromAttrOrRes(container.getContext(), R.attr.material_drawer_selected, R.color.material_drawer_selected); if (drawerItem instanceof PrimaryDrawerItem) { selected_color = ColorHolder.color(((PrimaryDrawerItem) drawerItem).getSelectedColor(), container.getContext(), R.attr.material_drawer_selected, R.color.material_drawer_selected); } else if (drawerItem instanceof SecondaryDrawerItem) { selected_color = ColorHolder.color(((SecondaryDrawerItem) drawerItem).getSelectedColor(), container.getContext(), R.attr.material_drawer_selected, R.color.material_drawer_selected); } View view = drawerItem.generateView(container.getContext(), container); view.setTag(drawerItem); if (drawerItem.isEnabled()) { UIUtils.setBackground(view, DrawerUIUtils.getSelectableBackground(container.getContext(), selected_color)); view.setOnClickListener(onClickListener); } container.addView(view); //for android API 17 --> Padding not applied via xml DrawerUIUtils.setDrawerVerticalPadding(view); } //and really. don't ask about this. it won't set the padding if i don't set the padding for the container container.setPadding(0, 0, 0, 0); }
Example 40
Project: MaterialDrawer-Xamarin File: MiniDrawer.java View source code | 5 votes |
/** * generates a MiniDrawerItem from a IDrawerItem * * @param drawerItem * @return */ public IDrawerItem generateMiniDrawerItem(IDrawerItem drawerItem) { if (drawerItem instanceof PrimaryDrawerItem) { return new MiniDrawerItem((PrimaryDrawerItem) drawerItem).withEnableSelectedBackground(mEnableSelectedMiniDrawerItemBackground); } else if (drawerItem instanceof SecondaryDrawerItem && mIncludeSecondaryDrawerItems) { return new MiniDrawerItem((SecondaryDrawerItem) drawerItem).withEnableSelectedBackground(mEnableSelectedMiniDrawerItemBackground); } else if (drawerItem instanceof ProfileDrawerItem) { MiniProfileDrawerItem mpdi = new MiniProfileDrawerItem((ProfileDrawerItem) drawerItem); mpdi.withEnabled(mEnableProfileClick); return mpdi; } return null; }