com.mikepenz.materialdrawer.model.ProfileDrawerItem Java Examples

The following examples show how to use com.mikepenz.materialdrawer.model.ProfileDrawerItem. 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 IdeaTrackerPlus with MIT License 6 votes vote down vote up
private void loadProjects() {

        mProjects = mTinyDB.getListObject(PREF_KEY, Project.class);

        if (mProjects.size() == 0) {
            DataEntry.setTableName("");
            mToolbar.setTitle(R.string.app_name);
            mFab.setVisibility(View.INVISIBLE);
            mNoProject = true;
        } else { //Start counter where we stopped
            int lastId = ((Project) mProjects.get(mProjects.size() - 1)).getId();
            Project.setCounter(lastId + 1);
        }

        mProfiles = new ArrayList<>();
        for (Object p : mProjects) {
            Project project = (Project) p;
            Drawable drawable = ContextCompat.getDrawable(this, R.drawable.disk);
            drawable.setColorFilter(project.getPrimaryColor(), PorterDuff.Mode.SRC_ATOP);
            mProfiles.add(new ProfileDrawerItem().withName(project.getName())
                    .withIcon(drawable)
                    .withOnDrawerItemClickListener(this));
        }
    }
 
Example #2
Source File: MainViewModel.java    From hacker-news-android with Apache License 2.0 6 votes vote down vote up
IProfile[] getLoggedInProfileItem() {
    if (mLoggedInProfiles == null) {
        mLoggedInProfiles = new IProfile[2];
        User currentUser = Select.from(User.class).first();
        ProfileDrawerItem profileDrawerItem = new ProfileDrawerItem().withIdentifier(LOGGED_IN_PROFILE_ITEM)
                                                                     .withIcon(TextDrawable.builder()
                                                                                           .buildRound(String.valueOf(currentUser.getUserName().charAt(0)),
                                                                                                       mResources.getColor(R.color.colorPrimaryDark)))
                                                                     .withName(currentUser.getUserName());
        ProfileSettingDrawerItem logoutDrawerItem = new ProfileSettingDrawerItem().withIdentifier(LOG_OUT_PROFILE_ITEM)
                                                                                  .withName("Logout")
                                                                                  .withDescription("Logout of current account")
                                                                                  .withIcon(mResources.getDrawable(R.drawable.ic_close));

        mLoggedInProfiles[0] = profileDrawerItem;
        mLoggedInProfiles[1] = logoutDrawerItem;
    }

    return mLoggedInProfiles;
}
 
Example #3
Source File: HomeActivity.java    From wmn-safety with MIT License 5 votes vote down vote up
public void updateProfile() {
    IProfile profile = new ProfileDrawerItem().withName(mFullName)
            .withTextColor(getResources().getColor(android.R.color.black))
            .withEmail(mEmail).withIcon(R.mipmap.ic_launcher)
            .withIdentifier(100);
    headerResult.updateProfile(profile);
}
 
Example #4
Source File: LeftDrawerManager.java    From timecat with Apache License 2.0 5 votes vote down vote up
private IProfile createProfile(DBUser u) {
    return new ProfileDrawerItem()
            .withIdentifier(u.id().intValue())
            .withName(u.name())
            .withEmail(u.getEmail())
            .withIcon(AvatarManager.res(u.avatar()));
}
 
Example #5
Source File: DrawerManager.java    From FragmentNavigationPatternDemo with Apache License 2.0 5 votes vote down vote up
private AccountHeader getAccountHeader(Activity activity) {
    //@formatter:off
    return new AccountHeaderBuilder()
                    .withActivity(activity)
                    .withHeaderBackground(R.color.primary_dark)
                    .addProfiles(
                        new ProfileDrawerItem()
                                        .withName(activity.getString(R.string.app_name))
                    )
                    .build();
    //@formatter:on
}
 
Example #6
Source File: MainActivity.java    From Droid2JoyStick with Apache License 2.0 5 votes vote down vote up
private void setupNavigationDrawer() {
    ProfileDrawerItem section = new ProfileDrawerItem()
            .withSetSelected(false)
            .withSetSelected(false)
            .withEnabled(false);
    PrimaryDrawerItem joyType0DrawerItem = new PrimaryDrawerItem().withName("Basic Gamepad").withTag(KEY_BASIC_GAMEPAD_1).withLevel(2);
    PrimaryDrawerItem joyType1DrawerItem = new PrimaryDrawerItem().withName("Assault Horizon").withTag(KEY_ASSAULT_HORIZON).withLevel(2);
    PrimaryDrawerItem joyType2DrawerItem = new PrimaryDrawerItem().withName("Awesomenauts").withTag(KEY_AWESOMENAUTS).withLevel(2);
    PrimaryDrawerItem joyType3DrawerItem = new PrimaryDrawerItem().withName("BombSquad").withTag(KEY_BOMBSQUAD).withLevel(2);
    PrimaryDrawerItem joyType4DrawerItem = new PrimaryDrawerItem().withName("Final Fantasy XIII").withTag(KEY_FINAL_FANTASY_XIII).withLevel(2);
    SectionDrawerItem sectionDrawerItem = new SectionDrawerItem().withName("Joystick Type").withTextColorRes(R.color.colorAccent);
    PrimaryDrawerItem deviceDrawerItem = new PrimaryDrawerItem().withName("Device Connection").withTag(KEY_DEVICE_CONNECTION).withIcon(GoogleMaterial.Icon.gmd_devices);
    PrimaryDrawerItem settingsDrawerItem = new PrimaryDrawerItem().withName("Settings").withTag("settings").withIcon(GoogleMaterial.Icon.gmd_settings);

    ndMenu = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(tbMain)
            .withCloseOnClick(true)
            .withFireOnInitialOnClick(true)
            .withSelectedItemByPosition(6)
            .withDelayDrawerClickEvent(300)
            .withDisplayBelowStatusBar(true)
            .withTranslucentStatusBar(false)
            .withOnDrawerItemClickListener(this)
            .addDrawerItems(section, deviceDrawerItem, settingsDrawerItem, sectionDrawerItem, joyType0DrawerItem, joyType1DrawerItem, joyType2DrawerItem, joyType3DrawerItem, joyType4DrawerItem)
            .build();
}
 
Example #7
Source File: MiniDrawer.java    From MaterialDrawer-Xamarin with Apache License 2.0 5 votes vote down vote up
/**
 * generates a MiniDrawerItem from a IDrawerItem
 *
 * @param drawerItem
 * @return
 */
public IDrawerItem generateMiniDrawerItem(IDrawerItem drawerItem) {
    if (drawerItem instanceof PrimaryDrawerItem) {
        return new MiniDrawerItem((PrimaryDrawerItem) drawerItem).withEnableSelectedBackground(mEnableSelectedMiniDrawerItemBackground);
    } else if (drawerItem instanceof SecondaryDrawerItem && mIncludeSecondaryDrawerItems) {
        return new MiniDrawerItem((SecondaryDrawerItem) drawerItem).withEnableSelectedBackground(mEnableSelectedMiniDrawerItemBackground);
    } else if (drawerItem instanceof ProfileDrawerItem) {
        MiniProfileDrawerItem mpdi = new MiniProfileDrawerItem((ProfileDrawerItem) drawerItem);
        mpdi.withEnabled(mEnableProfileClick);
        return mpdi;
    }
    return null;
}
 
Example #8
Source File: MainFrameActivity.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
public void updateAccountHeader() {
    if (mAccountHeader != null) {
        String username = OkHttpHelper.getInstance().isLoggedIn() ? HiSettingsHelper.getInstance().getUsername() : "<未登录>";
        String avatarUrl = OkHttpHelper.getInstance().isLoggedIn() ? HiUtils.getAvatarUrlByUid(HiSettingsHelper.getInstance().getUid()) : "";
        mAccountHeader.removeProfile(0);
        mAccountHeader.addProfile(new ProfileDrawerItem()
                .withEmail(username)
                .withIcon(avatarUrl), 0);
    }
}
 
Example #9
Source File: MainActivity.java    From IdeaTrackerPlus with MIT License 4 votes vote down vote up
private void createProjectFromDialog() {

        String projectName = mProjectField.getText().toString();

        if (isProjectNameAvailable(projectName) && !projectName.equals("")) {

            mDbHelper.newTable(projectName);

            //create the profile with its colored icon
            Drawable disk = ContextCompat.getDrawable(getApplicationContext(), R.drawable.disk);
            disk.setColorFilter(defaultPrimaryColor, PorterDuff.Mode.SRC_ATOP);
            IProfile newProfile = new ProfileDrawerItem().withName(projectName).withIcon(disk).withOnDrawerItemClickListener(this);
            mProfiles.add(newProfile);

            saveProject(new Project(projectName, defaultPrimaryColor, defaultSecondaryColor, defaultTextColor));

            //open the profile drawer and select the new profile


            header.removeProfile(mAddProject);
            header.addProfile(mAddProject, mProfiles.size());
            header.setActiveProfile(newProfile);
            mSelectedProfileIndex = mProfiles.size() - 2;
            switchToProjectColors();

            mToolbar.setTitle(projectName);
            displayIdeasCount();

            if (mNoProject) {
                mFab.setVisibility(View.VISIBLE);
                mNoProject = false;

                mViewPager.setAdapter(null);
                mViewPager.setAdapter(mSectionsPagerAdapter);
            }

            //If first project ever
            if (mTinyDB.getBoolean(getString(R.string.first_project_pref))) {
                leftDrawer.openDrawer();
                header.toggleSelectionList(getApplicationContext());
                firstProjectGuide();
            }
            setRightDrawerSate();
            refreshStar();

            mProjectDialog.dismiss();


        } else { //Error - project name is taken or empty, show the error
            mProjectError.setVisibility(View.VISIBLE);
        }

    }
 
Example #10
Source File: DrawerActivity.java    From outlay with Apache License 2.0 4 votes vote down vote up
public void setupDrawer(User currentUser) {
    String email = TextUtils.isEmpty(currentUser.getEmail()) ? "Guest" : currentUser.getEmail();

    AccountHeader headerResult = new AccountHeaderBuilder()
            .withActivity(this)
            .withTextColor(getOutlayTheme().secondaryTextColor)
            .withAlternativeProfileHeaderSwitching(false)
            .withSelectionListEnabledForSingleProfile(false)
            .withProfileImagesClickable(false)
            .withCloseDrawerOnProfileListClick(false)
            .addProfiles(
                    new ProfileDrawerItem()
                            .withEmail(email)
            )
            .build();

    List<IDrawerItem> items = new ArrayList<>();
    if (currentUser.isAnonymous()) {
        items.add(new PrimaryDrawerItem().withName(app.outlay.R.string.menu_item_create_user).withIcon(MaterialDesignIconic.Icon.gmi_account_add).withIdentifier(ITEM_CREATE_USER));
    }

    items.add(new PrimaryDrawerItem().withName(app.outlay.R.string.menu_item_analysis).withIcon(MaterialDesignIconic.Icon.gmi_trending_up).withIdentifier(ITEM_ANALYSIS));
    items.add(new PrimaryDrawerItem().withName(app.outlay.R.string.menu_item_categories).withIcon(MaterialDesignIconic.Icon.gmi_apps).withIdentifier(ITEM_CATEGORIES));
    items.add(new PrimaryDrawerItem().withName(app.outlay.R.string.menu_item_feedback).withIcon(MaterialDesignIconic.Icon.gmi_email).withIdentifier(ITEM_FEEDBACK));
    items.add(new PrimaryDrawerItem().withName(R.string.menu_item_settings).withIcon(MaterialDesignIconic.Icon.gmi_settings).withIdentifier(ITEM_SETTINGS));
    items.add(new PrimaryDrawerItem().withName(app.outlay.R.string.menu_item_signout).withIcon(MaterialDesignIconic.Icon.gmi_sign_in).withIdentifier(ITEM_SING_OUT));


    mainDrawer = new DrawerBuilder()
            .withFullscreen(true)
            .withActivity(this)
            .withAccountHeader(headerResult)
            .withSelectedItem(-1)
            .addDrawerItems(items.toArray(new IDrawerItem[items.size()]))
            .withOnDrawerItemClickListener((view, i, iDrawerItem) -> {
                if (iDrawerItem != null) {
                    int id = (int) iDrawerItem.getIdentifier();
                    switch (id) {
                        case ITEM_CATEGORIES:
                            analytics().trackViewCategoriesList();
                            SingleFragmentActivity.start(this, CategoriesFragment.class);
                            break;
                        case ITEM_ANALYSIS:
                            analytics().trackAnalysisView();
                            SingleFragmentActivity.start(this, AnalysisFragment.class);
                            break;
                        case ITEM_SETTINGS:
                            SingleFragmentActivity.start(this, SettingsFragment.class);
                            break;
                        case ITEM_FEEDBACK:
                            analytics().trackFeedbackClick();
                            Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
                                    "mailto", Constants.CONTACT_EMAIL, null));
                            emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{Constants.CONTACT_EMAIL});
                            emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Outlay Feedback");
                            try {
                                startActivity(Intent.createChooser(emailIntent, getString(app.outlay.R.string.label_send_email)));
                            } catch (android.content.ActivityNotFoundException ex) {
                                Alert.error(getRootView(), getString(app.outlay.R.string.error_no_email_clients));
                            }
                            break;
                        case ITEM_ABOUT:
                            SingleFragmentActivity.start(this, AboutFragment.class);
                            break;
                        case ITEM_SING_OUT:
                            analytics().trackSingOut();
                            signOut();
                            break;
                        case ITEM_CREATE_USER:
                            createUser();
                            break;
                    }

                    mainDrawer.setSelection(-1);
                    mainDrawer.closeDrawer();
                }
                return false;
            })
            .build();
}
 
Example #11
Source File: MainActivity.java    From ETSMobile-Android2 with Apache License 2.0 4 votes vote down vote up
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);

}
 
Example #12
Source File: Navbar.java    From SteamGifts with MIT License 4 votes vote down vote up
public ProfileDrawerItem withNotifications(String notifications) {
    this.notifications = new StringHolder(notifications);
    return this;
}