Java Code Examples for com.mikepenz.materialdrawer.DrawerBuilder#withStatusBarColor()

The following examples show how to use com.mikepenz.materialdrawer.DrawerBuilder#withStatusBarColor() . 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 openapk with GNU General Public License v3.0 4 votes vote down vote up
public static Drawer setNavigationDrawer(final Context context, final Toolbar toolbar, final RecyclerView recyclerView, boolean badge, final AppAdapter appInstalledAdapter, final AppAdapter appSystemAdapter, final AppAdapter appDisabledAdapter, final AppAdapter appHiddenAdapter, final AppAdapter appFavoriteAdapter) {
    AppPreferences appPreferences = App.getAppPreferences();
    final Activity activity = (Activity) context;
    int header;

    // check for dark theme
    Integer badgeColor;
    BadgeStyle badgeStyle;
    if (appPreferences.getTheme().equals("0")) {
        badgeColor = ContextCompat.getColor(context, R.color.badge_light);
        badgeStyle = new BadgeStyle(badgeColor, badgeColor).withTextColor(context.getResources().getColor(R.color.text_light));
        header = R.drawable.header_day;
    } else {
        badgeColor = ContextCompat.getColor(context, R.color.badge_dark);
        badgeStyle = new BadgeStyle(badgeColor, badgeColor).withTextColor(context.getResources().getColor(R.color.text_dark));
        header = R.drawable.header_night;
    }

    AccountHeader headerResult = new AccountHeaderBuilder()
            .withActivity(activity)
            .withHeaderBackground(header)
            .build();

    DrawerBuilder drawerBuilder = new DrawerBuilder();
    drawerBuilder.withActivity(activity);
    drawerBuilder.withToolbar(toolbar);
    drawerBuilder.withAccountHeader(headerResult);
    drawerBuilder.withStatusBarColor(OtherUtils.dark(appPreferences.getPrimaryColor(), 0.8));

    if (badge) {
        String installedApps = Integer.toString(appInstalledAdapter.getItemCount());
        String systemApps = Integer.toString(appSystemAdapter.getItemCount());
        String disabledApps = Integer.toString(appDisabledAdapter.getItemCount());
        String hiddenApps = Integer.toString(appHiddenAdapter.getItemCount());
        String favoriteApps = Integer.toString(appFavoriteAdapter.getItemCount());
        drawerBuilder.addDrawerItems(
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_installed)).withIcon(GoogleMaterial.Icon.gmd_phone_android).withBadge(installedApps).withBadgeStyle(badgeStyle).withIdentifier(0),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_system)).withIcon(GoogleMaterial.Icon.gmd_android).withBadge(systemApps).withBadgeStyle(badgeStyle).withIdentifier(1),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_disabled)).withIcon(GoogleMaterial.Icon.gmd_remove_circle_outline).withBadge(disabledApps).withBadgeStyle(badgeStyle).withIdentifier(2),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_hidden)).withIcon(GoogleMaterial.Icon.gmd_visibility_off).withBadge(hiddenApps).withBadgeStyle(badgeStyle).withIdentifier(3),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_favorite)).withIcon(GoogleMaterial.Icon.gmd_star).withBadge(favoriteApps).withBadgeStyle(badgeStyle).withIdentifier(4),
                new DividerDrawerItem(),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.settings)).withIcon(GoogleMaterial.Icon.gmd_settings).withSelectable(false).withIdentifier(5),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.about)).withIcon(GoogleMaterial.Icon.gmd_info).withSelectable(false).withIdentifier(6));
    } else {
        drawerBuilder.addDrawerItems(
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_installed)).withIcon(GoogleMaterial.Icon.gmd_phone_android).withIdentifier(0),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_system)).withIcon(GoogleMaterial.Icon.gmd_android).withIdentifier(1),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_disabled)).withIcon(GoogleMaterial.Icon.gmd_remove_circle_outline).withIdentifier(2),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_hidden)).withIcon(GoogleMaterial.Icon.gmd_visibility_off).withIdentifier(3),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.apps_favorite)).withIcon(GoogleMaterial.Icon.gmd_star).withIdentifier(4),
                new DividerDrawerItem(),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.settings)).withIcon(GoogleMaterial.Icon.gmd_settings).withSelectable(false).withIdentifier(5),
                new PrimaryDrawerItem().withName(context.getResources().getString(R.string.about)).withIcon(GoogleMaterial.Icon.gmd_info).withSelectable(false).withIdentifier(6));
    }

    drawerBuilder.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
        @Override
        public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
            switch (drawerItem.getIdentifier()) {
                case 0:
                    recyclerView.setAdapter(appInstalledAdapter);
                    App.setCurrentAdapter(0);
                    OtherUtils.setToolbarTitle(context, context.getResources().getString(R.string.apps_installed));
                    break;
                case 1:
                    recyclerView.setAdapter(appSystemAdapter);
                    App.setCurrentAdapter(1);
                    OtherUtils.setToolbarTitle(context, context.getResources().getString(R.string.apps_system));
                    break;
                case 2:
                    recyclerView.setAdapter(appDisabledAdapter);
                    App.setCurrentAdapter(2);
                    OtherUtils.setToolbarTitle(context, context.getResources().getString(R.string.apps_disabled));
                    break;
                case 3:
                    recyclerView.setAdapter(appHiddenAdapter);
                    App.setCurrentAdapter(3);
                    OtherUtils.setToolbarTitle(context, context.getResources().getString(R.string.apps_hidden));
                    break;
                case 4:
                    recyclerView.setAdapter(appFavoriteAdapter);
                    App.setCurrentAdapter(4);
                    OtherUtils.setToolbarTitle(context, context.getResources().getString(R.string.apps_favorite));
                    break;
                case 5:
                    context.startActivity(new Intent(context, SettingsActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
                    break;
                case 6:
                    context.startActivity(new Intent(context, AboutActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
                    break;
                default:
                    break;
            }
            return false;
        }
    });
    return drawerBuilder.build();
}