Search in sources :

Example 6 with ProfileDrawerItem

use of com.mikepenz.materialdrawer.model.ProfileDrawerItem in project MaterialDrawer by mikepenz.

the class MiniDrawer method generateMiniDrawerItem.

/**
     * generates a MiniDrawerItem from a IDrawerItem
     *
     * @param drawerItem
     * @return
     */
public IDrawerItem generateMiniDrawerItem(IDrawerItem drawerItem) {
    if (drawerItem instanceof SecondaryDrawerItem) {
        return mIncludeSecondaryDrawerItems ? new MiniDrawerItem((SecondaryDrawerItem) drawerItem).withEnableSelectedBackground(mEnableSelectedMiniDrawerItemBackground) : null;
    } else if (drawerItem instanceof PrimaryDrawerItem) {
        return new MiniDrawerItem((PrimaryDrawerItem) drawerItem).withEnableSelectedBackground(mEnableSelectedMiniDrawerItemBackground);
    } else if (drawerItem instanceof ProfileDrawerItem) {
        MiniProfileDrawerItem mpdi = new MiniProfileDrawerItem((ProfileDrawerItem) drawerItem);
        mpdi.withEnabled(mEnableProfileClick);
        return mpdi;
    }
    return null;
}
Also used : MiniDrawerItem(com.mikepenz.materialdrawer.model.MiniDrawerItem) PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) MiniProfileDrawerItem(com.mikepenz.materialdrawer.model.MiniProfileDrawerItem) ProfileDrawerItem(com.mikepenz.materialdrawer.model.ProfileDrawerItem) SecondaryDrawerItem(com.mikepenz.materialdrawer.model.SecondaryDrawerItem) MiniProfileDrawerItem(com.mikepenz.materialdrawer.model.MiniProfileDrawerItem)

Example 7 with ProfileDrawerItem

use of com.mikepenz.materialdrawer.model.ProfileDrawerItem in project ocreader by schaal.

the class ListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_list);
    setSupportActionBar(binding.toolbarLayout.toolbar);
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    binding.swipeRefreshLayout.setColorSchemeResources(R.color.primary);
    binding.swipeRefreshLayout.setOnRefreshListener(this);
    profileDrawerItem = new ProfileDrawerItem().withName(preferences.getString(Preferences.USERNAME.getKey(), getString(R.string.app_name))).withEmail(Preferences.URL.getString(preferences));
    updateUserProfile();
    IProfile profileSettingsItem = new ProfileSettingDrawerItem().withName(getString(R.string.account_settings)).withIconTinted(true).withIcon(R.drawable.ic_settings).withTag((Runnable) () -> {
        Intent loginIntent = new Intent(ListActivity.this, LoginActivity.class);
        startActivityForResult(loginIntent, LoginActivity.REQUEST_CODE);
    });
    accountHeader = new AccountHeaderBuilder().withActivity(this).withHeaderBackground(R.drawable.header_background).addProfiles(profileDrawerItem, profileSettingsItem).withCurrentProfileHiddenInList(true).withProfileImagesClickable(false).withSavedInstance(savedInstanceState).withOnAccountHeaderListener((view, profile, current) -> {
        if (profile instanceof Tagable) {
            Tagable tagable = (Tagable) profile;
            if (tagable.getTag() instanceof Runnable) {
                ((Runnable) tagable.getTag()).run();
                return false;
            }
        }
        return true;
    }).build();
    refreshDrawerItem = new PrimaryDrawerItem().withName(getString(R.string.action_sync)).withSelectable(false).withIconTintingEnabled(true).withIcon(R.drawable.ic_refresh).withIdentifier(REFRESH_DRAWER_ITEM_ID).withTag((Runnable) () -> SyncService.startSync(ListActivity.this));
    IDrawerItem settingsDrawerItem = new PrimaryDrawerItem().withName(R.string.settings).withIcon(R.drawable.ic_settings).withIconTintingEnabled(true).withSelectable(false).withTag((Runnable) () -> {
        startDrawer.closeDrawer();
        Intent settingsIntent = new Intent(ListActivity.this, SettingsActivity.class);
        startActivity(settingsIntent);
    });
    DrawerBuilder startDrawerBuilder = new DrawerBuilder().withActivity(this).withAccountHeader(accountHeader).addStickyDrawerItems(settingsDrawerItem, refreshDrawerItem).withOnDrawerListener(new Drawer.OnDrawerListener() {

        @Override
        public void onDrawerOpened(View drawerView) {
            drawerManager.getStartAdapter().updateUnreadCount(getRealm(), isShowOnlyUnread());
        }

        @Override
        public void onDrawerClosed(View drawerView) {
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
        }
    }).withOnDrawerItemClickListener((view, position, drawerItem) -> {
        if (drawerItem.getTag() instanceof TreeItem) {
            TreeItem item = (TreeItem) drawerItem.getTag();
            onStartDrawerItemClicked(item);
            return false;
        } else if (drawerItem.getTag() instanceof Runnable) {
            ((Runnable) drawerItem.getTag()).run();
        }
        return true;
    }).withSavedInstance(savedInstanceState);
    DrawerBuilder endDrawerBuilder = new DrawerBuilder().withActivity(this).withDrawerGravity(Gravity.END).withSavedInstance(savedInstanceState).withShowDrawerOnFirstLaunch(true).withOnDrawerListener(new Drawer.OnDrawerListener() {

        @Override
        public void onDrawerOpened(View drawerView) {
            drawerManager.getEndAdapter().updateUnreadCount(getRealm(), isShowOnlyUnread());
        }

        @Override
        public void onDrawerClosed(View drawerView) {
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
        }
    }).withOnDrawerItemClickListener((view, position, drawerItem) -> {
        if (drawerItem.getTag() instanceof Feed) {
            Feed feed = (Feed) drawerItem.getTag();
            onEndDrawerItemClicked(feed);
            return false;
        }
        return true;
    });
    startDrawerBuilder.withToolbar(binding.toolbarLayout.toolbar);
    startDrawer = startDrawerBuilder.build();
    drawerManager = new DrawerManager(this, startDrawer, endDrawerBuilder.append(startDrawer), unreadSwitchListener);
    layoutManager = new LinearLayoutManager(this);
    adapter = new ErrorAdapter(this, getRealm(), drawerManager.getState(), this, this);
    binding.fabMarkAllAsRead.setOnClickListener(new View.OnClickListener() {

        private void onCompletion(View view) {
            adapter.updateItems(false);
            view.setEnabled(true);
            binding.fabMarkAllAsRead.toggleSync();
        }

        @Override
        public void onClick(final View view) {
            if (binding.fabMarkAllAsRead.isSync()) {
                SyncService.startSync(ListActivity.this);
                binding.fabMarkAllAsRead.toggleSync();
            } else {
                Queries.markTemporaryFeedAsRead(getRealm(), () -> onCompletion(view), error -> {
                    Log.e(TAG, "Failed to mark temporary feed as read", error);
                    onCompletion(view);
                });
            }
        }
    });
    binding.fabMarkAllAsRead.setOnLongClickListener(v -> {
        Toast.makeText(ListActivity.this, R.string.mark_all_as_read, Toast.LENGTH_SHORT).show();
        return true;
    });
    binding.itemsRecyclerview.setAdapter(adapter);
    binding.itemsRecyclerview.setLayoutManager(layoutManager);
    if (savedInstanceState == null && getIntent().hasExtra(SyncService.EXTRA_ID)) {
        drawerManager.getState().restore(getRealm(), getIntent().getIntExtra(SyncService.EXTRA_ID, -10), null, false);
    } else {
        drawerManager.getState().restoreInstanceState(getRealm(), getPreferences(MODE_PRIVATE));
    }
    binding.itemsRecyclerview.addItemDecoration(new DividerItemDecoration(this, R.dimen.divider_inset));
    adapter.updateItems(false);
    if (savedInstanceState != null) {
        layoutManager.onRestoreInstanceState(savedInstanceState.getParcelable(LAYOUT_MANAGER_STATE));
        adapter.onRestoreInstanceState(savedInstanceState);
        if (adapter.getSelectedItemsCount() > 0) {
            actionMode = startActionMode(this);
        }
    }
    drawerManager.reloadAdapters(getRealm(), isShowOnlyUnread());
    // noinspection ConstantConditions
    getSupportActionBar().setTitle(drawerManager.getState().getTreeItem().getName());
}
Also used : ActionMode(android.view.ActionMode) Bundle(android.os.Bundle) OnCheckedChangeListener(com.mikepenz.materialdrawer.interfaces.OnCheckedChangeListener) Libs(com.mikepenz.aboutlibraries.Libs) DividerItemDecoration(email.schaal.ocreader.view.DividerItemDecoration) Nameable(com.mikepenz.materialdrawer.model.interfaces.Nameable) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) ActivityListBinding(email.schaal.ocreader.databinding.ActivityListBinding) Tagable(com.mikepenz.materialdrawer.model.interfaces.Tagable) Base64InputStream(android.util.Base64InputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) Item(email.schaal.ocreader.database.model.Item) TemporaryFeed(email.schaal.ocreader.database.model.TemporaryFeed) View(android.view.View) ProfileSettingDrawerItem(com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem) PreferenceManager(android.preference.PreferenceManager) SyncType(email.schaal.ocreader.service.SyncType) Log(android.util.Log) AccountHeader(com.mikepenz.materialdrawer.AccountHeader) ContextCompat(android.support.v4.content.ContextCompat) AllUnreadFolder(email.schaal.ocreader.database.model.AllUnreadFolder) PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) BroadcastReceiver(android.content.BroadcastReceiver) Queries(email.schaal.ocreader.database.Queries) ErrorAdapter(email.schaal.ocreader.view.ErrorAdapter) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) Nullable(android.support.annotation.Nullable) Snackbar(android.support.design.widget.Snackbar) Context(android.content.Context) Intent(android.content.Intent) BitmapFactory(android.graphics.BitmapFactory) IProfile(com.mikepenz.materialdrawer.model.interfaces.IProfile) NonNull(android.support.annotation.NonNull) IDrawerItem(com.mikepenz.materialdrawer.model.interfaces.IDrawerItem) TreeItem(email.schaal.ocreader.database.model.TreeItem) MenuItem(android.view.MenuItem) SyncService(email.schaal.ocreader.service.SyncService) Drawer(com.mikepenz.materialdrawer.Drawer) Toast(android.widget.Toast) Menu(android.view.Menu) User(email.schaal.ocreader.database.model.User) DrawerManager(email.schaal.ocreader.view.drawer.DrawerManager) DrawerLayout(android.support.v4.widget.DrawerLayout) ProfileDrawerItem(com.mikepenz.materialdrawer.model.ProfileDrawerItem) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) LibsBuilder(com.mikepenz.aboutlibraries.LibsBuilder) Feed(email.schaal.ocreader.database.model.Feed) LoadMoreAdapter(email.schaal.ocreader.view.LoadMoreAdapter) CompoundButton(android.widget.CompoundButton) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Gravity(android.view.Gravity) SharedPreferences(android.content.SharedPreferences) Bitmap(android.graphics.Bitmap) DataBindingUtil(android.databinding.DataBindingUtil) Base64(android.util.Base64) ItemViewHolder(email.schaal.ocreader.view.ItemViewHolder) AccountHeaderBuilder(com.mikepenz.materialdrawer.AccountHeaderBuilder) Activity(android.app.Activity) PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) IDrawerItem(com.mikepenz.materialdrawer.model.interfaces.IDrawerItem) ProfileSettingDrawerItem(com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem) ErrorAdapter(email.schaal.ocreader.view.ErrorAdapter) TreeItem(email.schaal.ocreader.database.model.TreeItem) ProfileDrawerItem(com.mikepenz.materialdrawer.model.ProfileDrawerItem) AccountHeaderBuilder(com.mikepenz.materialdrawer.AccountHeaderBuilder) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) IProfile(com.mikepenz.materialdrawer.model.interfaces.IProfile) TemporaryFeed(email.schaal.ocreader.database.model.TemporaryFeed) Feed(email.schaal.ocreader.database.model.Feed) DrawerManager(email.schaal.ocreader.view.drawer.DrawerManager) SharedPreferences(android.content.SharedPreferences) Intent(android.content.Intent) Drawer(com.mikepenz.materialdrawer.Drawer) DividerItemDecoration(email.schaal.ocreader.view.DividerItemDecoration) View(android.view.View) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) Tagable(com.mikepenz.materialdrawer.model.interfaces.Tagable)

Example 8 with ProfileDrawerItem

use of com.mikepenz.materialdrawer.model.ProfileDrawerItem in project TeamCityApp by vase4kin.

the class DrawerViewImpl method getUserProfiles.

/**
 * Get user profiles
 */
private ArrayList<IProfile> getUserProfiles(DrawerDataModel dataModel) {
    ArrayList<IProfile> profiles = new ArrayList<>();
    for (UserAccount userAccount : dataModel) {
        IProfile iProfile = new ProfileDrawerItem().withName(userAccount.getUserName()).withEmail(userAccount.getTeamcityUrl()).withIcon(new IconDrawable(mActivity, MaterialIcons.md_account_circle).colorRes(mDefaultColor));
        profiles.add(iProfile);
    }
    return profiles;
}
Also used : ProfileDrawerItem(com.mikepenz.materialdrawer.model.ProfileDrawerItem) ArrayList(java.util.ArrayList) IconDrawable(com.joanzapata.iconify.IconDrawable) IProfile(com.mikepenz.materialdrawer.model.interfaces.IProfile) UserAccount(com.github.vase4kin.teamcityapp.storage.api.UserAccount)

Example 9 with ProfileDrawerItem

use of com.mikepenz.materialdrawer.model.ProfileDrawerItem in project ETSMobile-Android2 by ApplETS.

the class MainActivity method initDrawer.

private void initDrawer() {
    boolean isUserLoggedIn = ApplicationManager.userCredentials != null;
    String studentName = "";
    String codeUniversel = "";
    ProfilManager profilManager = new ProfilManager(this);
    Etudiant etudiant = profilManager.getEtudiant();
    if (etudiant != null) {
        String prenom = etudiant.prenom != null ? etudiant.prenom.trim() : "";
        String nom = etudiant.nom != null ? etudiant.nom.trim() : "";
        studentName = prenom + " " + nom;
        codeUniversel = etudiant.codePerm != null ? etudiant.codePerm : "";
    }
    headerResult = new AccountHeaderBuilder().withActivity(this).withHeaderBackground(R.drawable.ets_background_grayscale).withSelectionListEnabledForSingleProfile(false).addProfiles(new ProfileDrawerItem().withName(codeUniversel).withEmail(studentName).withSelectedTextColor(ContextCompat.getColor(this, R.color.red)).withIcon(R.drawable.ic_user).withSelectable(isUserLoggedIn)).withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {

        @Override
        public boolean onProfileChanged(View view, IProfile profile, boolean current) {
            goToFragment(new ProfilFragment(), ProfilFragment.class.getName());
            activityDrawer.deselect();
            return false;
        }
    }).build();
    DrawerBuilder drawerBuilder = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withAccountHeader(headerResult).withSelectedItem(isUserLoggedIn ? TODAY_ITEM : ABOUT_ITEM).withDisplayBelowStatusBar(true).withShowDrawerOnFirstLaunch(true).addDrawerItems(new ExpandableDrawerItem().withName(R.string.menu_section_1_moi).withSelectable(false).withSubItems(new SecondaryDrawerItem().withName(R.string.menu_section_1_profil).withIdentifier(PROFILE_ITEM).withIcon(R.drawable.ic_ico_profil).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_1_ajd).withIdentifier(TODAY_ITEM).withIcon(R.drawable.ic_ico_aujourdhui).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_1_horaire).withIdentifier(SCHEDULE_ITEM).withIcon(R.drawable.ic_ico_schedule).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_1_notes).withIdentifier(COURSE_ITEM).withIcon(R.drawable.ic_ico_notes).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_2_moodle).withIdentifier(MOODLE_ITEM).withIcon(R.drawable.ic_moodle_icon_small).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_1_monETS).withIdentifier(MONETS_ITEM).withSelectable(false).withIcon(R.drawable.ic_monets).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_1_bandwith).withIdentifier(BANDWIDTH_ITEM).withIcon(R.drawable.ic_ico_internet), new SecondaryDrawerItem().withName(R.string.menu_section_3_beta).withIdentifier(BETA_VERSION_ITEM).withIcon(R.drawable.ic_beta_24dp)), new ExpandableDrawerItem().withName(R.string.menu_section_2_ets).withSelectable(false).withSubItems(new SecondaryDrawerItem().withName(R.string.menu_section_2_news).withIdentifier(NEWS_ITEM).withIcon(R.drawable.ic_ico_news), new SecondaryDrawerItem().withName(R.string.menu_section_2_bottin).withIdentifier(DIRECTORY_ITEM).withIcon(R.drawable.ic_ico_bottin), new SecondaryDrawerItem().withName(R.string.menu_section_2_biblio).withIdentifier(LIBRARY_ITEM).withSelectable(false).withIcon(R.drawable.ic_ico_library), new SecondaryDrawerItem().withName(R.string.menu_section_2_securite).withIdentifier(SECURITY_ITEM).withIcon(R.drawable.ic_ico_security)), new ExpandableDrawerItem().withName(R.string.menu_section_3_applets).withSelectable(false).withSubItems(new SecondaryDrawerItem().withName(R.string.menu_section_3_apps).withIdentifier(ACHIEVEMENTS_ITEM).withIcon(R.drawable.ic_star_60x60), new SecondaryDrawerItem().withName(R.string.menu_section_3_about).withIdentifier(ABOUT_ITEM).withIcon(R.drawable.ic_logo_icon_final), new SecondaryDrawerItem().withName(R.string.menu_section_3_faq).withIdentifier(FAQ_ITEM).withIcon(R.drawable.ic_ico_faq)));
    if (isUserLoggedIn)
        drawerBuilder.addStickyDrawerItems(new SecondaryDrawerItem().withName(R.string.action_logout).withIdentifier(LOGOUT).withTextColorRes(R.color.red));
    else
        drawerBuilder.addStickyDrawerItems(new SecondaryDrawerItem().withName(R.string.action_login).withIdentifier(LOGIN));
    drawerBuilder.withOnDrawerItemClickListener(drawerItemClickListener);
    activityDrawer = drawerBuilder.build();
    activityDrawer.getExpandableExtension().expand(1);
}
Also used : Etudiant(ca.etsmtl.applets.etsmobile.model.Etudiant) ProfilFragment(ca.etsmtl.applets.etsmobile.ui.fragment.ProfilFragment) ProfileDrawerItem(com.mikepenz.materialdrawer.model.ProfileDrawerItem) AccountHeaderBuilder(com.mikepenz.materialdrawer.AccountHeaderBuilder) View(android.view.View) TextView(android.widget.TextView) TapTargetView(com.getkeepsafe.taptargetview.TapTargetView) SecondaryDrawerItem(com.mikepenz.materialdrawer.model.SecondaryDrawerItem) AccountHeader(com.mikepenz.materialdrawer.AccountHeader) ExpandableDrawerItem(com.mikepenz.materialdrawer.model.ExpandableDrawerItem) IProfile(com.mikepenz.materialdrawer.model.interfaces.IProfile) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) ProfilManager(ca.etsmtl.applets.etsmobile.util.ProfilManager)

Example 10 with ProfileDrawerItem

use of com.mikepenz.materialdrawer.model.ProfileDrawerItem in project MaterialDrawer by mikepenz.

the class EmbeddedDrawerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_embedded);
    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(R.string.drawer_item_embedded_drawer);
    // Create a few sample profile
    // NOTE you have to define the loader logic too. See the CustomApplication for more details
    final IProfile profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("mikepenz@gmail.com").withIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460");
    final IProfile profile2 = new ProfileDrawerItem().withName("Bernat Borras").withEmail("alorma@github.com").withIcon(Uri.parse("https://avatars3.githubusercontent.com/u/887462?v=3&s=460"));
    final IProfile profile3 = new ProfileDrawerItem().withName("Max Muster").withEmail("max.mustermann@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile2));
    final IProfile profile4 = new ProfileDrawerItem().withName("Felix House").withEmail("felix.house@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile3));
    final IProfile profile5 = new ProfileDrawerItem().withName("Mr. X").withEmail("mister.x.super@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile4)).withIdentifier(4);
    final IProfile profile6 = new ProfileDrawerItem().withName("Batman").withEmail("batman@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile5));
    // Create the AccountHeader
    headerResult = new AccountHeaderBuilder().withActivity(this).withHeaderBackground(R.drawable.header).withTranslucentStatusBar(false).addProfiles(profile, profile2, profile3, profile4, profile5, profile6, //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(GoogleMaterial.Icon.gmd_plus).withIdentifier(PROFILE_SETTING), new ProfileSettingDrawerItem().withName("Manage Account").withIcon(GoogleMaterial.Icon.gmd_settings)).withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {

        @Override
        public boolean onProfileChanged(View view, IProfile profile, boolean current) {
            //if the clicked item has the identifier 1 add a new profile ;)
            if (profile instanceof IDrawerItem && ((IDrawerItem) profile).getIdentifier() == PROFILE_SETTING) {
                IProfile newProfile = new ProfileDrawerItem().withNameShown(true).withName("Batman").withEmail("batman@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile5));
                if (headerResult.getProfiles() != null) {
                    //we know that there are 2 setting elements. set the new profile above them ;)
                    headerResult.addProfile(newProfile, headerResult.getProfiles().size() - 2);
                } else {
                    headerResult.addProfiles(newProfile);
                }
            }
            //false if you have not consumed the event and it should close the drawer
            return false;
        }
    }).withSavedInstance(savedInstanceState).build();
    result = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withTranslucentStatusBar(false).withAccountHeader(//set the AccountHeader we created earlier for the header
    headerResult).addDrawerItems(new PrimaryDrawerItem().withName(R.string.drawer_item_compact_header).withIcon(GoogleMaterial.Icon.gmd_sun).withIdentifier(1), new PrimaryDrawerItem().withName(R.string.drawer_item_action_bar_drawer).withIcon(FontAwesome.Icon.faw_home).withBadge("22").withBadgeStyle(new BadgeStyle(Color.RED, Color.RED)).withIdentifier(2), new PrimaryDrawerItem().withName(R.string.drawer_item_multi_drawer).withIcon(FontAwesome.Icon.faw_gamepad).withIdentifier(3), new PrimaryDrawerItem().withName(R.string.drawer_item_non_translucent_status_drawer).withIcon(FontAwesome.Icon.faw_eye).withIdentifier(4), new PrimaryDrawerItem().withDescription("A more complex sample").withName(R.string.drawer_item_advanced_drawer).withIcon(GoogleMaterial.Icon.gmd_adb).withIdentifier(5), new SectionDrawerItem().withName(R.string.drawer_item_section_header), new SecondaryDrawerItem().withName(R.string.drawer_item_open_source).withIcon(FontAwesome.Icon.faw_github), new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withIcon(GoogleMaterial.Icon.gmd_format_color_fill).withTag("Bullhorn"), new DividerDrawerItem(), new SwitchDrawerItem().withName("Switch").withIcon(Octicons.Icon.oct_tools).withChecked(true).withOnCheckedChangeListener(onCheckedChangeListener), new ToggleDrawerItem().withName("Toggle").withIcon(Octicons.Icon.oct_tools).withChecked(true).withOnCheckedChangeListener(onCheckedChangeListener)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {

        @Override
        public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
            if (drawerItem instanceof Nameable) {
                Toast.makeText(EmbeddedDrawerActivity.this, ((Nameable) drawerItem).getName().getText(EmbeddedDrawerActivity.this), Toast.LENGTH_SHORT).show();
            }
            return false;
        }
    }).withSavedInstance(savedInstanceState).buildView();
    ((ViewGroup) findViewById(R.id.frame_container)).addView(result.getSlider());
}
Also used : IDrawerItem(com.mikepenz.materialdrawer.model.interfaces.IDrawerItem) PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) DividerDrawerItem(com.mikepenz.materialdrawer.model.DividerDrawerItem) ProfileSettingDrawerItem(com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem) ProfileDrawerItem(com.mikepenz.materialdrawer.model.ProfileDrawerItem) ViewGroup(android.view.ViewGroup) AccountHeaderBuilder(com.mikepenz.materialdrawer.AccountHeaderBuilder) SwitchDrawerItem(com.mikepenz.materialdrawer.model.SwitchDrawerItem) View(android.view.View) SecondaryDrawerItem(com.mikepenz.materialdrawer.model.SecondaryDrawerItem) ToggleDrawerItem(com.mikepenz.materialdrawer.model.ToggleDrawerItem) Nameable(com.mikepenz.materialdrawer.model.interfaces.Nameable) SectionDrawerItem(com.mikepenz.materialdrawer.model.SectionDrawerItem) BadgeStyle(com.mikepenz.materialdrawer.holder.BadgeStyle) IProfile(com.mikepenz.materialdrawer.model.interfaces.IProfile) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

ProfileDrawerItem (com.mikepenz.materialdrawer.model.ProfileDrawerItem)14 IProfile (com.mikepenz.materialdrawer.model.interfaces.IProfile)11 View (android.view.View)10 DrawerBuilder (com.mikepenz.materialdrawer.DrawerBuilder)10 PrimaryDrawerItem (com.mikepenz.materialdrawer.model.PrimaryDrawerItem)10 SecondaryDrawerItem (com.mikepenz.materialdrawer.model.SecondaryDrawerItem)10 AccountHeaderBuilder (com.mikepenz.materialdrawer.AccountHeaderBuilder)9 Toolbar (android.support.v7.widget.Toolbar)7 SectionDrawerItem (com.mikepenz.materialdrawer.model.SectionDrawerItem)7 IDrawerItem (com.mikepenz.materialdrawer.model.interfaces.IDrawerItem)7 Drawer (com.mikepenz.materialdrawer.Drawer)6 IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)5 ProfileSettingDrawerItem (com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem)5 Nameable (com.mikepenz.materialdrawer.model.interfaces.Nameable)5 BadgeStyle (com.mikepenz.materialdrawer.holder.BadgeStyle)4 DividerDrawerItem (com.mikepenz.materialdrawer.model.DividerDrawerItem)4 Intent (android.content.Intent)3 AccountHeader (com.mikepenz.materialdrawer.AccountHeader)3 SwitchDrawerItem (com.mikepenz.materialdrawer.model.SwitchDrawerItem)3 ToggleDrawerItem (com.mikepenz.materialdrawer.model.ToggleDrawerItem)3