本文整理汇总了Java中com.mikepenz.materialdrawer.AccountHeaderBuilder类的典型用法代码示例。如果您正苦于以下问题:Java AccountHeaderBuilder类的具体用法?Java AccountHeaderBuilder怎么用?Java AccountHeaderBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AccountHeaderBuilder类属于com.mikepenz.materialdrawer包,在下文中一共展示了AccountHeaderBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAccountHeader
import com.mikepenz.materialdrawer.AccountHeaderBuilder; //导入依赖的package包/类
private AccountHeader getAccountHeader(){
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String name = prefs.getString(SSConstants.SS_USER_NAME_INDEX, getString(R.string.ss_menu_anonymous_name));
String email = prefs.getString(SSConstants.SS_USER_EMAIL_INDEX, getString(R.string.ss_menu_anonymous_email));
String photo = prefs.getString(SSConstants.SS_USER_PHOTO_INDEX, MENU_ANONYMOUS_PHOTO);
ssAccountHeader = new AccountHeaderBuilder()
.withActivity(this)
.withTranslucentStatusBar(true)
.withHeaderBackground(R.color.colorPrimary)
.addProfiles(
new ProfileDrawerItem().withName(name)
.withEmail(email)
.withIcon(photo)
.withSelectedTextColor(Color.parseColor(SSColorTheme.getInstance().getColorPrimary()))
.withIdentifier(MENU_HEADER_PROFILE_ID),
new ProfileSettingDrawerItem().withName(getString(R.string.ss_menu_sign_out)).withIdentifier(MENU_HEADER_LOGOUT_ID)
)
.withOnAccountHeaderListener(this)
.build();
return ssAccountHeader;
}
示例2: getAccountHeaderBuilder
import com.mikepenz.materialdrawer.AccountHeaderBuilder; //导入依赖的package包/类
/**
* @return desired header
* Sets up account header
* will not be added if null
*/
@Nullable
@Override
protected AccountHeaderBuilder getAccountHeaderBuilder() {
return new AccountHeaderBuilder().withActivity(this)
.withHeaderBackground(R.color.colorPrimary)
.withSelectionFirstLine(s(R.string.app_name))
.withSelectionSecondLine(BuildConfig.VERSION_NAME)
.withProfileImagesClickable(false)
.withResetDrawerOnProfileListClick(false)
.addProfiles(
new ProfileDrawerItem().withIcon(ContextCompat.getDrawable(this, R.mipmap.ic_launcher))
)
.withSelectionListEnabled(false)
.withSelectionListEnabledForSingleProfile(false);
}
示例3: buildHeader
import com.mikepenz.materialdrawer.AccountHeaderBuilder; //导入依赖的package包/类
private void buildHeader(Bundle savedInstanceState) {
// Create the AccountHeader
headerResult = new AccountHeaderBuilder()
.withActivity(this)
.withTranslucentStatusBar(true)
.withCompactStyle(false)
.withHeaderBackground(R.drawable.header)
.withCurrentProfileHiddenInList(true)
.withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
@Override
public boolean onProfileChanged(View view, IProfile profile, boolean current) {
//sample usage of the onProfileChanged listener
//if the clicked item has the identifier 1 add a new profile ;)
if (profile instanceof IDrawerItem && profile.getIdentifier() == PROFILE_ADD_ACCOUNT) {
showLoginActivity();
} else if (profile instanceof IDrawerItem && profile.getIdentifier() == PROFILE_LOGOUT) {
IProfile activeProfile = headerResult.getActiveProfile();
if (activeProfile != null) {
if (activeProfile.getName() != null && activeProfile.getEmail() != null) {
ParseUser.logOut();
}
if (miniResult != null)
miniResult.createItems();
}
} else if (profile instanceof IDrawerItem && profile.getIdentifier() == PROFILE_VIEW) {
showProfileView();
} else if (!current) {
switchUser();
} else {
Croperino.prepareGallery(MainActivity.this);
}
//false if you have not consumed the event and it should close the drawer
return false;
}
})
.withSavedInstance(savedInstanceState)
.build();
}
示例4: getAccountHeader
import com.mikepenz.materialdrawer.AccountHeaderBuilder; //导入依赖的package包/类
private AccountHeader getAccountHeader(Activity activity) {
//@formatter:off
return new AccountHeaderBuilder()
.withActivity(activity)
.withHeaderBackground(R.color.primary_dark)
.addProfiles(
new ProfileDrawerItem()
.withName(activity.getString(R.string.app_name))
)
.build();
//@formatter:on
}
示例5: getDrawerHeader
import com.mikepenz.materialdrawer.AccountHeaderBuilder; //导入依赖的package包/类
private AccountHeader getDrawerHeader(ProfileDrawerItem profile) {
return new AccountHeaderBuilder()
.withActivity(this)
.withSelectionListEnabledForSingleProfile(true)
.withHeaderBackground(R.drawable.background_nav)
.withHeaderBackgroundScaleType(ImageView.ScaleType.CENTER_CROP)
.addProfiles(profile,
//TODO: Add support for multi profiles
new ProfileSettingDrawerItem()
.withName("Wyloguj się")
.withIcon(R.drawable.logout)
.withOnDrawerItemClickListener(this::logout))
.build();
}
示例6: initAccount
import com.mikepenz.materialdrawer.AccountHeaderBuilder; //导入依赖的package包/类
@UiThread void initAccount() {
headerResult = new AccountHeaderBuilder().withActivity(act)
.withHeaderBackground(R.color.colorPrimary)
.addProfiles(new ProfileDrawerItem().withName("Usuário"))
.withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
@Override
public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {
return false;
}
})
.build();
}
示例7: setNavigationDrawer
import com.mikepenz.materialdrawer.AccountHeaderBuilder; //导入依赖的package包/类
/**
* Method to set Navigation Drawer
* Uses library https://github.com/mikepenz/MaterialDrawer
*/
private void setNavigationDrawer() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ProfileDrawerItem profileDrawerItem;
profileDrawerItem = new ProfileDrawerItem()
.withName("John Davis")
.withEmail("[email protected]")
.withIcon(getResources()
.getDrawable(R.drawable.ic_person_pink_600_48dp));
// Create the AccountHeader
AccountHeader headerResult = new AccountHeaderBuilder()
.withActivity(LibraryActivity.this)
.addProfiles(profileDrawerItem)
.withHeaderBackground(R.drawable.header)
.withAlternativeProfileHeaderSwitching(false)
.withCurrentProfileHiddenInList(true)
.withResetDrawerOnProfileListClick(false)
.withSelectionFirstLineShown(false)
.withSelectionListEnabledForSingleProfile(true)
.build();
navigationDrawer = new DrawerBuilder()
.withActivity(LibraryActivity.this)
.withAccountHeader(headerResult)
.build();
}
}, 0);
}
示例8: onCreate
import com.mikepenz.materialdrawer.AccountHeaderBuilder; //导入依赖的package包/类
@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();
}
示例9: initProfiles
import com.mikepenz.materialdrawer.AccountHeaderBuilder; //导入依赖的package包/类
public void initProfiles(Activity activity, AccountHeaderBuilder accountHeaderBuilder) {
File saveDir = new File(activity.getFilesDir(), "img");
for (User user : users) {
profileMap.put(user.username, new ProfileDrawerItem().withName(user.nickname));
try {
profileMap.get(user.username).withIcon(BitmapFactory.decodeStream(new FileInputStream(new File(saveDir, user.username + ".png"))));
} catch (FileNotFoundException e) {
}
accountHeaderBuilder.addProfiles(profileMap.get(user.username));
}
checkProfiles("initProfiles");
}
示例10: NavigationDrawer
import com.mikepenz.materialdrawer.AccountHeaderBuilder; //导入依赖的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.AccountHeaderBuilder; //导入依赖的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: initDrawer
import com.mikepenz.materialdrawer.AccountHeaderBuilder; //导入依赖的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);
}
示例13: onCreate
import com.mikepenz.materialdrawer.AccountHeaderBuilder; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
// Handle Toolbar
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.drawer_item_compact_header);
// Create a few sample profile
final IProfile profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("[email protected]").withIcon(R.drawable.profile);
final IProfile profile2 = new ProfileDrawerItem().withName("Max Muster").withEmail("[email protected]").withIcon(R.drawable.profile2);
final IProfile profile3 = new ProfileDrawerItem().withName("Felix House").withEmail("[email protected]").withIcon(R.drawable.profile3);
final IProfile profile4 = new ProfileDrawerItem().withName("Mr. X").withEmail("[email protected]").withIcon(R.drawable.profile4);
final IProfile profile5 = new ProfileDrawerItem().withName("Batman").withEmail("[email protected]").withIcon(R.drawable.profile5);
// Create the AccountHeader
headerResult = new AccountHeaderBuilder()
.withActivity(this)
.withCompactStyle(true)
.withHeaderBackground(R.drawable.header)
.addProfiles(
profile,
profile2,
profile3,
profile4,
profile5,
//don't ask but google uses 14dp for the add account icon in gmail but 20dp for the normal icons (like manage account)
new ProfileSettingDrawerItem().withName("Add Account").withDescription("Add new GitHub Account").withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_plus).actionBar().paddingDp(5).colorRes(R.color.material_drawer_dark_primary_text)).withIdentifier(PROFILE_SETTING),
new ProfileSettingDrawerItem().withName("Manage Account").withIcon(GoogleMaterial.Icon.gmd_settings)
)
.withSavedInstance(savedInstanceState)
.build();
//Create the drawer
result = new DrawerBuilder()
.withActivity(this)
.withAccountHeader(headerResult) //set the AccountHeader we created earlier for the header
.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).withIdentifier(5),
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)
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (drawerItem != null && drawerItem.getIdentifier() == 1) {
startSupportActionMode(new ActionBarCallBack());
findViewById(R.id.action_mode_bar).setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(CompactHeaderDrawerActivity.this, R.attr.colorPrimary, R.color.material_drawer_primary));
}
if (drawerItem instanceof Nameable) {
toolbar.setTitle(((Nameable) drawerItem).getName().getText(CompactHeaderDrawerActivity.this));
}
return false;
}
})
.withSavedInstance(savedInstanceState)
.build();
// set the selection to the item with the identifier 5
if (savedInstanceState == null) {
result.setSelection(5, false);
}
//set the back arrow in the toolbar
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(false);
}
示例14: setupDrawer
import com.mikepenz.materialdrawer.AccountHeaderBuilder; //导入依赖的package包/类
public void setupDrawer(User currentUser) {
String email = TextUtils.isEmpty(currentUser.getEmail()) ? "Guest" : currentUser.getEmail();
AccountHeader headerResult = new AccountHeaderBuilder()
.withActivity(this)
.withTextColor(getOutlayTheme().secondaryTextColor)
.withAlternativeProfileHeaderSwitching(false)
.withSelectionListEnabledForSingleProfile(false)
.withProfileImagesClickable(false)
.withCloseDrawerOnProfileListClick(false)
.addProfiles(
new ProfileDrawerItem()
.withEmail(email)
)
.build();
List<IDrawerItem> items = new ArrayList<>();
if (currentUser.isAnonymous()) {
items.add(new PrimaryDrawerItem().withName(app.outlay.R.string.menu_item_create_user).withIcon(MaterialDesignIconic.Icon.gmi_account_add).withIdentifier(ITEM_CREATE_USER));
}
items.add(new PrimaryDrawerItem().withName(app.outlay.R.string.menu_item_analysis).withIcon(MaterialDesignIconic.Icon.gmi_trending_up).withIdentifier(ITEM_ANALYSIS));
items.add(new PrimaryDrawerItem().withName(app.outlay.R.string.menu_item_categories).withIcon(MaterialDesignIconic.Icon.gmi_apps).withIdentifier(ITEM_CATEGORIES));
items.add(new PrimaryDrawerItem().withName(app.outlay.R.string.menu_item_feedback).withIcon(MaterialDesignIconic.Icon.gmi_email).withIdentifier(ITEM_FEEDBACK));
items.add(new PrimaryDrawerItem().withName(R.string.menu_item_settings).withIcon(MaterialDesignIconic.Icon.gmi_settings).withIdentifier(ITEM_SETTINGS));
items.add(new PrimaryDrawerItem().withName(app.outlay.R.string.menu_item_signout).withIcon(MaterialDesignIconic.Icon.gmi_sign_in).withIdentifier(ITEM_SING_OUT));
mainDrawer = new DrawerBuilder()
.withFullscreen(true)
.withActivity(this)
.withAccountHeader(headerResult)
.withSelectedItem(-1)
.addDrawerItems(items.toArray(new IDrawerItem[items.size()]))
.withOnDrawerItemClickListener((view, i, iDrawerItem) -> {
if (iDrawerItem != null) {
int id = (int) iDrawerItem.getIdentifier();
switch (id) {
case ITEM_CATEGORIES:
analytics().trackViewCategoriesList();
SingleFragmentActivity.start(this, CategoriesFragment.class);
break;
case ITEM_ANALYSIS:
analytics().trackAnalysisView();
SingleFragmentActivity.start(this, AnalysisFragment.class);
break;
case ITEM_SETTINGS:
SingleFragmentActivity.start(this, SettingsFragment.class);
break;
case ITEM_FEEDBACK:
analytics().trackFeedbackClick();
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto", Constants.CONTACT_EMAIL, null));
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{Constants.CONTACT_EMAIL});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Outlay Feedback");
try {
startActivity(Intent.createChooser(emailIntent, getString(app.outlay.R.string.label_send_email)));
} catch (android.content.ActivityNotFoundException ex) {
Alert.error(getRootView(), getString(app.outlay.R.string.error_no_email_clients));
}
break;
case ITEM_ABOUT:
SingleFragmentActivity.start(this, AboutFragment.class);
break;
case ITEM_SING_OUT:
analytics().trackSingOut();
signOut();
break;
case ITEM_CREATE_USER:
createUser();
break;
}
mainDrawer.setSelection(-1);
mainDrawer.closeDrawer();
}
return false;
})
.build();
}
示例15: renderDrawerOptions
import com.mikepenz.materialdrawer.AccountHeaderBuilder; //导入依赖的package包/类
/**
* Methods from the {@link HomeView} interface
*/
@Override
public void renderDrawerOptions() {
IProfile profile = new ProfileDrawerItem()
.withName(userModel.getName())
.withEmail(userModel.getEmail())
.withIcon(Uri.parse(userModel.getProfilePictureUrl()));
AccountHeader accountHeader = new AccountHeaderBuilder()
.withActivity(this)
.withHeaderBackground(R.drawable.header)
.addProfiles(profile)
.build();
drawer = new DrawerBuilder()
.withActivity(this)
.withActionBarDrawerToggle(true)
.withAccountHeader(accountHeader)
.withToolbar(toolbar)
.addDrawerItems(
new PrimaryDrawerItem()
.withName(getString(R.string.app_nav_drawer_1))
.withIdentifier(ActivityMain.DRAWER_IDENTIFIER_HOME)
.withIcon(GoogleMaterial.Icon.gmd_home),
new PrimaryDrawerItem()
.withName(getString(R.string.app_nav_drawer_2))
.withIdentifier(ActivityMain.DRAWER_IDENTIFIER_MY_POSTS)
.withIcon(GoogleMaterial.Icon.gmd_content_paste))
.withSelectedItem(DRAWER_IDENTIFIER_HOME)
.build();
drawer.setOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
onDrawerItemSelected(drawerItem.getIdentifier());
return false;
}
});
}