public class

ItemIdComposer

extends Object
java.lang.Object
   ↳ com.h6ah4i.android.widget.advrecyclerview.adapter.ItemIdComposer

Class Overview

Utility class providing "Composed item ID" related definitions and methods.

Spec:

bit 63Reserved
bit 62-56View type segment
bit 55-28Group ID
bit 27-0Child ID

Summary

Constants
long BIT_MASK_CHILD_ID Bit mask of the expandable child ID part.
long BIT_MASK_GROUP_ID Bit mask of the expandable group ID part.
long BIT_MASK_RESERVED_SIGN_FLAG Bit mask of the reserved sign flag part.
long BIT_MASK_SEGMENT Bit mask of the segment part.
int BIT_OFFSET_CHILD_ID Bit offset of the child ID part.
int BIT_OFFSET_GROUP_ID Bit offset of the group ID part.
int BIT_OFFSET_RESERVED_SIGN_FLAG Bit offset of the reserved sign flag part.
int BIT_OFFSET_SEGMENT Bit offset of the segment part.
int BIT_WIDTH_CHILD_ID Bit width of the expandable child ID part.
int BIT_WIDTH_GROUP_ID Bit width of the expandable group ID part.
int BIT_WIDTH_RESERVED_SIGN_FLAG Bit width of the reserved sign flag part.
int BIT_WIDTH_SEGMENT Bit width of the segment part.
long MAX_CHILD_ID Maximum value of child ID.
long MAX_GROUP_ID Maximum value of group ID.
int MAX_SEGMENT Maximum value of segment.
long MAX_WRAPPED_ID Minimum value of wrapped ID (= group + child) ID.
long MIN_CHILD_ID Minimum value of child ID.
long MIN_GROUP_ID Minimum value of group ID.
int MIN_SEGMENT Minimum value of segment.
long MIN_WRAPPED_ID Minimum value of wrapped ID (= group + child) ID.
Public Methods
static long composeExpandableChildId(long groupId, long childId)
Makes a composed ID which represents a child item of an expandable group.
static long composeExpandableGroupId(long groupId)
Makes a composed ID which represents an expandable group item.
static long composeSegment(int segment, long wrappedId)
Makes a composed ID with specified segment and wrapped ID.
static long extractExpandableChildIdPart(long composedId)
Extracts "Child ID" part from composed ID.
static long extractExpandableGroupIdPart(long composedId)
Extracts "Group ID" part from composed ID.
static int extractSegmentPart(long composedId)
Extracts "Segment" part from composed ID.
static long extractWrappedIdPart(long composedId)
Extracts "Wrapped ID" (group ID + child ID) part from composed ID.
static boolean isExpandableGroup(long composedId)
Checks the composed ID is a expandable group or not.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final long BIT_MASK_CHILD_ID

Bit mask of the expandable child ID part.

Constant Value: 268435455 (0x000000000fffffff)

public static final long BIT_MASK_GROUP_ID

Bit mask of the expandable group ID part.

Constant Value: 72057593769492480 (0x00fffffff0000000)

public static final long BIT_MASK_RESERVED_SIGN_FLAG

Bit mask of the reserved sign flag part.

Constant Value: -9223372036854775808 (0x8000000000000000)

public static final long BIT_MASK_SEGMENT

Bit mask of the segment part.

Constant Value: 9151314442816847872 (0x7f00000000000000)

public static final int BIT_OFFSET_CHILD_ID

Bit offset of the child ID part.

Constant Value: 0 (0x00000000)

public static final int BIT_OFFSET_GROUP_ID

Bit offset of the group ID part.

Constant Value: 28 (0x0000001c)

public static final int BIT_OFFSET_RESERVED_SIGN_FLAG

Bit offset of the reserved sign flag part.

Constant Value: 63 (0x0000003f)

public static final int BIT_OFFSET_SEGMENT

Bit offset of the segment part.

Constant Value: 56 (0x00000038)

public static final int BIT_WIDTH_CHILD_ID

Bit width of the expandable child ID part.

Constant Value: 28 (0x0000001c)

public static final int BIT_WIDTH_GROUP_ID

Bit width of the expandable group ID part.

Constant Value: 28 (0x0000001c)

public static final int BIT_WIDTH_RESERVED_SIGN_FLAG

Bit width of the reserved sign flag part.

Constant Value: 1 (0x00000001)

public static final int BIT_WIDTH_SEGMENT

Bit width of the segment part.

Constant Value: 7 (0x00000007)

public static final long MAX_CHILD_ID

Maximum value of child ID.

Constant Value: 134217727 (0x0000000007ffffff)

public static final long MAX_GROUP_ID

Maximum value of group ID.

Constant Value: 134217727 (0x0000000007ffffff)

public static final int MAX_SEGMENT

Maximum value of segment.

Constant Value: 127 (0x0000007f)

public static final long MAX_WRAPPED_ID

Minimum value of wrapped ID (= group + child) ID.

Constant Value: 36028797018963967 (0x007fffffffffffff)

public static final long MIN_CHILD_ID

Minimum value of child ID.

Constant Value: -134217728 (0xfffffffff8000000)

public static final long MIN_GROUP_ID

Minimum value of group ID.

Constant Value: -134217728 (0xfffffffff8000000)

public static final int MIN_SEGMENT

Minimum value of segment.

Constant Value: 0 (0x00000000)

public static final long MIN_WRAPPED_ID

Minimum value of wrapped ID (= group + child) ID.

Constant Value: -36028797018963968 (0xff80000000000000)

Public Methods

public static long composeExpandableChildId (long groupId, long childId)

Makes a composed ID which represents a child item of an expandable group.

Parameters
groupId Group item ID
childId Child item ID
Returns
  • Composed expandable child ID

public static long composeExpandableGroupId (long groupId)

Makes a composed ID which represents an expandable group item.

Parameters
groupId Group item ID
Returns
  • Composed expandable group ID

public static long composeSegment (int segment, long wrappedId)

Makes a composed ID with specified segment and wrapped ID.

Parameters
segment Segment
wrappedId Wrapped ID
Returns
  • Composed ID.

public static long extractExpandableChildIdPart (long composedId)

Extracts "Child ID" part from composed ID.

Parameters
composedId Composed ID
Returns
  • Child ID part. If the specified composed ID is not a child of an expandable group, returns NO_ID.

public static long extractExpandableGroupIdPart (long composedId)

Extracts "Group ID" part from composed ID.

Parameters
composedId Composed ID
Returns
  • Group ID part. If the specified composed ID is not an expandable group, returns NO_ID.

public static int extractSegmentPart (long composedId)

Extracts "Segment" part from composed ID.

Parameters
composedId Composed ID
Returns
  • Segment part

public static long extractWrappedIdPart (long composedId)

Extracts "Wrapped ID" (group ID + child ID) part from composed ID.

Parameters
composedId Composed ID
Returns
  • Wrapped ID part.

public static boolean isExpandableGroup (long composedId)

Checks the composed ID is a expandable group or not.

Parameters
composedId Composed ID
Returns
  • True if the specified composed ID is an expandable group ID. Otherwise, false.