本文整理汇总了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;
}
示例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();
}
示例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
}
示例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();
}
示例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();
}
示例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);
}
示例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");
}
示例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)");
}
示例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();
}
示例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;
}
});
}
示例11: AccountHeaderChanger
import com.mikepenz.materialdrawer.AccountHeader; //导入依赖的package包/类
private AccountHeaderChanger(@NonNull AccountHeader header) {
this.header = header;
}
示例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();
}
示例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;
}
});
}
示例14: header
import com.mikepenz.materialdrawer.AccountHeader; //导入依赖的package包/类
public AccountHeader header() {
return headerResult;
}