mikepenz / MaterialDrawer

The flexible, easy to use, all in one drawer library for your Android project. Now brand new with material 2 design.
https://mikepenz.dev
Apache License 2.0
11.67k stars 2.05k forks source link

setSelection - icon tinting problem #1599

Closed MFlisar closed 7 years ago

MFlisar commented 7 years ago

After reading a few issues here, I adjusted my code to use following:

mDrawerLeft.getAdapter().withSelectWithItemUpdate(true);

Here is my theming function for the drawer, I call it for all my items in the drawer:

public void themeDrawerItem(IDrawerItem item)
{
    if (item instanceof BaseDrawerItem)
    {
        ((BaseDrawerItem) item).withSelectedTextColor(mTheme.accentColor());
        ((BaseDrawerItem) item).withSelectedIconColor(mTheme.accentColor());
        ((BaseDrawerItem) item).withIconColor(mTheme.getMainTextColor());
        ((BaseDrawerItem) item).withIconTintingEnabled(true);
    }
    else if (item instanceof SectionDrawerItem)
        ((SectionDrawerItem) item).withTextColor(mTheme.accentColor());
}

Now I allow the user to select pages via a BottomNavigationView in addition to the Drawer and so I need to sync the selection states and whenever the page changes, I call following:

mDrawerLeft.setSelection(selectedId, false);

This leads to following:

Any ideas what could be the problem here?

mikepenz commented 7 years ago

@MFlisar which version are you on?

First. Why did you have to change to the above: withSelectWithItemUpdate? In general the normal state change should be enough for selecting / deselecting.

Also I think iterating over all items when the theme changes to adjust the colors shouldn't be done, as it is slower as if you would just handle the items on your own and just set the colors at the normal bind view method.

But the above do not describe why you get into this issue. Do you call the above method in the main ui thread?

MFlisar commented 7 years ago

I'm using the current develop branch.

I tried withSelectWithItemUpdate because of this issue: https://github.com/mikepenz/MaterialDrawer/issues/1180

I'm calling the themeDrawerItem(IDrawerItem item) before showing anything, this is only called when I setup the drawer builder. The mDrawerLeft.setSelection(selectedId, false); is called from the main thread as well.

Again, selection works perfectly fine (everything but the icon tinting => selector and text tinting work fine)

mikepenz commented 7 years ago

@MFlisar that's weird again :/ probably you can create another sample app so I can try and debug it

mikepenz commented 7 years ago

@MFlisar any update? otherwise I have to close this.

Just comment to bring this up again