FileDocCategorySizeDatePackage
ExpandableListPosition.javaAPI DocAndroid 5.1 API4430Thu Mar 12 22:22:10 GMT 2015android.widget

ExpandableListPosition

public class ExpandableListPosition extends Object
ExpandableListPosition can refer to either a group's position or a child's position. Referring to a child's position requires both a group position (the group containing the child) and a child position (the child's position within that group). To create objects, use {@link #obtainChildPosition(int, int)} or {@link #obtainGroupPosition(int)}.

Fields Summary
private static final int
MAX_POOL_SIZE
private static ArrayList
sPool
public static final int
CHILD
This data type represents a child position
public static final int
GROUP
This data type represents a group position
public int
groupPos
The position of either the group being referred to, or the parent group of the child being referred to
public int
childPos
The position of the child within its parent group
int
flatListPos
The position of the item in the flat list (optional, used internally when the corresponding flat list position for the group or child is known)
public int
type
What type of position this ExpandableListPosition represents
Constructors Summary
private ExpandableListPosition()

    
Methods Summary
longgetPackedPosition()

        if (type == CHILD) return ExpandableListView.getPackedPositionForChild(groupPos, childPos);
        else return ExpandableListView.getPackedPositionForGroup(groupPos);
    
private static android.widget.ExpandableListPositiongetRecycledOrCreate()

        ExpandableListPosition elp;
        synchronized (sPool) {
            if (sPool.size() > 0) {
                elp = sPool.remove(0);
            } else {
                return new ExpandableListPosition();
            }
        }
        elp.resetState();
        return elp;
    
static android.widget.ExpandableListPositionobtain(int type, int groupPos, int childPos, int flatListPos)

        ExpandableListPosition elp = getRecycledOrCreate(); 
        elp.type = type;
        elp.groupPos = groupPos;
        elp.childPos = childPos;
        elp.flatListPos = flatListPos;
        return elp;
    
static android.widget.ExpandableListPositionobtainChildPosition(int groupPosition, int childPosition)

        return obtain(CHILD, groupPosition, childPosition, 0);
    
static android.widget.ExpandableListPositionobtainGroupPosition(int groupPosition)

        return obtain(GROUP, groupPosition, 0, 0);
    
static android.widget.ExpandableListPositionobtainPosition(long packedPosition)

        if (packedPosition == ExpandableListView.PACKED_POSITION_VALUE_NULL) {
            return null;
        }
        
        ExpandableListPosition elp = getRecycledOrCreate(); 
        elp.groupPos = ExpandableListView.getPackedPositionGroup(packedPosition);
        if (ExpandableListView.getPackedPositionType(packedPosition) ==
                ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
            elp.type = CHILD;
            elp.childPos = ExpandableListView.getPackedPositionChild(packedPosition);
        } else {
            elp.type = GROUP;
        }
        return elp;
    
public voidrecycle()
Do not call this unless you obtained this via ExpandableListPosition.obtain(). PositionMetadata will handle recycling its own children.

        synchronized (sPool) {
            if (sPool.size() < MAX_POOL_SIZE) {
                sPool.add(this);
            }
        }
    
private voidresetState()

    
       
        groupPos = 0;
        childPos = 0;
        flatListPos = 0;
        type = 0;