You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the sub item was selected, and then we collapse the list and click on the other main item, both items will be selected (the new one and the old sub item)
How to reproduce (sample app):
Open navigation drawer
Expand "Collapsable Badge", select the first item - "CollapsableItem"
Collapse the list by clicking on "Collapsable Badge"
Click on "Contract"
Expand "Collapsable Badge"
Both "CollapsableItem" and "Contract" item will be selected
My temporary workaround - I deselect all sub items when the click was performed on the main items:
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (nonNull(drawerItem) && drawerItem instanceof AbstractBadgeableDrawerItem) {
long clickedIdentifier = drawerItem.getIdentifier();
if (!isSubItem(clickedIdentifier)) {
deselectAllSubItems();
}
(...)
}
return false;
}
private void deselectAllSubItems() {
List<IDrawerItem> drawerItems = drawerResult.getDrawerItems();
for (IDrawerItem drawerItem : drawerItems) {
if (drawerItem instanceof ExpandableDrawerItem) {
ExpandableDrawerItem expandableDrawerItem = (ExpandableDrawerItem) drawerItem;
List<IDrawerItem> subItems = expandableDrawerItem.getSubItems();
if (nonNull(subItems)) {
for (IDrawerItem subItem : subItems) {
subItem.withSetSelected(false);
}
}
}
}
}
private boolean isSubItem(long itemId) {
List<IDrawerItem> drawerItems = drawerResult.getDrawerItems();
for (IDrawerItem drawerItem : drawerItems) {
if (drawerItem instanceof ExpandableDrawerItem) {
ExpandableDrawerItem expandableDrawerItem = (ExpandableDrawerItem) drawerItem;
List<IDrawerItem> subItems = expandableDrawerItem.getSubItems();
if (nonNull(subItems)) {
for (IDrawerItem subItem : subItems) {
if (subItem.getIdentifier() == itemId)
return true;
}
}
}
}
return false;
}
The text was updated successfully, but these errors were encountered:
ghost
changed the title
Sub item doesn't deselect if the list was collapsed
Sub item doesn't deselect if the list was collapsed when new click performed
Jan 23, 2018
If the sub item was selected, and then we collapse the list and click on the other main item, both items will be selected (the new one and the old sub item)
How to reproduce (sample app):
My temporary workaround - I deselect all sub items when the click was performed on the main items:
The text was updated successfully, but these errors were encountered: