本文整理匯總了Java中com.mikepenz.materialdrawer.model.ProfileDrawerItem類的典型用法代碼示例。如果您正苦於以下問題:Java ProfileDrawerItem類的具體用法?Java ProfileDrawerItem怎麽用?Java ProfileDrawerItem使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ProfileDrawerItem類屬於com.mikepenz.materialdrawer.model包,在下文中一共展示了ProfileDrawerItem類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadProjects
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; //導入依賴的package包/類
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));
}
}
示例2: addProfile
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; //導入依賴的package包/類
/**
* Add new profile
* @param user
*/
private void addProfile(User user) {
this.accountHeader.addProfiles(
new ProfileDrawerItem().withName( user.getName() )
.withEmail( user.getKey() )
.withIcon( user.createBitMap( this.main ) )
.withIdentifier( user.getIdentifier() )
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
onProfileChange( view, position, drawerItem );
return false;
}
})
);
}
示例3: getAccountHeader
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; //導入依賴的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;
}
示例4: getAccountHeaderBuilder
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; //導入依賴的package包/類
/**
* @return desired header
* Sets up account header
* will not be added if null
*/
@Nullable
@Override
protected AccountHeaderBuilder getAccountHeaderBuilder() {
return new AccountHeaderBuilder().withActivity(this)
.withHeaderBackground(R.color.colorPrimary)
.withSelectionFirstLine(s(R.string.app_name))
.withSelectionSecondLine(BuildConfig.VERSION_NAME)
.withProfileImagesClickable(false)
.withResetDrawerOnProfileListClick(false)
.addProfiles(
new ProfileDrawerItem().withIcon(ContextCompat.getDrawable(this, R.mipmap.ic_launcher))
)
.withSelectionListEnabled(false)
.withSelectionListEnabledForSingleProfile(false);
}
示例5: setupAllAccountHeaders
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; //導入依賴的package包/類
private void setupAllAccountHeaders() {
allAccountHeaders = new ArrayList<>();
List<User> users = User.getAllUsers();
for (int i = 0; i < users.size(); i++) {
ProfileDrawerItem profileDrawerItem = new ProfileDrawerItem().withName(users.get(i).getUsername());
/**
* A fun image for each profile drawer
*/
if (i % 3 == 0)
profileDrawerItem.withIcon(getResources().getDrawable(R.drawable.user_white));
if (i % 3 == 1)
profileDrawerItem.withIcon(getResources().getDrawable(R.drawable.user_blue));
if (i % 3 == 2)
profileDrawerItem.withIcon(getResources().getDrawable(R.drawable.user_grey));
allAccountHeaders.add(profileDrawerItem);
}
final String createAccount = getString(R.string.drawer_new_account);
allAccountHeaders.add(new ProfileDrawerItem().withName(createAccount).withIcon(getResources().getDrawable(R.drawable.plus)));
}
示例6: getLoggedInProfileItem
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; //導入依賴的package包/類
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;
}
示例7: genProfile
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; //導入依賴的package包/類
private IProfile genProfile(Patient p) {
final int schedules = DB.schedules().findAll(p).size();
String fakeMail;
if (schedules > 0) {
fakeMail = home.getString(R.string.active_schedules_number, schedules);
} else {
fakeMail = home.getString(R.string.active_schedules_none);
}
return new ProfileDrawerItem()
.withIdentifier(p.getId().intValue())
.withName(p.getName())
.withEmail(fakeMail)
.withIcon(AvatarMgr.res(p.getAvatar()))
.withNameShown(true);
}
示例8: onConnected
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; //導入依賴的package包/類
@Override
public void onConnected(@Nullable Bundle bundle) {
loadingView.setVisibility(View.VISIBLE);
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(this, android.Manifest.permission.GET_ACCOUNTS)) {
Toast.makeText(getApplicationContext(), getString(R.string.should_accept_permissions), Toast.LENGTH_LONG).show();
return;
// ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.GET_ACCOUNTS}, PERMISSION_REQUEST_GET_ACCOUNTS);
} else {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.GET_ACCOUNTS}, PERMISSION_REQUEST_GET_ACCOUNTS);
}
return;
}
new Thread(new Runnable() {
@Override
public void run() {
DataManager.setGoogleAccountLink(true);
Drive.DriveApi.getAppFolder(mGoogleApiClient).listChildren(mGoogleApiClient).setResultCallback(connectDriveCallback);
}
}).start();
Person person = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
headerResult.removeProfile(0);
headerResult.addProfiles(new ProfileDrawerItem().withName(person.getDisplayName()).withEmail(Plus.AccountApi.getAccountName(mGoogleApiClient)).withIcon(person.getImage().getUrl()));
if (person.getCover() != null && person.getCover().getCoverPhoto() != null && person.getCover().getCoverPhoto().getUrl() != null)
headerResult.setHeaderBackground(new ImageHolder(person.getCover().getCoverPhoto().getUrl()));
drawer.removeItems(4, 11);
}
示例9: onFetchUserInfoSuccess
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; //導入依賴的package包/類
private void onFetchUserInfoSuccess(Account me, String domain) {
// Add the header image and avatar from the account, into the navigation drawer header.
ImageView background = headerResult.getHeaderBackgroundView();
background.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background_dark));
Picasso.with(MainActivity.this)
.load(me.header)
.placeholder(R.drawable.account_header_default)
.into(background);
headerResult.clear();
headerResult.addProfiles(
new ProfileDrawerItem()
.withName(me.getDisplayName())
.withEmail(String.format("%[email protected]%s", me.username, domain))
.withIcon(me.avatar)
);
// Show follow requests in the menu, if this is a locked account.
if (me.locked) {
PrimaryDrawerItem followRequestsItem = new PrimaryDrawerItem()
.withIdentifier(DRAWER_ITEM_FOLLOW_REQUESTS)
.withName(R.string.action_view_follow_requests)
.withSelectable(false)
.withIcon(GoogleMaterial.Icon.gmd_person_add);
drawer.addItemAtPosition(followRequestsItem, 3);
}
// Update the current login information.
loggedInAccountId = me.id;
loggedInAccountUsername = me.username;
getPrivatePreferences().edit()
.putString("loggedInAccountId", loggedInAccountId)
.putString("loggedInAccountUsername", loggedInAccountUsername)
.putBoolean("loggedInAccountLocked", me.locked)
.apply();
}
示例10: getAccountHeader
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; //導入依賴的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
}
示例11: setupNavigationDrawer
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; //導入依賴的package包/類
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();
}
示例12: setupDrawer
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; //導入依賴的package包/類
@Override
public void setupDrawer(Me me, Optional<LuckyNumber> luckyNumber) {
TextDrawable icon = getIcon(me);
ProfileDrawerItem profile = getProfileDrawerItem(me, icon);
DrawerBuilder drawerBuilder = new DrawerBuilder()
.withActivity(this)
.addStickyDrawerItems(settingsPresenter.convertToDrawerItem(this::displayFragment))
.withDelayOnDrawerClose(50)
.withOnDrawerNavigationListener(clickedView -> {
onBackPressed();
return true;
})
.withActionBarDrawerToggle(true)
.withActionBarDrawerToggleAnimated(true)
.withToolbar(toolbar)
.withAccountHeader(getDrawerHeader(profile));
StreamSupport.stream(fragmentPresenters)
.sorted(Ordering.natural().onResultOf(MainFragmentPresenter::getOrder))
.map(presenter -> presenter.convertToDrawerItem(p -> displayFragment(presenter)))
.forEach(drawerBuilder::addDrawerItems);
if (luckyNumber.isPresent()) {
drawerBuilder.addDrawerItems(
new DividerDrawerItem(),
getLuckyNumberDrawerItem(luckyNumber.get()));
}
this.drawer = drawerBuilder.build();
}
示例13: getDrawerHeader
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; //導入依賴的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();
}
示例14: initAccount
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; //導入依賴的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();
}
示例15: updateStationsList
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; //導入依賴的package包/類
public void updateStationsList() {
// добавляем станции в navigation drawer
drawerHeader.clear();
for (int i = 0; i < Config.values.stations.size(); i++) {
Station station = Config.values.stations.get(i);
String nodename = station.nodename;
ProfileDrawerItem dritem = new ProfileDrawerItem()
.withEmail(station.address)
.withName(nodename)
.withNameShown(true)
.withIcon(getStationIcon(nodename))
.withIdentifier(i);
drawerHeader.addProfile(dritem, i);
}
drawerHeader.addProfiles(
new ProfileSettingDrawerItem().withName(getString(R.string.add_node)).withIdentifier(ADD_NODE).withIcon(GoogleMaterial.Icon.gmd_add),
new ProfileSettingDrawerItem().withName(getString(R.string.manage_node)).withIdentifier(MANAGE_NODE).withIcon(GoogleMaterial.Icon.gmd_settings)
);
if (Config.currentSelectedStation > (Config.values.stations.size() - 1)) {
Config.currentSelectedStation = 0;
Config.saveCurrentStationPosition();
}
currentStation = Config.values.stations.get(Config.currentSelectedStation);
drawerHeader.setActiveProfile(Config.currentSelectedStation);
}