Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. Activity activity;
  2. Toolbar toolbar;
  3.  
  4. public DrawerHelper(Activity activity, Toolbar toolbar) {
  5. this.activity = activity;
  6. this.toolbar = toolbar;
  7. }
  8.  
  9. public void setDrawer() {
  10. Drawer result = new DrawerBuilder()
  11. .withActivity(activity)
  12. .withToolbar(toolbar)
  13. .withAccountHeader(getAccountHeader())
  14. .addDrawerItems(
  15. new SecondaryDrawerItem().withName("Transações").withIcon(GoogleMaterial.Icon.gmd_wb_sunny).withTag("transactions")
  16. )
  17. .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
  18. @Override
  19. public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
  20.  
  21. switch (drawerItem.getTag().toString()) {
  22. case "transactions":
  23. ((MenuActivity)activity).replaceFragment(new ListFragment(), null, false);
  24. break;
  25. }
  26.  
  27. return false;
  28. }
  29. })
  30. .build();
  31. }
  32.  
  33.  
  34. public AccountHeader getAccountHeader() {
  35. AccountHeader headerResult = new AccountHeaderBuilder()
  36. .withActivity(activity)
  37. .addProfiles(
  38. new ProfileDrawerItem().withName("Mike Penz").withEmail("mikepenz@gmail.com")
  39. )
  40. .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
  41. @Override
  42. public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {
  43. return false;
  44. }
  45. })
  46. .build();
  47.  
  48. return headerResult;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement