@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 && ((IDrawerItem) profile).getIdentifier() == PROFILE_SETTING) { IProfile newProfile = new ProfileDrawerItem().withNameShown(true).withName("Batman").withEmail("batman@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile5)); if (headerResult.getProfiles() != null) { //we know that there are 2 setting elements. set the new profile above them ;) headerResult.addProfile(newProfile, headerResult.getProfiles().size() - 2); } else { headerResult.addProfiles(newProfile); } } //false if you have not consumed the event and it should close the drawer return false; } })
profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("mikepenz@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile)); profile2 = new ProfileDrawerItem().withName("Max Muster").withEmail("max.mustermann@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile2)).withIdentifier(2); profile3 = new ProfileDrawerItem().withName("Felix House").withEmail("felix.house@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile3)); profile4 = new ProfileDrawerItem().withName("Mr. X").withEmail("mister.x.super@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile4)).withIdentifier(4); profile5 = new ProfileDrawerItem().withName("Batman").withEmail("batman@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile5));
final IProfile profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("mikepenz@gmail.com").withIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460"); final IProfile profile2 = new ProfileDrawerItem().withName("Bernat Borras").withEmail("alorma@github.com").withIcon(Uri.parse("https://avatars3.githubusercontent.com/u/887462?v=3&s=460")); final IProfile profile3 = new ProfileDrawerItem().withName("Max Muster").withEmail("max.mustermann@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile2)); final IProfile profile4 = new ProfileDrawerItem().withName("Felix House").withEmail("felix.house@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile3)); final IProfile profile5 = new ProfileDrawerItem().withName("Mr. X").withEmail("mister.x.super@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile4)).withIdentifier(4); final IProfile profile6 = new ProfileDrawerItem().withName("Batman").withEmail("batman@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile5));
@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 && ((IDrawerItem) profile).getIdentifier() == PROFILE_SETTING) { IProfile newProfile = new ProfileDrawerItem().withNameShown(true).withName("Batman").withEmail("batman@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile5)); if (headerResult.getProfiles() != null) { //we know that there are 2 setting elements. set the new profile above them ;) headerResult.addProfile(newProfile, headerResult.getProfiles().size() - 2); } else { headerResult.addProfiles(newProfile); } } //false if you have not consumed the event and it should close the drawer return false; } })
final IProfile profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("mikepenz@gmail.com").withIcon(R.drawable.profile); final IProfile profile2 = new ProfileDrawerItem().withName("Max Muster").withEmail("max.mustermann@gmail.com").withIcon(R.drawable.profile2); final IProfile profile3 = new ProfileDrawerItem().withName("Felix House").withEmail("felix.house@gmail.com").withIcon(R.drawable.profile3); final IProfile profile4 = new ProfileDrawerItem().withName("Mr. X").withEmail("mister.x.super@gmail.com").withIcon(R.drawable.profile4); final IProfile profile5 = new ProfileDrawerItem().withName("Batman").withEmail("batman@gmail.com").withIcon(R.drawable.profile5);
@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 && ((IDrawerItem) profile).getIdentifier() == PROFILE_SETTING) { IProfile newProfile = new ProfileDrawerItem().withNameShown(true).withName("Batman").withEmail("batman@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile5)); if (headerResult.getProfiles() != null) { //we know that there are 2 setting elements. set the new profile above them ;) headerResult.addProfile(newProfile, headerResult.getProfiles().size() - 2); } else { headerResult.addProfiles(newProfile); } } //false if you have not consumed the event and it should close the drawer return false; } })
final IProfile profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("mikepenz@gmail.com").withIcon(R.drawable.profile); final IProfile profile2 = new ProfileDrawerItem().withName("Max Muster").withEmail("max.mustermann@gmail.com").withIcon(R.drawable.profile2); final IProfile profile3 = new ProfileDrawerItem().withName("Felix House").withEmail("felix.house@gmail.com").withIcon(R.drawable.profile3); final IProfile profile4 = new ProfileDrawerItem().withName("Mr. X").withEmail("mister.x.super@gmail.com").withIcon(R.drawable.profile4); final IProfile profile5 = new ProfileDrawerItem().withName("Batman").withEmail("batman@gmail.com").withIcon(R.drawable.profile5);
@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_SETTING) { int count = 100 + headerResult.getProfiles().size() + 1; IProfile newProfile = new ProfileDrawerItem().withNameShown(true).withName("Batman" + count).withEmail("batman" + count + "@gmail.com").withIcon(R.drawable.profile5).withIdentifier(count); if (headerResult.getProfiles() != null) { //we know that there are 2 setting elements. set the new profile above them ;) headerResult.addProfile(newProfile, headerResult.getProfiles().size() - 2); } else { headerResult.addProfiles(newProfile); } } //false if you have not consumed the event and it should close the drawer return false; } })
final IProfile profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("mikepenz@gmail.com").withIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460"); final IProfile profile2 = new ProfileDrawerItem().withName("Bernat Borras").withEmail("alorma@github.com").withIcon(Uri.parse("https://avatars3.githubusercontent.com/u/887462?v=3&s=460")); final IProfile profile3 = new ProfileDrawerItem().withName("Max Muster").withEmail("max.mustermann@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile2)); final IProfile profile4 = new ProfileDrawerItem().withName("Felix House").withEmail("felix.house@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile3)); final IProfile profile5 = new ProfileDrawerItem().withName("Mr. X").withEmail("mister.x.super@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile4)).withIdentifier(4); final IProfile profile6 = new ProfileDrawerItem().withName("Batman").withEmail("batman@gmail.com").withIcon(getResources().getDrawable(R.drawable.profile5));
headerBuilder.addProfiles(new ProfileDrawerItem() .withNameShown(true) .withName(R.string.integrated_inbox_title) .withEmail(parent.getString(R.string.integrated_inbox_detail)) .withIcon(new IconicsDrawable(parent, FontAwesome.Icon.faw_users) .withName(account.getDescription()) .withEmail(account.getEmail()) .withIdentifier(drawerId)
final IProfile profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("mikepenz@gmail.com").withIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460"); final IProfile profile2 = new ProfileDrawerItem().withName("Bernat Borras").withEmail("alorma@github.com").withIcon(Uri.parse("https://avatars3.githubusercontent.com/u/887462?v=3&s=460"));
final IProfile profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("mikepenz@gmail.com").withIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460").withIdentifier(100); final IProfile profile2 = new ProfileDrawerItem().withName("Demo User").withEmail("demo@github.com").withIcon("https://avatars2.githubusercontent.com/u/3597376?v=3&s=460").withIdentifier(101); final IProfile profile3 = new ProfileDrawerItem().withName("Max Muster").withEmail("max.mustermann@gmail.com").withIcon(R.drawable.profile2).withIdentifier(102); final IProfile profile4 = new ProfileDrawerItem().withName("Felix House").withEmail("felix.house@gmail.com").withIcon(R.drawable.profile3).withIdentifier(103); final IProfile profile5 = new ProfileDrawerItem().withName("Mr. X").withEmail("mister.x.super@gmail.com").withIcon(R.drawable.profile4).withIdentifier(104); final IProfile profile6 = new ProfileDrawerItem().withName("Batman").withEmail("batman@gmail.com").withIcon(R.drawable.profile5).withIdentifier(105);
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)); } }
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 }
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); }
private void updateUserProfile() { final String username = Preferences.USERNAME.getString(PreferenceManager.getDefaultSharedPreferences(this)); if(username != null) { final User user = getRealm().where(User.class).equalTo(User.USER_ID, username).findFirst(); if (user != null) { profileDrawerItem.withName(user.getDisplayName()); final String encodedImage = user.getAvatar(); if (encodedImage != null) { Bitmap avatarBitmap = BitmapFactory.decodeStream(new Base64InputStream(new ByteArrayInputStream(encodedImage.getBytes()), Base64.DEFAULT)); profileDrawerItem.withIcon(avatarBitmap); } else { profileDrawerItem.withIcon(R.mipmap.ic_launcher_round); } if (accountHeader != null) accountHeader.updateProfile(profileDrawerItem); } else { profileDrawerItem.withIcon(R.mipmap.ic_launcher_round); } } else { profileDrawerItem.withIcon(R.mipmap.ic_launcher_round); } }
private void refreshUserInfo(UserInfo userInfo) { IProfile p; if(userInfo.getImg_url() != null && !userInfo.getImg_url().equals("")){ String url = StringUtils.getPicUrlList(userInfo.getImg_url()).get(0); p = new ProfileDrawerItem() .withName(userInfo.getNickname()) .withEmail(userInfo.getEmail()) .withIcon(url) .withIdentifier(100); drawerHeader.updateProfile(p); ImageView view = (ImageView) drawerHeader.getView().findViewById(R.id.material_drawer_account_header_current); Picasso.with(MainActivity.this) .load(url) .resize(200, 200) .centerCrop() .into(view); }else{ p = new ProfileDrawerItem() .withName(userInfo.getNickname()) .withEmail(userInfo.getEmail()) .withIcon(R.drawable.ic_account_circle_white_48dp) .withIdentifier(100); drawerHeader.updateProfile(p); } }
IProfile newProfile = new ProfileDrawerItem().withName(projectName).withIcon(disk).withOnDrawerItemClickListener(this); mProfiles.add(newProfile);
public void showConnectionsInDrawerHeader() { // Remove old profiles from the header List<Long> profileIdList = new ArrayList<>(); for (IProfile profile : headerResult.getProfiles()) { profileIdList.add(profile.getIdentifier()); } for (Long id : profileIdList) { headerResult.removeProfileByIdentifier(id); } // Add the existing connections as new profiles final List<Connection> connectionList = appRepository.getConnectionData().getItems(); if (connectionList.size() > 0) { for (Connection c : connectionList) { headerResult.addProfiles( new CustomProfileDrawerItem() .withEmailShown(true) .withNameShown(true) .withIdentifier(c.getId()) .withName(c.getName()) .withEmail(c.getHostname())); } } else { headerResult.addProfiles(new ProfileDrawerItem().withName(R.string.no_connection_available)); } Connection connection = appRepository.getConnectionData().getActiveItem(); if (connection != null) { headerResult.setActiveProfile(connection.getId()); } }
profileDrawerItem.withName(Preferences.USERNAME.getString(preferences)); profileDrawerItem.withEmail(Preferences.URL.getString(preferences));