Materialdrawer: Update user profile image icon

Created on 29 Jul 2016  ·  4Comments  ·  Source: mikepenz/MaterialDrawer

Hi Mike,

First of all, thanks for your amazing job!
I am trying to use the method drawer.updateIcon(id, image in bitmap).
But the image don't update. I checked the image and is correct.

I tried update using the header object, but not work too.

There is any library that is necessary for this to work?

I can't find a solution.

Thanks again.

question

Most helpful comment

@GutoMartins019 you are mixing drawer and header.

If you want to update a profile (an item of the AccountHeader) you have to use the AccountHeader specific methods to update it's elements.

Which would result in something like this, to update the icon:

profile5.withIcon(BitmapFactory.decodeResource(getResources(), R.drawable.leak_canary_icon));  
headerResult.updateProfile(profile5);

All 4 comments

@GutoMartins019 you had an image prior to setting the bitmap?

And your item has an identifier set?

@mikepenz

Yes, i had a image before update, it was setted on create. My item have a identifier, a int value.

This is how i made:
new ProfileDrawerItem() .withName(user.getFirstName()) .withEmail(user.getEmail()) .withIcon(user.getProfileImageInBitmap()) .withIdentifier(3)

Added this ProfileDrawerItem to my AccountHeaderBuilder
Build my drawer on create activity:
drawer = new DrawerBuilder().withAccountHeader(headerResult)

And now i want to update the profile imagem like this:

if (drawer != null) { User user = new UserService().getUser(); drawer.updateIcon(3, new ImageHolder(user.getProfileImageInBitmap())); }

@GutoMartins019 you are mixing drawer and header.

If you want to update a profile (an item of the AccountHeader) you have to use the AccountHeader specific methods to update it's elements.

Which would result in something like this, to update the icon:

profile5.withIcon(BitmapFactory.decodeResource(getResources(), R.drawable.leak_canary_icon));  
headerResult.updateProfile(profile5);

@mikepenz Thanks for help me!

Sorry for mixing things =/.

Now its working perfect!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DasserBasyouni picture DasserBasyouni  ·  4Comments

pranjal-joshi picture pranjal-joshi  ·  3Comments

Erwinstein picture Erwinstein  ·  3Comments

wayne1203 picture wayne1203  ·  3Comments

sonh picture sonh  ·  3Comments