Fix selection after expand/collapse group

This commit is contained in:
drdev
2014-02-04 03:29:34 +00:00
parent 4aa2dd4471
commit 038418ca0d

View File

@@ -63,15 +63,26 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
//if didn't click on item, see if clicked on group header
if (groupBy != null) {
Point point = e.getPoint();
boolean collapsedChanged = false;
for (Group group : groups) {
if (group.getBounds().contains(point)) {
if (!collapsedChanged && group.getBounds().contains(point)) {
if (point.y < group.getTop() + GROUP_HEADER_HEIGHT) {
group.isCollapsed = !group.isCollapsed;
updateLayout();
collapsedChanged = true;
}
else {
break;
}
}
if (collapsedChanged) {
//if found group to expand/collapse, select next visible item starting at beginning of group
if (!group.isCollapsed && !group.items.isEmpty()) {
setSelectedIndex(group.piles.get(0).items.get(0).index);
break;
}
}
}
}
}
}
@@ -218,6 +229,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
}
private void updateLayout() {
clearSelection(); //must clear selection since indices and visible items will be changing
orderedItems.clear();
int x, groupY;