com.mikepenz.materialdrawer.model.DividerDrawerItem Java Examples
The following examples show how to use
com.mikepenz.materialdrawer.model.DividerDrawerItem.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HomeActivity.java From wmn-safety with MIT License | 5 votes |
private void createNavDrawer(Toolbar toolbar) { result = new DrawerBuilder() .withActivity(this) .withAccountHeader(headerResult) .withToolbar(toolbar) .withSelectedItem(-1) .withHasStableIds(true) .addDrawerItems( new PrimaryDrawerItem().withName("Trusted Contacts") .withIdentifier(1).withIcon(R.drawable.ic_contact_phone_black_24dp), new PrimaryDrawerItem().withName("Explore") .withIdentifier(2).withIcon(R.drawable.ic_explore_black_24dp), new DividerDrawerItem(), new PrimaryDrawerItem().withName("Settings") .withIdentifier(3).withIcon(R.drawable.ic_settings_black_24dp), new PrimaryDrawerItem().withName("Help & Feedback") .withIcon(R.drawable.ic_feedback_black_24dp) .withIdentifier(5), new PrimaryDrawerItem().withName("About") .withIcon(R.drawable.ic_info_outline_black_24dp) .withIdentifier(6), new PrimaryDrawerItem().withName("Rate Us") .withIcon(R.drawable.ic_star_black_24dp) .withIdentifier(7) ) .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { // add click listeners for nav drawer items switch ((int) drawerItem.getIdentifier()) { case 1: startActivity(new Intent(mContext, TrustedContactsActivity.class)); break; case 2: startActivity(new Intent(mContext,ExploreActivity.class)); break; case 3: startActivity(new Intent(mContext, SettingsActivity.class)); break; case 6: startActivity(new Intent(mContext, AboutActivity.class)); break; case 7: Toast.makeText(mContext,"Coming soon on Play Store",Toast.LENGTH_SHORT).show(); } return false; } }) .build(); }
Example #2
Source File: MainActivity.java From minx with MIT License | 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 #3
Source File: MainViewModel.java From hacker-news-android with Apache License 2.0 | 5 votes |
List<IDrawerItem> getDrawerItems() { if (mDrawerItems != null && !mDrawerItems.isEmpty()) { return mDrawerItems; } List<PrimaryDrawerItem> primaryDrawerItems = new ArrayList<>(); List<SecondaryDrawerItem> secondaryDrawerItems = new ArrayList<>(); mDrawerItems = new ArrayList<>(); primaryDrawerItems.add(new PrimaryDrawerItem().withIdentifier(SECTION_TOP).withName(R.string.title_section_top).withIcon(R.drawable.ic_action_whatshot)); primaryDrawerItems.add(new PrimaryDrawerItem().withIdentifier(SECTION_BEST).withName(R.string.title_section_best).withIcon(R.drawable.ic_action_grade)); primaryDrawerItems.add(new PrimaryDrawerItem().withIdentifier(SECTION_NEWEST).withName(R.string.title_section_newest).withIcon(R.drawable.ic_action_note_add)); primaryDrawerItems.add(new PrimaryDrawerItem().withIdentifier(SECTION_SHOW_HN).withName(R.string.title_section_show).withIcon(R.drawable.ic_action_visibility)); primaryDrawerItems.add(new PrimaryDrawerItem().withIdentifier(SECTION_SHOW_HN_NEW).withName(R.string.title_section_show_new).withIcon(R.drawable.ic_action_visibility)); primaryDrawerItems.add(new PrimaryDrawerItem().withIdentifier(SECTION_ASK).withName(R.string.title_section_ask).withIcon(R.drawable.ic_action_live_help)); primaryDrawerItems.add(new PrimaryDrawerItem().withIdentifier(SECTION_SAVED).withName(R.string.title_section_saved).withIcon(R.drawable.ic_action_archive)); mDrawerItems.addAll(primaryDrawerItems); mDrawerItems.add(new DividerDrawerItem()); secondaryDrawerItems.add(new SecondaryDrawerItem().withIdentifier(SECTION_SETTINGS).withName(R.string.title_section_settings).withCheckable(false)); secondaryDrawerItems.add(new SecondaryDrawerItem().withIdentifier(SECTION_ABOUT).withName(R.string.title_section_about).withCheckable(false)); mDrawerItems.addAll(secondaryDrawerItems); return mDrawerItems; }
Example #4
Source File: SheetMusicActivity.java From MidiSheetMusic-Android with GNU General Public License v3.0 | 4 votes |
void createViews() { layout = findViewById(R.id.sheet_content); SwitchDrawerItem scrollVertically = new SwitchDrawerItem() .withName(R.string.scroll_vertically) .withChecked(options.scrollVert) .withOnCheckedChangeListener((iDrawerItem, compoundButton, isChecked) -> { options.scrollVert = isChecked; createSheetMusic(options); }); SwitchDrawerItem useColors = new SwitchDrawerItem() .withName(R.string.use_note_colors) .withChecked(options.useColors) .withOnCheckedChangeListener((iDrawerItem, compoundButton, isChecked) -> { options.useColors = isChecked; createSheetMusic(options); }); SecondarySwitchDrawerItem showMeasures = new SecondarySwitchDrawerItem() .withName(R.string.show_measures) .withLevel(2) .withChecked(options.showMeasures) .withOnCheckedChangeListener((iDrawerItem, compoundButton, isChecked) -> { options.showMeasures = isChecked; createSheetMusic(options); }); SecondaryDrawerItem loopStart = new SecondaryDrawerItem() .withIdentifier(ID_LOOP_START) .withBadge(Integer.toString(options.playMeasuresInLoopStart + 1)) .withName(R.string.play_measures_in_loop_start) .withLevel(2); SecondaryDrawerItem loopEnd = new SecondaryDrawerItem() .withIdentifier(ID_LOOP_END) .withBadge(Integer.toString(options.playMeasuresInLoopEnd + 1)) .withName(R.string.play_measures_in_loop_end) .withLevel(2); ExpandableSwitchDrawerItem loopSettings = new ExpandableSwitchDrawerItem() .withIdentifier(ID_LOOP_ENABLE) .withName(R.string.loop_on_measures) .withChecked(options.playMeasuresInLoop) .withOnCheckedChangeListener((iDrawerItem, compoundButton, isChecked) -> { options.playMeasuresInLoop = isChecked; }) .withSubItems(showMeasures, loopStart, loopEnd); // Drawer drawer = new DrawerBuilder() .withActivity(this) .withInnerShadow(true) .addDrawerItems( scrollVertically, useColors, loopSettings, new DividerDrawerItem() ) .inflateMenu(R.menu.sheet_menu) .withOnDrawerItemClickListener((view, i, item) -> drawerItemClickListener(item)) .withDrawerGravity(Gravity.RIGHT) .build(); // Make sure that the view extends over the navigation buttons area drawer.getDrawerLayout().setFitsSystemWindows(false); // Lock the drawer so swiping doesn't open it drawer.getDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); player = new MidiPlayer(this); player.setDrawer(drawer); layout.addView(player); piano = new Piano(this); layout.addView(piano); player.SetPiano(piano); layout.requestLayout(); player.setSheetUpdateRequestListener(() -> createSheetMusic(options)); createSheetMusic(options); }
Example #5
Source File: MainActivity.java From openapk with GNU General Public License v3.0 | 4 votes |
public static Drawer setNavigationDrawer(final Context context, final Toolbar toolbar, final RecyclerView recyclerView, boolean badge, final AppAdapter appInstalledAdapter, final AppAdapter appSystemAdapter, final AppAdapter appDisabledAdapter, final AppAdapter appHiddenAdapter, final AppAdapter appFavoriteAdapter) { AppPreferences appPreferences = App.getAppPreferences(); final Activity activity = (Activity) context; int header; // check for dark theme Integer badgeColor; BadgeStyle badgeStyle; if (appPreferences.getTheme().equals("0")) { badgeColor = ContextCompat.getColor(context, R.color.badge_light); badgeStyle = new BadgeStyle(badgeColor, badgeColor).withTextColor(context.getResources().getColor(R.color.text_light)); header = R.drawable.header_day; } else { badgeColor = ContextCompat.getColor(context, R.color.badge_dark); badgeStyle = new BadgeStyle(badgeColor, badgeColor).withTextColor(context.getResources().getColor(R.color.text_dark)); header = R.drawable.header_night; } AccountHeader headerResult = new AccountHeaderBuilder() .withActivity(activity) .withHeaderBackground(header) .build(); DrawerBuilder drawerBuilder = new DrawerBuilder(); drawerBuilder.withActivity(activity); drawerBuilder.withToolbar(toolbar); drawerBuilder.withAccountHeader(headerResult); drawerBuilder.withStatusBarColor(OtherUtils.dark(appPreferences.getPrimaryColor(), 0.8)); if (badge) { String installedApps = Integer.toString(appInstalledAdapter.getItemCount()); String systemApps = Integer.toString(appSystemAdapter.getItemCount()); String disabledApps = Integer.toString(appDisabledAdapter.getItemCount()); String hiddenApps = Integer.toString(appHiddenAdapter.getItemCount()); String favoriteApps = Integer.toString(appFavoriteAdapter.getItemCount()); drawerBuilder.addDrawerItems( new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_installed)).withIcon(GoogleMaterial.Icon.gmd_phone_android).withBadge(installedApps).withBadgeStyle(badgeStyle).withIdentifier(0), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_system)).withIcon(GoogleMaterial.Icon.gmd_android).withBadge(systemApps).withBadgeStyle(badgeStyle).withIdentifier(1), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_disabled)).withIcon(GoogleMaterial.Icon.gmd_remove_circle_outline).withBadge(disabledApps).withBadgeStyle(badgeStyle).withIdentifier(2), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_hidden)).withIcon(GoogleMaterial.Icon.gmd_visibility_off).withBadge(hiddenApps).withBadgeStyle(badgeStyle).withIdentifier(3), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_favorite)).withIcon(GoogleMaterial.Icon.gmd_star).withBadge(favoriteApps).withBadgeStyle(badgeStyle).withIdentifier(4), new DividerDrawerItem(), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.settings)).withIcon(GoogleMaterial.Icon.gmd_settings).withSelectable(false).withIdentifier(5), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.about)).withIcon(GoogleMaterial.Icon.gmd_info).withSelectable(false).withIdentifier(6)); } else { drawerBuilder.addDrawerItems( new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_installed)).withIcon(GoogleMaterial.Icon.gmd_phone_android).withIdentifier(0), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_system)).withIcon(GoogleMaterial.Icon.gmd_android).withIdentifier(1), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_disabled)).withIcon(GoogleMaterial.Icon.gmd_remove_circle_outline).withIdentifier(2), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_hidden)).withIcon(GoogleMaterial.Icon.gmd_visibility_off).withIdentifier(3), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_favorite)).withIcon(GoogleMaterial.Icon.gmd_star).withIdentifier(4), new DividerDrawerItem(), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.settings)).withIcon(GoogleMaterial.Icon.gmd_settings).withSelectable(false).withIdentifier(5), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.about)).withIcon(GoogleMaterial.Icon.gmd_info).withSelectable(false).withIdentifier(6)); } drawerBuilder.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { switch (drawerItem.getIdentifier()) { case 0: recyclerView.setAdapter(appInstalledAdapter); App.setCurrentAdapter(0); OtherUtils.setToolbarTitle(context, context.getResources().getString(R.string.apps_installed)); break; case 1: recyclerView.setAdapter(appSystemAdapter); App.setCurrentAdapter(1); OtherUtils.setToolbarTitle(context, context.getResources().getString(R.string.apps_system)); break; case 2: recyclerView.setAdapter(appDisabledAdapter); App.setCurrentAdapter(2); OtherUtils.setToolbarTitle(context, context.getResources().getString(R.string.apps_disabled)); break; case 3: recyclerView.setAdapter(appHiddenAdapter); App.setCurrentAdapter(3); OtherUtils.setToolbarTitle(context, context.getResources().getString(R.string.apps_hidden)); break; case 4: recyclerView.setAdapter(appFavoriteAdapter); App.setCurrentAdapter(4); OtherUtils.setToolbarTitle(context, context.getResources().getString(R.string.apps_favorite)); break; case 5: context.startActivity(new Intent(context, SettingsActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); break; case 6: context.startActivity(new Intent(context, AboutActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); break; default: break; } return false; } }); return drawerBuilder.build(); }
Example #6
Source File: UtilsUI.java From Moticons with GNU General Public License v3.0 | 4 votes |
public static Drawer showNavigationDrawer(final Context context, Toolbar toolbar, final MoticonAdapter moticonAdapter, final MoticonAdapter moticonPositiveAdapter, final MoticonAdapter moticonNegativeAdapter, final MoticonAdapter moticonFunnyAdapter, final MoticonAdapter moticonAnimalsAdapter, final MoticonAdapter moticonSpecialAdapter, final RecyclerView recyclerView) { Activity activity = (Activity) context; AccountHeader headerResult = new AccountHeaderBuilder() .withActivity(activity) .withHeaderBackground(R.drawable.header) .build(); return new DrawerBuilder() .withActivity(activity) .withToolbar(toolbar) .withAccountHeader(headerResult) .withStatusBarColor(context.getResources().getColor(R.color.primary_dark)) .addDrawerItems( new PrimaryDrawerItem().withName(context.getResources().getString(R.string.app_name)).withIcon(R.mipmap.ic_launcher), new DividerDrawerItem(), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_positive)).withIcon(FontAwesome.Icon.faw_thumbs_up).withBadge("(/^▽^)/"), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_negative)).withIcon(FontAwesome.Icon.faw_thumbs_down).withBadge("(>_<)"), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_funny)).withIcon(FontAwesome.Icon.faw_child).withBadge("¯\\_(ツ)_/¯"), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_animal)).withIcon(FontAwesome.Icon.faw_paw).withBadge("∪・ω・∪"), new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_special)).withIcon(FontAwesome.Icon.faw_star).withBadge("ʕ•̬͡•ʕ•̫͡•♥"), new DividerDrawerItem(), new SecondaryDrawerItem().withName(context.getResources().getString(R.string.action_about)).withCheckable(false) ) .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(AdapterView<?> adapterView, View view, int position, long id, IDrawerItem iDrawerItem) { switch (position) { case 0: recyclerView.setAdapter(moticonAdapter); break; case 2: recyclerView.setAdapter(moticonPositiveAdapter); break; case 3: recyclerView.setAdapter(moticonNegativeAdapter); break; case 4: recyclerView.setAdapter(moticonFunnyAdapter); break; case 5: recyclerView.setAdapter(moticonAnimalsAdapter); break; case 6: recyclerView.setAdapter(moticonSpecialAdapter); break; case 8: context.startActivity(new Intent(context, AboutActivity.class)); break; default: break; } return false; } }).build(); }
Example #7
Source File: Navbar.java From SteamGifts with MIT License | 4 votes |
/** * Rebuilds the list of all navigation items, in particular: * <ol> * <li>the header, indicating whether or not the user is logged in</li> * <li>list of accessible giveaway filters (new, group, wishlist, all)</li> * </ol> */ public void reconfigure() { // Rebuild the header. accountHeader.clear(); // Update the account header. SteamGiftsUserData account = SteamGiftsUserData.getCurrent(activity); if (account.isLoggedIn()) { profile = (CustomProfileDrawerItem) new CustomProfileDrawerItem().withName(account.getName()).withEmail("...").withIdentifier(1); if (account.getImageUrl() != null && !account.getImageUrl().isEmpty()) profile.withIcon(account.getImageUrl()); accountHeader.addProfile(profile, 0); } else { profile = (CustomProfileDrawerItem) new CustomProfileDrawerItem().withName(activity.getString(R.string.guest)).withEmail("Not logged in").withIcon(R.drawable.default_avatar).withIdentifier(1); accountHeader.addProfile(profile, 0); } // Rebuild all items drawer.removeAllItems(); // If we're not logged in, log in is the top. if (!account.isLoggedIn()) drawer.addItem(new PrimaryDrawerItem().withName(R.string.login).withIdentifier(R.string.login).withSelectable(false).withIcon(FontAwesome.Icon.faw_sign_in)); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity); String mode = sharedPreferences.getString("preference_sidebar_discussion_list", "full"); addGiveawayItems(account); if ("compact".equals(mode)) drawer.addItem(new DividerDrawerItem()); addDiscussionItems(account, mode); drawer.addItems(new DividerDrawerItem()); drawer.addItem(new PrimaryDrawerItem().withName(R.string.navigation_saved_elements).withIdentifier(R.string.navigation_saved_elements).withIcon(FontAwesome.Icon.faw_star)); drawer.addItem(new PrimaryDrawerItem().withName(R.string.preferences).withIdentifier(R.string.preferences).withSelectable(false).withIcon(FontAwesome.Icon.faw_cog)); drawer.addItem(new PrimaryDrawerItem().withName(R.string.navigation_help).withIdentifier(R.string.navigation_help).withSelectable(false).withIcon(FontAwesome.Icon.faw_question)); drawer.addItem(new PrimaryDrawerItem().withName(R.string.navigation_about).withIdentifier(R.string.navigation_about).withSelectable(false).withIcon(FontAwesome.Icon.faw_info)); }