com.mikepenz.materialdrawer.accountswitcher.AccountHeaderBuilder Java Examples

The following examples show how to use com.mikepenz.materialdrawer.accountswitcher.AccountHeaderBuilder. 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: MainActivity.java    From minx with MIT License 5 votes vote down vote up
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 #2
Source File: UtilsUI.java    From Moticons with GNU General Public License v3.0 4 votes vote down vote up
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();
}