本文整理汇总了Java中com.mikepenz.materialdrawer.model.DividerDrawerItem类的典型用法代码示例。如果您正苦于以下问题:Java DividerDrawerItem类的具体用法?Java DividerDrawerItem怎么用?Java DividerDrawerItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DividerDrawerItem类属于com.mikepenz.materialdrawer.model包,在下文中一共展示了DividerDrawerItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeDrawer
import com.mikepenz.materialdrawer.model.DividerDrawerItem; //导入依赖的package包/类
public void initializeDrawer(Activity activity) {
this.response = new DrawerBuilder().withActivity(activity)
.addDrawerItems(
audioActivity,
fileActivity,
new DividerDrawerItem(),
about
).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
updatedSelection();
return true;
}
})
.build();
}
示例2: getDrawerItems
import com.mikepenz.materialdrawer.model.DividerDrawerItem; //导入依赖的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;
}
示例3: SubscriptionDrawerManager
import com.mikepenz.materialdrawer.model.DividerDrawerItem; //导入依赖的package包/类
public SubscriptionDrawerManager(Drawer drawer, OnCheckedChangeListener unreadSwitchListener) {
super(drawer);
topDrawerItems.add(
new TreeItemSwitchDrawerItem(allUnreadFolder)
.withOnCheckedChangeListener(unreadSwitchListener)
);
topDrawerItems.add(new TreeItemDrawerItem(starredFolder));
topDrawerItems.add(new TreeItemDrawerItem(freshFolder));
topDrawerItems.add(new DividerDrawerItem());
}
示例4: onCreate
import com.mikepenz.materialdrawer.model.DividerDrawerItem; //导入依赖的package包/类
@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();
}
示例5: setupDrawer
import com.mikepenz.materialdrawer.model.DividerDrawerItem; //导入依赖的package包/类
@Override
public void setupDrawer(Me me, Optional<LuckyNumber> luckyNumber) {
TextDrawable icon = getIcon(me);
ProfileDrawerItem profile = getProfileDrawerItem(me, icon);
DrawerBuilder drawerBuilder = new DrawerBuilder()
.withActivity(this)
.addStickyDrawerItems(settingsPresenter.convertToDrawerItem(this::displayFragment))
.withDelayOnDrawerClose(50)
.withOnDrawerNavigationListener(clickedView -> {
onBackPressed();
return true;
})
.withActionBarDrawerToggle(true)
.withActionBarDrawerToggleAnimated(true)
.withToolbar(toolbar)
.withAccountHeader(getDrawerHeader(profile));
StreamSupport.stream(fragmentPresenters)
.sorted(Ordering.natural().onResultOf(MainFragmentPresenter::getOrder))
.map(presenter -> presenter.convertToDrawerItem(p -> displayFragment(presenter)))
.forEach(drawerBuilder::addDrawerItems);
if (luckyNumber.isPresent()) {
drawerBuilder.addDrawerItems(
new DividerDrawerItem(),
getLuckyNumberDrawerItem(luckyNumber.get()));
}
this.drawer = drawerBuilder.build();
}
示例6: getMainDrawerItems
import com.mikepenz.materialdrawer.model.DividerDrawerItem; //导入依赖的package包/类
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;
}
示例7: getDynamicalDrawerItems
import com.mikepenz.materialdrawer.model.DividerDrawerItem; //导入依赖的package包/类
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);
}
示例8: setUpDrawer
import com.mikepenz.materialdrawer.model.DividerDrawerItem; //导入依赖的package包/类
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);
}
示例9: getDrawerItems
import com.mikepenz.materialdrawer.model.DividerDrawerItem; //导入依赖的package包/类
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;
}
示例10: NavigationDrawer
import com.mikepenz.materialdrawer.model.DividerDrawerItem; //导入依赖的package包/类
private NavigationDrawer(final MainActivity activity) {
// activity.getSupportActionBar().setDisplayHomeAsUpEnabled(false);
// Create the AccountHeader
AccountHeader headerResult = new AccountHeaderBuilder()
.withActivity(activity)
.withHeaderBackground(R.drawable.header)
.withSelectionListEnabledForSingleProfile(false)
.withOnlyMainProfileImageVisible(true)
.addProfiles(
new ProfileDrawerItem().withName(UserInfo.getDisplayName()).withEmail(UserInfo.getUserEmail()).withIcon(UserInfo.getProfilePictureURL())
)
.build();
PrimaryDrawerItem item1 = new PrimaryDrawerItem().withIdentifier(1).withName(activity.getString(R.string.seeCollection)).withIcon(FontAwesome.Icon.faw_book);
SecondaryDrawerItem item2 = new SecondaryDrawerItem().withIdentifier(2).withName(activity.getString(R.string.addComic)).withIcon(FontAwesome.Icon.faw_plus_circle);
SecondaryDrawerItem ajustes = new SecondaryDrawerItem().withIdentifier(3).withName(activity.getString(R.string.settings)).withIcon(FontAwesome.Icon.faw_cog);
SecondaryDrawerItem signout = new SecondaryDrawerItem().withIdentifier(4).withName(activity.getString(R.string.logout_button)).withIcon(FontAwesome.Icon.faw_sign_out);
//create the drawer and remember the `Drawer` result object
drawerBuilder = new DrawerBuilder()
.withActivity(activity)
.withAccountHeader(headerResult)
.addDrawerItems(item1,item2, new DividerDrawerItem(),ajustes,signout)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
BaseFragment fragment;
switch (position) {
case 1:
fragment = CollectionFragment.newInstance();
activity.openFragment(fragment,"");
break;
case 2:
fragment = AddComicFragment.newInstance();
activity.openFragment(fragment,"add");
break;
case 4:
fragment = SettingsFragment.newInstance();
activity.openFragment(fragment,"settings");
break;
case 5:
//logout code
AlertDialog.Builder logOutBuilder = Functions.getModalLogOut(activity);
logOutBuilder.setPositiveButton((activity.getString(R.string.ok)), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
FirebaseModule.getInstance().getmAuth().signOut();
Intent i = new Intent(activity.getApplicationContext(), LoginActivity.class);
activity.startActivity(i);
}
});
logOutBuilder.show();
break;
}
return true;
}
}).build();
}
示例11: getDrawerBuilder
import com.mikepenz.materialdrawer.model.DividerDrawerItem; //导入依赖的package包/类
public static DrawerBuilder getDrawerBuilder(final Context context, final Activity activity, Toolbar toolbar){
// Create the AccountHeader
AccountHeader headerResult = new AccountHeaderBuilder()
.withActivity(activity)
.withHeaderBackground(R.drawable.header)
.withSelectionListEnabledForSingleProfile(false)
.withOnlyMainProfileImageVisible(false)
.build();
PrimaryDrawerItem item1 = new PrimaryDrawerItem().withIdentifier(1).withName(activity.getApplicationContext().getString(R.string.title_activity_clock));
PrimaryDrawerItem item2 = new PrimaryDrawerItem().withIdentifier(2).withName(activity.getString(R.string.add_medicine));
PrimaryDrawerItem item3 = new PrimaryDrawerItem().withIdentifier(3).withName(activity.getString(R.string.medicinBox_Title));
return drawerBuilder = new DrawerBuilder()
.withActivity(activity)
.withToolbar(toolbar)
.withAccountHeader(headerResult)
.addDrawerItems(
item1,
item2,
item3,
new DividerDrawerItem()
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
switch (position) {
case 1:
context.startActivity(new Intent(context,ClockActivity.class));
activity.finish();
break;
case 2:
context.startActivity(new Intent(context,AddPillGeneralActivity.class));
activity.finish();
break;
case 3:
context.startActivity(new Intent(context, MedicineBoxActivity.class));
activity.finish();
break;
}
return true;
}
});
}
示例12: init
import com.mikepenz.materialdrawer.model.DividerDrawerItem; //导入依赖的package包/类
@SuppressLint("ShortAlarm")
@Override
public void init(Bundle savedInstanceState) {
setupLayout(R.layout.activity_landing, "Amrita Info Desk");
toolbar.setBackgroundColor(getResources().getColor(R.color.white));
setRecentHeaderColor(getResources().getColor(R.color.white));
checkForUpdates();
AccountHeader headerResult = new AccountHeaderBuilder()
.withActivity(this)
.withHeaderBackground(R.drawable.header)
.addProfiles(
new ProfileDrawerItem().withName("Amrita Info Desk").withEmail("Version " + BuildConfig.VERSION_NAME).setSelectable(false)
)
.withSelectionListEnabledForSingleProfile(false)
.build();
headerResult.getHeaderBackgroundView().setColorFilter(Color.rgb(170, 170, 170), android.graphics.PorterDuff.Mode.MULTIPLY);
Drawer result = new DrawerBuilder()
.withActivity(this)
.withToolbar(toolbar)
.withAccountHeader(headerResult)
.addDrawerItems(
new PrimaryDrawerItem().withName("Home").withIcon(R.drawable.ic_action_home).withCheckable(false),
new PrimaryDrawerItem().withName("News").withIcon(R.drawable.ic_action_speaker_notes).withCheckable(false),
new DividerDrawerItem(),
new PrimaryDrawerItem().withName("About the app").withIcon(R.drawable.ic_action_info).withCheckable(false),
new PrimaryDrawerItem().withName("Invite").withIcon(R.drawable.ic_action_info).withCheckable(false),
new PrimaryDrawerItem().withName("Settings").withIcon(R.drawable.ic_action_settings).withCheckable(false)
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(AdapterView<?> parent, View view, int position, long id, IDrawerItem drawerItem) {
switch (position) {
case 1:
startActivity(new Intent(baseContext, NewsActivity.class));
break;
case 3:
startActivity(new Intent(baseContext, App.class));
break;
case 4:
Intent intent = new AppInviteInvitation.IntentBuilder("Invite users")
.setMessage("Spread the word to fellow Amrititans")
.setCallToActionText("Invite")
.build();
startActivityForResult(intent, 211);
break;
case 5:
startActivity(new Intent(baseContext, SettingsActivity.class));
break;
}
return false;
}
})
.withCloseOnClick(true)
.build();
setupGrid();
File aumsCookieFile = new File(getApplicationContext().getFilesDir().getParent() + "/shared_prefs/" + PersistentCookieStore.AUMS_COOKIE_PREFS + ".xml");
if (aumsCookieFile.exists()) {
aumsCookieFile.delete();
}
File gpmsCookieFile = new File(getApplicationContext().getFilesDir().getParent() + "/shared_prefs/" + PersistentCookieStore.GPMS_COOKIE_PREFS + ".xml");
if (gpmsCookieFile.exists()) {
gpmsCookieFile.delete();
}
AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
alarm.set(
AlarmManager.RTC_WAKEUP,
System.currentTimeMillis() + (1000 * 60 * 60 * 6),
PendingIntent.getService(this, 0, new Intent(this, NewsUpdateService.class), 0)
);
startService(new Intent(baseContext, NewsUpdateService.class));
}
示例13: initDrawer
import com.mikepenz.materialdrawer.model.DividerDrawerItem; //导入依赖的package包/类
private void initDrawer(){
new DrawerBuilder().withActivity(this).build();
// Create the AccountHeader
profileItem = new ProfileDrawerItem().withName(" ").withEmail(" ").withIcon(getResources().getDrawable(R.drawable.empty_profile));
headerResult = new AccountHeaderBuilder()
.withActivity(this)
.withHeaderBackground(R.color.primary)
.withSelectionListEnabledForSingleProfile(false)
.addProfiles(
profileItem
)
.build();
//create the drawer and remember the `Drawer` result object
drawer = new DrawerBuilder()
.withActivity(this)
.withToolbar(mToolbar)
.withAccountHeader(headerResult)
.withItemAnimator(new AlphaCrossFadeAnimator())
.addDrawerItems(
new SectionDrawerItem().withName(R.string.time_tracker).withDivider(false),
new PrimaryDrawerItem().withIdentifier(1).withName(R.string.last_30_days).withIcon(R.drawable.icon_histogram),
new SectionDrawerItem().withName(R.string.settings).withDivider(false),
new PrimaryDrawerItem().withIdentifier(2).withName(R.string.i_beacon).withIcon(R.drawable.icon_ibeacon).withBadge(AppPreferences.getBeaconDetectionState()? "On":"Off").withBadgeStyle(new BadgeStyle().withTextColor(ContextCompat.getColor(this, R.color.medium_grey_text_color))),
new PrimaryDrawerItem().withIdentifier(3).withName(R.string.geofence).withIcon(R.drawable.icon_geofence).withBadge(AppPreferences.getGeofenceDetectionState()? "On":"Off").withBadgeStyle(new BadgeStyle().withTextColor(ContextCompat.getColor(this, R.color.medium_grey_text_color))),
new DividerDrawerItem(),
new PrimaryDrawerItem().withIdentifier(4).withName(R.string.feedback),
// new PrimaryDrawerItem().withIdentifier(5).withName(R.string.terms_and_cond),
new PrimaryDrawerItem().withIdentifier(6).withName(R.string.log_out)
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
Intent intent;
switch ((int)drawerItem.getIdentifier()){
case 1:
intent = new Intent(MainActivity.this, LastMonthTimeEntriesActivity.class);
startActivity(intent);
break;
case 2:
intent = new Intent(MainActivity.this, BeaconSettingsActivity.class);
startActivity(intent);
break;
case 3:
intent = new Intent(MainActivity.this, GeofenceSettingsActivity.class);
startActivity(intent);
break;
case 4:
PackageInfo pInfo = null;
try {
pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
Intent emailIntent = new Intent(Intent.ACTION_VIEW);
Uri data = Uri.parse("mailto:?subject=" + getResources().getString(R.string.app_name) + " - Version: " + pInfo.versionName + "&body=" + "" + "&to=" + EMAIL_ADDRESS);
emailIntent.setData(data);
startActivity(emailIntent);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
break;
case 5:
// Intent intent = new Intent(MainActivity.this, LastMonthTimeEntriesActivity.class);
// startActivity(intent);
break;
case 6:
logoutAction();
break;
}
return false;
}
})
.withCloseOnClick(true)
.build();
drawer.setSelection(-1);
}
示例14: createDrawer
import com.mikepenz.materialdrawer.model.DividerDrawerItem; //导入依赖的package包/类
private void createDrawer(Toolbar toolbar) {
result = new DrawerBuilder()
.withActivity(this)
.withToolbar(toolbar)
.withAccountHeader(header)
.addDrawerItems(
new PrimaryDrawerItem().withName(R.string.nav_lock_profile_text).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_view_carousel).color(ContextCompat.getColor(getApplicationContext(), R.color.material_drawer_dark_primary_icon))).withIdentifier(Constants.navLocker),
new PrimaryDrawerItem().withName(R.string.nav_visual_text).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_photo_library).color(ContextCompat.getColor(getApplicationContext(), R.color.material_drawer_dark_primary_icon))).withIdentifier(Constants.navVisual),
new PrimaryDrawerItem().withName(R.string.nav_notify_text).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_notifications_active).color(ContextCompat.getColor(getApplicationContext(), R.color.material_drawer_dark_primary_icon))).withIdentifier(Constants.navNotify),
new PrimaryDrawerItem().withName(R.string.nav_security_text).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_lock).color(ContextCompat.getColor(getApplicationContext(), R.color.material_drawer_dark_primary_icon))).withIdentifier(Constants.navSecurity),
new PrimaryDrawerItem().withName(R.string.nav_misc_text).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_list).color(ContextCompat.getColor(getApplicationContext(), R.color.material_drawer_dark_primary_icon))).withIdentifier(Constants.navMisc),
new DividerDrawerItem(),
new PrimaryDrawerItem().withName(R.string.nav_tips_tricks_text).withIdentifier(Constants.navTips),
new PrimaryDrawerItem().withName(R.string.nav_backup_restore_text).withIdentifier(Constants.navBackup),
new PrimaryDrawerItem().withName(R.string.nav_about_text).withIdentifier(Constants.navAbout)
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
Fragment fragment = null;
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
Intent intent = null;
if (drawerItem.getIdentifier() == Constants.navLocker) {
fragment = new LockProfilePref();
} else if (drawerItem.getIdentifier() == Constants.navVisual) {
//fragment = new VisualOptionFragment();
} else if (drawerItem.getIdentifier() == Constants.navNotify) {
//fragment = new NotificationOptionFragment();
} else if (drawerItem.getIdentifier() == Constants.navSecurity) {
//fragment = new SecurityOptionFragment();
} else if (drawerItem.getIdentifier() == Constants.navMisc) {
//fragment = new MiscOptionFragment();
} else if (drawerItem.getIdentifier() == Constants.navTips) {
} else if (drawerItem.getIdentifier() == Constants.navBackup) {
} else if (drawerItem.getIdentifier() == Constants.navAbout) {
intent = new Intent(MainSettingsActivity.this, AboutAppActivity.class);
}
//Execute the fragments/intents when selected
if (fragment != null) {
fragmentTransaction.replace(R.id.main_settings_container, fragment).commit();
}
if (intent != null) {
MainSettingsActivity.this.startActivity(intent);
}
return false;
}
})
.build();
result.setSelection(Constants.navLocker, true);
}
示例15: addDrawerItems
import com.mikepenz.materialdrawer.model.DividerDrawerItem; //导入依赖的package包/类
protected void addDrawerItems() {
//if you want to update the items at a later time it is recommended to keep it in a variable
PrimaryDrawerItem nav_home = new PrimaryDrawerItem().withIdentifier(1).withName(getString(R.string.nav_home)).withIcon(GoogleMaterial.Icon.gmd_home).withSelectable(false);
PrimaryDrawerItem nav_events = new PrimaryDrawerItem().withIdentifier(2).withName(getString(R.string.nav_events)).withIcon(GoogleMaterial.Icon.gmd_event).withSelectable(false);
PrimaryDrawerItem nav_popular = new PrimaryDrawerItem().withIdentifier(3).withName(getString(R.string.nav_popular)).withIcon(GoogleMaterial.Icon.gmd_favorite).withSelectable(false);
PrimaryDrawerItem nav_read = new PrimaryDrawerItem().withIdentifier(4).withName(getString(R.string.nav_read)).withIcon(GoogleMaterial.Icon.gmd_markunread_mailbox).withSelectable(false);
PrimaryDrawerItem nav_search = new PrimaryDrawerItem().withIdentifier(5).withName(getString(R.string.nav_search)).withIcon(GoogleMaterial.Icon.gmd_search).withSelectable(false);
PrimaryDrawerItem nav_messages = new PrimaryDrawerItem().withIdentifier(6).withName(getString(R.string.nav_messages)).withIcon(GoogleMaterial.Icon.gmd_mail_outline).withSelectable(false);
PrimaryDrawerItem nav_cpanel = new PrimaryDrawerItem().withIdentifier(7).withName(getString(R.string.nav_controlpanel)).withIcon(GoogleMaterial.Icon.gmd_build).withSelectable(false);
PrimaryDrawerItem nav_ticker = new PrimaryDrawerItem().withIdentifier(12).withName(getString(R.string.nav_ticker)).withIcon(GoogleMaterial.Icon.gmd_link).withSelectable(false);
PrimaryDrawerItem nav_settings = new PrimaryDrawerItem().withIdentifier(8).withName(getString(R.string.action_settings)).withIcon(GoogleMaterial.Icon.gmd_settings).withSelectable(false);
if (sharedPref.getBoolean("isLoggedIn", false)) {
nav_logout = new PrimaryDrawerItem().withIdentifier(9).withName(getString(R.string.nav_logout)).withIcon(GoogleMaterial.Icon.gmd_lock_open).withSelectable(false).withEnabled(true);
} else {
nav_logout = new PrimaryDrawerItem().withIdentifier(9).withName(getString(R.string.nav_logout)).withIcon(GoogleMaterial.Icon.gmd_lock_open).withSelectable(false).withEnabled(false);
}
PrimaryDrawerItem nav_donate = new PrimaryDrawerItem().withIdentifier(10).withName(getString(R.string.nav_donate)).withIcon(GoogleMaterial.Icon.gmd_card_giftcard).withSelectable(false);
drawer.addItems(
nav_home,
nav_events,
nav_popular,
nav_read,
nav_search,
nav_messages,
nav_cpanel,
nav_ticker
);
// Get Pinned items
RealmResults<PinnedItem> pinnedItems = realm.where(PinnedItem.class).findAll();
Log.d("Pitem list", pinnedItems.toString());
if (pinnedItems.size() > 0) {
drawer.addItem(new SectionDrawerItem().withName(getString(R.string.nav_pinnedpages)));
for (PinnedItem pitem : pinnedItems) {
drawer.addItem(new PrimaryDrawerItem().withName(pitem.getTitle()).withSelectable(false).withTag(pitem.getUrl()).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (sharedPref.getBoolean("settings_pagepinning_goto_newest_post", true)) {
if (drawerItem.getTag().toString().contains("?")) {
webview.loadUrl(drawerItem.getTag().toString() + "&goto=newpost");
} else {
webview.loadUrl(drawerItem.getTag().toString() + "?goto=newpost");
}
return false;
}
webview.loadUrl(drawerItem.getTag().toString());
return false;
}
}));
}
drawer.addItem(new SecondaryDrawerItem().withName(getString(R.string.nav_editpinnedpages)).withIcon(GoogleMaterial.Icon.gmd_edit).withIdentifier(11).withSelectable(false));
}
drawer.addItem(new DividerDrawerItem());
drawer.addItem(nav_settings);
drawer.addItem(nav_logout);
drawer.addItem(new DividerDrawerItem());
drawer.addItem(nav_donate);
}