Closed carlos-mg89 closed 2 years ago
I believe that this could possibly be because not all things are reset. E.g. the different held references:
binding.slider.accountHeader = null
binding.slider.headerView = null
headerView.sliderView = null
(based on the sample activity)
A quick draft of a method to do a detach could look like (this would be a full detach, not 100% tested yet):
fun AccountHeaderView.detachFromSliderView(sliderView: MaterialDrawerSliderView) {
this.sliderView = null
// set the top padding to 0 as this would happen when the AccountHeader is created during Drawer build time
sliderView.recyclerView.updatePadding(top = /* topInset + */ context.resources.getDimensionPixelSize(R.dimen.material_drawer_padding_top_bottom))
// remove the views again
sliderView.headerView = null
sliderView.accountHeader = null
// rebuild the things
updateHeaderAndList()
sliderView.resetDrawerContent()
}
Thanks a lot! That was it :)
About this issue
Hi everyone!
I'm trying to fully reset the
MaterialDrawerSliderView
by rebuilding it (after certain user events). The view is almost fully rebuilt, except theAccountHeaderView
(which I only create if there's an active profile == user logged in).Basically, this is the whole process.
1. Scenario with active profile
2. Scenario without active profile
This is my code to build the slider:
And the code to reset the slider:
If you go from scenario 2, and login, then the account header is properly set, with the active profile information.
However, if you are in the scenario 1, and log out, the account header gets the profile removed, but the background remains there.
And I'll expect it to be, as it is in the scenario 2:
Details
Checklist