Skip to content

Instantly share code, notes, and snippets.

@inktomi
Created March 16, 2015 16:09
Show Gist options
  • Save inktomi/4111d570baeef267eb4d to your computer and use it in GitHub Desktop.
Save inktomi/4111d570baeef267eb4d to your computer and use it in GitHub Desktop.
Side Panel Setup
private void setupSidePanel(Toolbar toolbar) {
// Ensure we'll be able to see the drawer toggle button.
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Account account = mAuthManager.getSingleAccountForType(BuildConfig.ACCOUNT_TYPE);
IDrawerItem signOutItem = null;
if (null != account) {
signOutItem = new PrimaryDrawerItem()
.withName(R.string.side_panel_sign_out)
.withIcon(R.drawable.ic_sign_out_unselected)
.withSelectedIcon(R.drawable.ic_sign_out_selected)
.withIdentifier(R.id.side_panel_sign_out);
}
mDrawer = new Drawer()
.withActivity(this)
.withTranslucentStatusBar(true)
.withSliderBackgroundColorRes(R.color.white)
.withToolbar(toolbar);
mDrawer.withAccountHeader(
new AccountHeader()
.withActivity(this)
.withProfileImagesClickable(false)
.withHeaderBackground(R.color.blue_bright)
.withSelectionListEnabledForSingleProfile(false)
.addProfiles(
new ProfileDrawerItem()
.withName("Billy Bob")
.withEmail("billybob@testemail.com")
)
.build()
);
mDrawer.addDrawerItems(
new PrimaryDrawerItem()
.withName(R.string.side_panel_dashboard)
.withIcon(R.drawable.ic_dashboard_unselected)
.withSelectedIcon(R.drawable.ic_dashboard_selected)
.withIdentifier(R.id.side_panel_dashboard),
new PrimaryDrawerItem()
.withName(R.string.side_panel_profile)
.withIcon(R.drawable.ic_profile_unselected)
.withSelectedIcon(R.drawable.ic_profile_selected)
.withIdentifier(R.id.side_panel_profile)
);
if (null != signOutItem) {
mDrawer.addDrawerItems(signOutItem);
}
mDrawer.addDrawerItems(new PrimaryDrawerItem()
.withName(R.string.side_panel_help)
.withIcon(R.drawable.ic_help_unselected)
.withSelectedIcon(R.drawable.ic_help_selected)
.withIdentifier(R.id.side_panel_help)
).build();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment