ItemViewTypeComposer { @IntRange(from = MIN_SEGMENT, to = MAX_SEGMENT) public static int extractSegmentPart(int composedViewType) { return (composedViewType & BIT_MASK_SEGMENT) >>> BIT_OFFSET_SEGMENT; } private  ItemViewTypeComposer(); @IntRange(from = MIN_SEGMENT, to = MAX_SEGMENT) static int extractSegmentPart(int composedViewType); @IntRange(from = MIN_WRAPPED_VIEW_TYPE, to = MAX_WRAPPED_VIEW_TYPE) static int extractWrappedViewTypePart(int composedViewType); static boolean isExpandableGroup(int composedViewType); static int composeSegment(@IntRange(from = MIN_SEGMENT, to = MAX_SEGMENT) int segment, int wrappedViewType); static final int BIT_OFFSET_EXPANDABLE_FLAG; static final int BIT_OFFSET_SEGMENT; static final int BIT_OFFSET_WRAPPED_VIEW_TYPE; static final int BIT_WIDTH_EXPANDABLE_FLAG; static final int BIT_WIDTH_SEGMENT; static final int BIT_WIDTH_WRAPPED_VIEW_TYPE; static final int BIT_MASK_EXPANDABLE_FLAG; static final int BIT_MASK_SEGMENT; static final int BIT_MASK_WRAPPED_VIEW_TYPE; static final int MIN_SEGMENT; static final int MAX_SEGMENT; static final int MIN_WRAPPED_VIEW_TYPE; static final int MAX_WRAPPED_VIEW_TYPE; }
@Test public void extractSegmentPart() throws Exception { assertThat(ItemViewTypeComposer.extractSegmentPart(0), is(0)); assertThat(ItemViewTypeComposer.extractSegmentPart(1 << ItemViewTypeComposer.BIT_OFFSET_SEGMENT), is(1)); assertThat(ItemViewTypeComposer.extractSegmentPart(ItemViewTypeComposer.MIN_SEGMENT << ItemViewTypeComposer.BIT_OFFSET_SEGMENT), is(ItemViewTypeComposer.MIN_SEGMENT)); assertThat(ItemViewTypeComposer.extractSegmentPart(ItemViewTypeComposer.MAX_SEGMENT << ItemViewTypeComposer.BIT_OFFSET_SEGMENT), is(ItemViewTypeComposer.MAX_SEGMENT)); assertThat(ItemViewTypeComposer.extractSegmentPart(ItemViewTypeComposer.BIT_MASK_EXPANDABLE_FLAG | ItemViewTypeComposer.BIT_MASK_WRAPPED_VIEW_TYPE), is(0)); assertThat(ItemViewTypeComposer.extractSegmentPart(ItemViewTypeComposer.BIT_MASK_SEGMENT), is(ItemViewTypeComposer.MAX_SEGMENT)); }