Materialdrawer: Updating the account header profile info for the same result Drawer.

Created on 25 Aug 2016  路  6Comments  路  Source: mikepenz/MaterialDrawer

Hi,
My app generates only one Drawer object and updates it's items and header data values during it's life time. Can you please show me how to update the header account info (name, email) without the need to rebuild a new Drawer. I tried the following answer #317 (also #1370) from 2015, but the mentioned update function is deprecated.

Thank you.

question

Most helpful comment

does your profile have an identifier?

All 6 comments

Thanks for the fast reply :)
I tried to use notify() after updating the account header, but my app crashes.

headerResult.updateProfile(profile);
headerResult.notify();

08-25 18:37:40.064 3548-3548/com.example.sense.ContactManagment E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.sense.ContactManagment, PID: 3548
java.lang.IllegalMonitorStateException: object not locked by thread before notify()
at java.lang.Object.notify(Native Method)
at com.example.sense.ContactManagment.Utilities.NavigationDrawerUtil.getNavigationDrawer(NavigationDrawerUtil.java:115)
at com.example.sense.ContactManagment.ActivityAddContacts.getNavigationDrawer(ActivityAddContacts.java:1159)
at com.example.sense.ContactManagment.ActivityAddContacts.syncData(ActivityAddContacts.java:330)
at com.example.sense.ContactManagment.ActivityAddContacts.onDropBoxLogDone(ActivityAddContacts.java:322)
at com.example.sense.ContactManagment.DropboxController.DropBoxLogOnManager$1.onComplete(DropBoxLogOnManager.java:128)
at com.example.sense.ContactManagment.DropboxController.ConnectToDropBoxAccount.onPostExecute(ConnectToDropBoxAccount.java:41)
at com.example.sense.ContactManagment.DropboxController.ConnectToDropBoxAccount.onPostExecute(ConnectToDropBoxAccount.java:13)
at android.os.AsyncTask.finish(AsyncTask.java:651)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

you should not call notify on the headerResult everything handled via the updateProfile mehod.

Also make sure you are on the main thread

I tried without notify and it doesn't update the header account.

When I execute the below code with "profile" having the correct updated name + email info, I get one profile back in the list, and the name and email are not updated.

headerResult.updateProfile(profile);
List<IProfile> ip = headerResult.getProfiles();

does your profile have an identifier?

I just added an identifier and it worked. Thanks a lot.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kakai248 picture kakai248  路  4Comments

pranjal-joshi picture pranjal-joshi  路  3Comments

fuentepa picture fuentepa  路  3Comments

GutoMartins019 picture GutoMartins019  路  4Comments

Meeks91 picture Meeks91  路  3Comments