/** * @param listPosition The child positions to be converted in it's * {@link ExpandableListPosition} representation. * @return The flat list position for the first child in a group */ public int getFlattenedFirstChildIndex(ExpandableListPosition listPosition) { return getFlattenedGroupIndex(listPosition) + 1; }
/** * @param groupIndex The index of a group within {@link #groups} * @return The flat list position for the first child in a group */ public int getFlattenedFirstChildIndex(int groupIndex) { return getFlattenedGroupIndex(groupIndex) + 1; }
/** * Expand a group * * @param listPosition the group to be expanded */ private void expandGroup(ExpandableListPosition listPosition) { expandableList.expandedGroupIndexes[listPosition.groupPos] = true; if (listener != null) { listener.onGroupExpanded(expandableList.getFlattenedGroupIndex(listPosition) + 1, expandableList.groups.get(listPosition.groupPos).getItemCount()); } }
/** * Collapse a group * * @param listPosition position of the group to collapse */ private void collapseGroup(ExpandableListPosition listPosition) { expandableList.expandedGroupIndexes[listPosition.groupPos] = false; if (listener != null) { listener.onGroupCollapsed(expandableList.getFlattenedGroupIndex(listPosition) + 1, expandableList.groups.get(listPosition.groupPos).getItemCount()); } }
public boolean toggleGroup(ExpandableGroup group) { ExpandableListPosition listPos = expandableList.getUnflattenedPosition(expandableList.getFlattenedGroupIndex(group)); boolean expanded = expandableList.expandedGroupIndexes[listPos.groupPos]; if (expanded) { collapseGroup(listPos); } else { expandGroup(listPos); } return expanded; }