本文整理汇总了Java中com.mikepenz.materialdrawer.accountswitcher.AccountHeader类的典型用法代码示例。如果您正苦于以下问题:Java AccountHeader类的具体用法?Java AccountHeader怎么用?Java AccountHeader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AccountHeader类属于com.mikepenz.materialdrawer.accountswitcher包,在下文中一共展示了AccountHeader类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpDrawer
import com.mikepenz.materialdrawer.accountswitcher.AccountHeader; //导入依赖的package包/类
private void setUpDrawer() {
AccountHeader accountHeader = new AccountHeaderBuilder()
.withActivity(MainActivity.this)
.withHeaderBackground(R.drawable.minx_small)
.withHeaderBackgroundScaleType(ImageView.ScaleType.FIT_CENTER)
.withHeightDp(200)
.build();
result = new DrawerBuilder()
.withHeaderDivider(true)
.withActivity(this)
.withAccountHeader(accountHeader)
.withToolbar(toolbar)
.addDrawerItems(
new PrimaryDrawerItem().withName(R.string.drawer_item_home),
new DividerDrawerItem(),
new SecondaryDrawerItem().withName(R.string.drawer_item_saved),
new SecondaryDrawerItem().withName(R.string.drawer_item_share),
new SecondaryDrawerItem().withName(R.string.drawer_item_settings),
new SecondaryDrawerItem().withName(R.string.drawer_item_about)
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(AdapterView<?> parent, View view, int position, long id, IDrawerItem drawerItem) {
// do something with the clicked item :D
Toast.makeText(MainActivity.this, "You clicked on item : " + position, Toast.LENGTH_SHORT).show();
loadFragment(position);
return false;
}
})
.build();
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
result.getActionBarDrawerToggle().setDrawerIndicatorEnabled(true);
}
示例2: onCreate
import com.mikepenz.materialdrawer.accountswitcher.AccountHeader; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setSupportActionBar(toolbar);
// show first fragment
showFragment(new NewsFragment(), false);
toolbar.setTitle(R.string.nav_home);
visibleFragmentId = ID_NEWS;
// setup account in nav drawer
Account account = loginManager.getAccount().get();
AccountHeader accountHeader = new AccountHeaderBuilder()
.withActivity(this)
.withHeaderBackground(R.drawable.drawer_background)
.addProfiles(new ProfileDrawerItem().withName(account.name).withIcon(getResources().getDrawable(R.drawable.ic_duck)))
.withSelectionListEnabledForSingleProfile(false)
.withProfileImagesClickable(false)
.withHeaderBackgroundScaleType(ImageView.ScaleType.CENTER_CROP)
.build();
// setup actual nav drawer
drawer = new DrawerBuilder()
.withActivity(this)
.withToolbar(toolbar)
.withAccountHeader(accountHeader)
.addDrawerItems(
new PrimaryDrawerItem().withName(R.string.nav_home).withIconTintingEnabled(true).withIcon(R.drawable.ic_home).withIdentifier(ID_NEWS),
new PrimaryDrawerItem().withName(R.string.nav_alarms).withIconTintingEnabled(true).withIcon(R.drawable.ic_alert).withIdentifier(ID_ALARMS),
new PrimaryDrawerItem().withName(R.string.nav_stations).withIconTintingEnabled(true).withIcon(R.drawable.ic_gauge).withIdentifier(ID_STATION_LEVELS),
new PrimaryDrawerItem().withName(R.string.nav_river_graphs).withIconTintingEnabled(true).withIcon(R.drawable.ic_chart).withIdentifier(ID_RIVER_GRAPHS)
)
.addStickyDrawerItems(
new PrimaryDrawerItem().withName(R.string.nav_settings).withIconTintingEnabled(true).withIcon(R.drawable.ic_settings).withIdentifier(ID_SETTINGS),
new PrimaryDrawerItem().withName(R.string.nav_feedback).withIconTintingEnabled(true).withIcon(R.drawable.ic_email).withIdentifier(ID_FEEDBACK)
)
.withOnDrawerItemClickListener(this)
.build();
}
示例3: init
import com.mikepenz.materialdrawer.accountswitcher.AccountHeader; //导入依赖的package包/类
@SuppressLint("ShortAlarm")
@Override
public void init(Bundle savedInstanceState) {
setupLayout(R.layout.activity_landing, "Amrita Info Desk");
toolbar.setBackgroundColor(getResources().getColor(R.color.white));
setRecentHeaderColor(getResources().getColor(R.color.white));
checkForUpdates();
AccountHeader headerResult = new AccountHeaderBuilder()
.withActivity(this)
.withHeaderBackground(R.drawable.header)
.addProfiles(
new ProfileDrawerItem().withName("Amrita Info Desk").withEmail("Version " + BuildConfig.VERSION_NAME).setSelectable(false)
)
.withSelectionListEnabledForSingleProfile(false)
.build();
headerResult.getHeaderBackgroundView().setColorFilter(Color.rgb(170, 170, 170), android.graphics.PorterDuff.Mode.MULTIPLY);
Drawer result = new DrawerBuilder()
.withActivity(this)
.withToolbar(toolbar)
.withAccountHeader(headerResult)
.addDrawerItems(
new PrimaryDrawerItem().withName("Home").withIcon(R.drawable.ic_action_home).withCheckable(false),
new PrimaryDrawerItem().withName("News").withIcon(R.drawable.ic_action_speaker_notes).withCheckable(false),
new DividerDrawerItem(),
new PrimaryDrawerItem().withName("About the app").withIcon(R.drawable.ic_action_info).withCheckable(false),
new PrimaryDrawerItem().withName("Invite").withIcon(R.drawable.ic_action_info).withCheckable(false),
new PrimaryDrawerItem().withName("Settings").withIcon(R.drawable.ic_action_settings).withCheckable(false)
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(AdapterView<?> parent, View view, int position, long id, IDrawerItem drawerItem) {
switch (position) {
case 1:
startActivity(new Intent(baseContext, NewsActivity.class));
break;
case 3:
startActivity(new Intent(baseContext, App.class));
break;
case 4:
Intent intent = new AppInviteInvitation.IntentBuilder("Invite users")
.setMessage("Spread the word to fellow Amrititans")
.setCallToActionText("Invite")
.build();
startActivityForResult(intent, 211);
break;
case 5:
startActivity(new Intent(baseContext, SettingsActivity.class));
break;
}
return false;
}
})
.withCloseOnClick(true)
.build();
setupGrid();
File aumsCookieFile = new File(getApplicationContext().getFilesDir().getParent() + "/shared_prefs/" + PersistentCookieStore.AUMS_COOKIE_PREFS + ".xml");
if (aumsCookieFile.exists()) {
aumsCookieFile.delete();
}
File gpmsCookieFile = new File(getApplicationContext().getFilesDir().getParent() + "/shared_prefs/" + PersistentCookieStore.GPMS_COOKIE_PREFS + ".xml");
if (gpmsCookieFile.exists()) {
gpmsCookieFile.delete();
}
AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
alarm.set(
AlarmManager.RTC_WAKEUP,
System.currentTimeMillis() + (1000 * 60 * 60 * 6),
PendingIntent.getService(this, 0, new Intent(this, NewsUpdateService.class), 0)
);
startService(new Intent(baseContext, NewsUpdateService.class));
}
示例4: showNavigationDrawer
import com.mikepenz.materialdrawer.accountswitcher.AccountHeader; //导入依赖的package包/类
public static Drawer showNavigationDrawer(final Context context, Toolbar toolbar, final MoticonAdapter moticonAdapter, final MoticonAdapter moticonPositiveAdapter, final MoticonAdapter moticonNegativeAdapter, final MoticonAdapter moticonFunnyAdapter, final MoticonAdapter moticonAnimalsAdapter, final MoticonAdapter moticonSpecialAdapter, final RecyclerView recyclerView) {
Activity activity = (Activity) context;
AccountHeader headerResult = new AccountHeaderBuilder()
.withActivity(activity)
.withHeaderBackground(R.drawable.header)
.build();
return new DrawerBuilder()
.withActivity(activity)
.withToolbar(toolbar)
.withAccountHeader(headerResult)
.withStatusBarColor(context.getResources().getColor(R.color.primary_dark))
.addDrawerItems(
new PrimaryDrawerItem().withName(context.getResources().getString(R.string.app_name)).withIcon(R.mipmap.ic_launcher),
new DividerDrawerItem(),
new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_positive)).withIcon(FontAwesome.Icon.faw_thumbs_up).withBadge("(/^▽^)/"),
new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_negative)).withIcon(FontAwesome.Icon.faw_thumbs_down).withBadge("(>_<)"),
new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_funny)).withIcon(FontAwesome.Icon.faw_child).withBadge("¯\\_(ツ)_/¯"),
new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_animal)).withIcon(FontAwesome.Icon.faw_paw).withBadge("∪・ω・∪"),
new PrimaryDrawerItem().withName(context.getResources().getString(R.string.action_special)).withIcon(FontAwesome.Icon.faw_star).withBadge("ʕ•̬͡•ʕ•̫͡•♥"),
new DividerDrawerItem(),
new SecondaryDrawerItem().withName(context.getResources().getString(R.string.action_about)).withCheckable(false)
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(AdapterView<?> adapterView, View view, int position, long id, IDrawerItem iDrawerItem) {
switch (position) {
case 0:
recyclerView.setAdapter(moticonAdapter);
break;
case 2:
recyclerView.setAdapter(moticonPositiveAdapter);
break;
case 3:
recyclerView.setAdapter(moticonNegativeAdapter);
break;
case 4:
recyclerView.setAdapter(moticonFunnyAdapter);
break;
case 5:
recyclerView.setAdapter(moticonAnimalsAdapter);
break;
case 6:
recyclerView.setAdapter(moticonSpecialAdapter);
break;
case 8:
context.startActivity(new Intent(context, AboutActivity.class));
break;
default:
break;
}
return false;
}
}).build();
}