/** * <p>Returns the packed position representation of a child position.</p> * <p>In general, a packed position should be used in situations where the position given to/returned from * {@link RecyclerViewExpandableItemManager} method can either be a child or group. * The two positions are packed into a single long which can be unpacked using {@link #getPackedPositionChild(long)} and * {@link #getPackedPositionGroup(long)}.</p> * * @param groupPosition The child's parent group's position * @param childPosition The child position within the group * @return The packed position representation of the child (and parent group). */ public static long getPackedPositionForChild(int groupPosition, int childPosition) { return ExpandableAdapterHelper.getPackedPositionForChild(groupPosition, childPosition); }
/*package*/ void notifyChildItemRangeChanged(int groupPosition, int childPositionStart, int itemCount, Object payload) { final int visibleChildCount = mPositionTranslator.getVisibleChildCount(groupPosition); // notify if the group is expanded if ((visibleChildCount > 0) && (childPositionStart < visibleChildCount)) { final long packedPosition = ExpandableAdapterHelper.getPackedPositionForChild(groupPosition, 0); final int flatPosition = mPositionTranslator.getFlatPosition(packedPosition); if (flatPosition != RecyclerView.NO_POSITION) { final int startPosition = flatPosition + childPositionStart; final int count = Math.min(itemCount, (visibleChildCount - childPositionStart)); notifyItemRangeChanged(startPosition, count, payload); } } }
/*package*/ void notifyChildrenOfGroupItemChanged(int groupPosition, Object payload) { final int visibleChildCount = mPositionTranslator.getVisibleChildCount(groupPosition); // notify if the group is expanded if (visibleChildCount > 0) { final long packedPosition = ExpandableAdapterHelper.getPackedPositionForChild(groupPosition, 0); final int flatPosition = mPositionTranslator.getFlatPosition(packedPosition); if (flatPosition != RecyclerView.NO_POSITION) { notifyItemRangeChanged(flatPosition, visibleChildCount, payload); } } }
/*package*/ void notifyChildItemInserted(int groupPosition, int childPosition) { mPositionTranslator.insertChildItem(groupPosition, childPosition); final long packedPosition = ExpandableAdapterHelper.getPackedPositionForChild(groupPosition, childPosition); final int flatPosition = mPositionTranslator.getFlatPosition(packedPosition); if (flatPosition != RecyclerView.NO_POSITION) { notifyItemInserted(flatPosition); } }
/*package*/ void notifyChildItemRemoved(int groupPosition, int childPosition) { final long packedPosition = ExpandableAdapterHelper.getPackedPositionForChild(groupPosition, childPosition); final int flatPosition = mPositionTranslator.getFlatPosition(packedPosition); mPositionTranslator.removeChildItem(groupPosition, childPosition); if (flatPosition != RecyclerView.NO_POSITION) { notifyItemRemoved(flatPosition); } }
/*package*/ void notifyChildItemRangeInserted(int groupPosition, int childPositionStart, int itemCount) { mPositionTranslator.insertChildItems(groupPosition, childPositionStart, itemCount); final long packedPosition = ExpandableAdapterHelper.getPackedPositionForChild(groupPosition, childPositionStart); final int flatPosition = mPositionTranslator.getFlatPosition(packedPosition); if (flatPosition != RecyclerView.NO_POSITION) { notifyItemRangeInserted(flatPosition, itemCount); } }
/*package*/ void notifyChildItemRangeRemoved(int groupPosition, int childPositionStart, int itemCount) { final long packedPosition = ExpandableAdapterHelper.getPackedPositionForChild(groupPosition, childPositionStart); final int flatPosition = mPositionTranslator.getFlatPosition(packedPosition); mPositionTranslator.removeChildItems(groupPosition, childPositionStart, itemCount); if (flatPosition != RecyclerView.NO_POSITION) { notifyItemRangeRemoved(flatPosition, itemCount); } }
expandablePosition = ExpandableAdapterHelper.getPackedPositionForChild(i, (flatPosition - offset)); break; } else {
final int childStart = Math.min(range.getStart(), maxChildrenPos); final int childEnd = Math.min(range.getEnd(), maxChildrenPos); final long startPackedChildPosition = ExpandableAdapterHelper.getPackedPositionForChild(groupPosition, childStart); final long endPackedChildPosition = ExpandableAdapterHelper.getPackedPositionForChild(groupPosition, childEnd); final int start = mPositionTranslator.getFlatPosition(startPackedChildPosition); final int end = mPositionTranslator.getFlatPosition(endPackedChildPosition);
ExpandableAdapterHelper.getPackedPositionForChild(fromGroupPosition, modToChildPosition));