當前位置: 首頁>>代碼示例>>Java>>正文


Java AccountHeader類代碼示例

本文整理匯總了Java中com.mikepenz.materialdrawer.AccountHeader的典型用法代碼示例。如果您正苦於以下問題:Java AccountHeader類的具體用法?Java AccountHeader怎麽用?Java AccountHeader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AccountHeader類屬於com.mikepenz.materialdrawer包,在下文中一共展示了AccountHeader類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAccountHeader

import com.mikepenz.materialdrawer.AccountHeader; //導入依賴的package包/類
private AccountHeader getAccountHeader(){
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String name = prefs.getString(SSConstants.SS_USER_NAME_INDEX, getString(R.string.ss_menu_anonymous_name));
    String email = prefs.getString(SSConstants.SS_USER_EMAIL_INDEX, getString(R.string.ss_menu_anonymous_email));
    String photo = prefs.getString(SSConstants.SS_USER_PHOTO_INDEX, MENU_ANONYMOUS_PHOTO);

    ssAccountHeader = new AccountHeaderBuilder()
            .withActivity(this)
            .withTranslucentStatusBar(true)
            .withHeaderBackground(R.color.colorPrimary)
            .addProfiles(
                    new ProfileDrawerItem().withName(name)
                            .withEmail(email)
                            .withIcon(photo)
                            .withSelectedTextColor(Color.parseColor(SSColorTheme.getInstance().getColorPrimary()))
                            .withIdentifier(MENU_HEADER_PROFILE_ID),
                    new ProfileSettingDrawerItem().withName(getString(R.string.ss_menu_sign_out)).withIdentifier(MENU_HEADER_LOGOUT_ID)
            )
            .withOnAccountHeaderListener(this)
            .build();

    return ssAccountHeader;
}
 
開發者ID:Adventech,項目名稱:sabbath-school-android,代碼行數:24,代碼來源:SSBaseActivity.java

示例2: buildHeader

import com.mikepenz.materialdrawer.AccountHeader; //導入依賴的package包/類
private void buildHeader(Bundle savedInstanceState) {
    // Create the AccountHeader
    headerResult = new AccountHeaderBuilder()
            .withActivity(this)
            .withTranslucentStatusBar(true)
            .withCompactStyle(false)
            .withHeaderBackground(R.drawable.header)
            .withCurrentProfileHiddenInList(true)
            .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
                @Override
                public boolean onProfileChanged(View view, IProfile profile, boolean current) {
                    //sample usage of the onProfileChanged listener
                    //if the clicked item has the identifier 1 add a new profile ;)
                    if (profile instanceof IDrawerItem && profile.getIdentifier() == PROFILE_ADD_ACCOUNT) {
                        showLoginActivity();
                    } else if (profile instanceof IDrawerItem && profile.getIdentifier() == PROFILE_LOGOUT) {
                        IProfile activeProfile = headerResult.getActiveProfile();
                        if (activeProfile != null) {
                            if (activeProfile.getName() != null && activeProfile.getEmail() != null) {
                                ParseUser.logOut();
                            }
                            if (miniResult != null)
                                miniResult.createItems();
                        }
                    } else if (profile instanceof IDrawerItem && profile.getIdentifier() == PROFILE_VIEW) {
                        showProfileView();
                    } else if (!current) {
                        switchUser();
                    } else {
                        Croperino.prepareGallery(MainActivity.this);
                    }

                    //false if you have not consumed the event and it should close the drawer
                    return false;
                }
            })
            .withSavedInstance(savedInstanceState)
            .build();
}
 
開發者ID:SalmanTKhan,項目名稱:MyAnimeViewer,代碼行數:40,代碼來源:MainActivity.java

示例3: getAccountHeader

import com.mikepenz.materialdrawer.AccountHeader; //導入依賴的package包/類
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
}
 
開發者ID:beczesz,項目名稱:FragmentNavigationPatternDemo,代碼行數:13,代碼來源:DrawerManager.java

示例4: getDrawerHeader

import com.mikepenz.materialdrawer.AccountHeader; //導入依賴的package包/類
private AccountHeader getDrawerHeader(ProfileDrawerItem profile) {
    return new AccountHeaderBuilder()
            .withActivity(this)
            .withSelectionListEnabledForSingleProfile(true)
            .withHeaderBackground(R.drawable.background_nav)
            .withHeaderBackgroundScaleType(ImageView.ScaleType.CENTER_CROP)
            .addProfiles(profile,
                    //TODO: Add  support for multi profiles
                    new ProfileSettingDrawerItem()
                            .withName("Wyloguj się")
                            .withIcon(R.drawable.logout)
                            .withOnDrawerItemClickListener(this::logout))
            .build();
}
 
開發者ID:shymmq,項目名稱:librus-client,代碼行數:15,代碼來源:MainActivity.java

示例5: initAccount

import com.mikepenz.materialdrawer.AccountHeader; //導入依賴的package包/類
@UiThread void initAccount() {
  headerResult = new AccountHeaderBuilder().withActivity(act)
      .withHeaderBackground(R.color.colorPrimary)
      .addProfiles(new ProfileDrawerItem().withName("Usuário"))
      .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
        @Override
        public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {
          return false;
        }
      })
      .build();
}
 
開發者ID:Pierry,項目名稱:cartolapp,代碼行數:13,代碼來源:ToolbarBase.java

示例6: setNavigationDrawer

import com.mikepenz.materialdrawer.AccountHeader; //導入依賴的package包/類
/**
 * Method to set Navigation Drawer
 * Uses library https://github.com/mikepenz/MaterialDrawer
 */
private void setNavigationDrawer() {

    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            ProfileDrawerItem profileDrawerItem;

            profileDrawerItem = new ProfileDrawerItem()
                    .withName("John Davis")
                    .withEmail("[email protected]")
                    .withIcon(getResources()
                            .getDrawable(R.drawable.ic_person_pink_600_48dp));
            // Create the AccountHeader
            AccountHeader headerResult = new AccountHeaderBuilder()
                    .withActivity(LibraryActivity.this)
                    .addProfiles(profileDrawerItem)
                    .withHeaderBackground(R.drawable.header)
                    .withAlternativeProfileHeaderSwitching(false)
                    .withCurrentProfileHiddenInList(true)
                    .withResetDrawerOnProfileListClick(false)
                    .withSelectionFirstLineShown(false)
                    .withSelectionListEnabledForSingleProfile(true)
                    .build();

            navigationDrawer = new DrawerBuilder()
                    .withActivity(LibraryActivity.this)
                    .withAccountHeader(headerResult)
                    .build();
        }
    }, 0);
}
 
開發者ID:iem-devs,項目名稱:apna-library,代碼行數:36,代碼來源:LibraryActivity.java

示例7: addProfileForUser

import com.mikepenz.materialdrawer.AccountHeader; //導入依賴的package包/類
public void addProfileForUser(Activity activity, AccountHeader accountHeader, User user) {
    File saveDir = new File(activity.getFilesDir(), "img");
    profileMap.put(user.username, new ProfileDrawerItem().withName(user.nickname));
    try {
        profileMap.get(user.username).withIcon(BitmapFactory.decodeStream(new FileInputStream(new File(saveDir, user.username + ".png"))));
    } catch (FileNotFoundException e) {
    }
    accountHeader.addProfile(profileMap.get(user.username), accountHeader.getProfiles().size() - 2);
    checkProfiles("addProfileForUser");
}
 
開發者ID:iLexiconn,項目名稱:Hipster,代碼行數:11,代碼來源:Config.java

示例8: removeProfile

import com.mikepenz.materialdrawer.AccountHeader; //導入依賴的package包/類
public void removeProfile(AccountHeader accountHeader, User user) {
    checkProfiles("removeProfile (1)");
    IProfile<?> profile = getProfileForUser(user);
    profileMap.remove(user.username);
    accountHeader.removeProfileByIdentifier(profile.getIdentifier());
    checkProfiles("removeProfile (2)");
}
 
開發者ID:iLexiconn,項目名稱:Hipster,代碼行數:8,代碼來源:Config.java

示例9: NavigationDrawer

import com.mikepenz.materialdrawer.AccountHeader; //導入依賴的package包/類
private NavigationDrawer(final MainActivity activity) {


//        activity.getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        // Create the AccountHeader
        AccountHeader headerResult = new AccountHeaderBuilder()
                .withActivity(activity)
                .withHeaderBackground(R.drawable.header)
                .withSelectionListEnabledForSingleProfile(false)
                .withOnlyMainProfileImageVisible(true)
                .addProfiles(
                        new ProfileDrawerItem().withName(UserInfo.getDisplayName()).withEmail(UserInfo.getUserEmail()).withIcon(UserInfo.getProfilePictureURL())
                )

                .build();
        PrimaryDrawerItem item1 = new PrimaryDrawerItem().withIdentifier(1).withName(activity.getString(R.string.seeCollection)).withIcon(FontAwesome.Icon.faw_book);
        SecondaryDrawerItem item2 = new SecondaryDrawerItem().withIdentifier(2).withName(activity.getString(R.string.addComic)).withIcon(FontAwesome.Icon.faw_plus_circle);
        SecondaryDrawerItem ajustes = new SecondaryDrawerItem().withIdentifier(3).withName(activity.getString(R.string.settings)).withIcon(FontAwesome.Icon.faw_cog);
        SecondaryDrawerItem signout = new SecondaryDrawerItem().withIdentifier(4).withName(activity.getString(R.string.logout_button)).withIcon(FontAwesome.Icon.faw_sign_out);



        //create the drawer and remember the `Drawer` result object
        drawerBuilder = new DrawerBuilder()
                .withActivity(activity)

                .withAccountHeader(headerResult)
                .addDrawerItems(item1,item2, new DividerDrawerItem(),ajustes,signout)
                .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                    @Override
                    public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                        BaseFragment fragment;

                        switch (position) {
                            case 1:
                                fragment = CollectionFragment.newInstance();

                                activity.openFragment(fragment,"");
                                break;

                            case 2:
                                fragment = AddComicFragment.newInstance();
                                activity.openFragment(fragment,"add");
                                break;

                            case 4:
                                fragment = SettingsFragment.newInstance();
                                activity.openFragment(fragment,"settings");
                                break;


                            case 5:
                                //logout code
                                AlertDialog.Builder logOutBuilder = Functions.getModalLogOut(activity);
                                logOutBuilder.setPositiveButton((activity.getString(R.string.ok)), new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        FirebaseModule.getInstance().getmAuth().signOut();
                                        Intent i = new Intent(activity.getApplicationContext(), LoginActivity.class);
                                        activity.startActivity(i);
                                    }
                                });
                                logOutBuilder.show();
                                break;

                        }
                        return true;
                    }
                }).build();

    }
 
開發者ID:jcolladosp,項目名稱:PimPam,代碼行數:72,代碼來源:NavigationDrawer.java

示例10: getDrawerBuilder

import com.mikepenz.materialdrawer.AccountHeader; //導入依賴的package包/類
public static DrawerBuilder getDrawerBuilder(final Context context, final Activity activity, Toolbar toolbar){
    // Create the AccountHeader
    AccountHeader headerResult = new AccountHeaderBuilder()
            .withActivity(activity)
            .withHeaderBackground(R.drawable.header)
            .withSelectionListEnabledForSingleProfile(false)
            .withOnlyMainProfileImageVisible(false)

            .build();


    PrimaryDrawerItem item1 = new PrimaryDrawerItem().withIdentifier(1).withName(activity.getApplicationContext().getString(R.string.title_activity_clock));
    PrimaryDrawerItem item2 = new PrimaryDrawerItem().withIdentifier(2).withName(activity.getString(R.string.add_medicine));
    PrimaryDrawerItem item3 = new PrimaryDrawerItem().withIdentifier(3).withName(activity.getString(R.string.medicinBox_Title));
    return  drawerBuilder =  new DrawerBuilder()
            .withActivity(activity)
            .withToolbar(toolbar)
            .withAccountHeader(headerResult)
            .addDrawerItems(
                    item1,
                    item2,
                    item3,
                    new DividerDrawerItem()
            )
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    switch (position) {
                        case 1:
                            context.startActivity(new Intent(context,ClockActivity.class));
                            activity.finish();

                            break;
                        case 2:
                            context.startActivity(new Intent(context,AddPillGeneralActivity.class));
                            activity.finish();


                            break;
                        case 3:
                            context.startActivity(new Intent(context, MedicineBoxActivity.class));
                            activity.finish();

                            break;
                    }



                    return true;
                }
            });
}
 
開發者ID:jcolladosp,項目名稱:ePills,代碼行數:53,代碼來源:NavigationDrawer.java

示例11: AccountHeaderChanger

import com.mikepenz.materialdrawer.AccountHeader; //導入依賴的package包/類
private AccountHeaderChanger(@NonNull AccountHeader header) {
    this.header = header;
}
 
開發者ID:AllanWang,項目名稱:Capsule,代碼行數:4,代碼來源:CapsuleActivityFrame.java

示例12: setupDrawer

import com.mikepenz.materialdrawer.AccountHeader; //導入依賴的package包/類
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();
}
 
開發者ID:bmelnychuk,項目名稱:outlay,代碼行數:81,代碼來源:DrawerActivity.java

示例13: renderDrawerOptions

import com.mikepenz.materialdrawer.AccountHeader; //導入依賴的package包/類
/**
 * Methods from the {@link HomeView} interface
 */
@Override
public void renderDrawerOptions() {

    IProfile profile = new ProfileDrawerItem()
            .withName(userModel.getName())
            .withEmail(userModel.getEmail())
            .withIcon(Uri.parse(userModel.getProfilePictureUrl()));

    AccountHeader accountHeader = new AccountHeaderBuilder()
            .withActivity(this)
            .withHeaderBackground(R.drawable.header)
            .addProfiles(profile)
            .build();

    drawer = new DrawerBuilder()
            .withActivity(this)
            .withActionBarDrawerToggle(true)
            .withAccountHeader(accountHeader)
            .withToolbar(toolbar)
            .addDrawerItems(
                    new PrimaryDrawerItem()
                            .withName(getString(R.string.app_nav_drawer_1))
                            .withIdentifier(ActivityMain.DRAWER_IDENTIFIER_HOME)
                            .withIcon(GoogleMaterial.Icon.gmd_home),

                    new PrimaryDrawerItem()
                            .withName(getString(R.string.app_nav_drawer_2))
                            .withIdentifier(ActivityMain.DRAWER_IDENTIFIER_MY_POSTS)
                            .withIcon(GoogleMaterial.Icon.gmd_content_paste))
            .withSelectedItem(DRAWER_IDENTIFIER_HOME)
            .build();

    drawer.setOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
        @Override
        public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
            onDrawerItemSelected(drawerItem.getIdentifier());
            return false;
        }
    });
}
 
開發者ID:lalongooo,項目名稱:permutas-sep-android,代碼行數:44,代碼來源:ActivityMain.java

示例14: header

import com.mikepenz.materialdrawer.AccountHeader; //導入依賴的package包/類
public AccountHeader header() {
    return headerResult;
}
 
開發者ID:citiususc,項目名稱:calendula,代碼行數:4,代碼來源:LeftDrawerMgr.java


注:本文中的com.mikepenz.materialdrawer.AccountHeader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。