@Test public void partialSpanInvalidation() throws Throwable { Config config = new Config().spanCount(5).itemCount(100); setupByConfig(config); for (int i = 20; i < mAdapter.getItemCount(); i += 20) { mAdapter.mFullSpanItems.add(i); } waitFirstLayout(); smoothScrollToPosition(50); int prevSpanId = mLayoutManager.mLazySpanLookup.mData[30]; mAdapter.changeAndNotify(15, 2); Thread.sleep(200); assertEquals("Invalidation should happen within full span item boundaries", prevSpanId, mLayoutManager.mLazySpanLookup.mData[30]); assertEquals("item in invalidated range should have clear span id", LayoutParams.INVALID_SPAN_ID, mLayoutManager.mLazySpanLookup.mData[16]); smoothScrollToPosition(85); int[] prevSpans = copyOfRange(mLayoutManager.mLazySpanLookup.mData, 62, 85); mAdapter.deleteAndNotify(55, 2); Thread.sleep(200); assertEquals("item in invalidated range should have clear span id", LayoutParams.INVALID_SPAN_ID, mLayoutManager.mLazySpanLookup.mData[16]); int[] newSpans = copyOfRange(mLayoutManager.mLazySpanLookup.mData, 60, 83); assertSpanAssignmentEquality("valid spans should be shifted for deleted item", prevSpans, newSpans, 0, 0, newSpans.length); }
@Override public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) { LinearSmoothScroller scroller = new LinearSmoothScroller(recyclerView.getContext()); scroller.setTargetPosition(position); startSmoothScroll(scroller); }
StaggeredGridLayoutManager extends RecyclerView.LayoutManager implements
        RecyclerView.SmoothScroller.ScrollVectorProvider { @Override public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) { LinearSmoothScroller scroller = new LinearSmoothScroller(recyclerView.getContext()); scroller.setTargetPosition(position); startSmoothScroll(scroller); } }
StaggeredGridLayoutManager extends RecyclerView.LayoutManager implements
        RecyclerView.SmoothScroller.ScrollVectorProvider { @Override public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) { LinearSmoothScroller scroller = new LinearSmoothScroller(recyclerView.getContext()); scroller.setTargetPosition(position); startSmoothScroll(scroller); } @SuppressWarnings("unused")  StaggeredGridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr,
            int defStyleRes);  StaggeredGridLayoutManager(int spanCount, int orientation); }
StaggeredGridLayoutManager extends RecyclerView.LayoutManager implements
        RecyclerView.SmoothScroller.ScrollVectorProvider { @Override public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) { LinearSmoothScroller scroller = new LinearSmoothScroller(recyclerView.getContext()); scroller.setTargetPosition(position); startSmoothScroll(scroller); } @SuppressWarnings("unused")  StaggeredGridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr,
            int defStyleRes);  StaggeredGridLayoutManager(int spanCount, int orientation); @Override boolean isAutoMeasureEnabled(); @Override void onScrollStateChanged(int state); @Override void onDetachedFromWindow(RecyclerView view, RecyclerView.Recycler recycler); void setSpanCount(int spanCount); void setOrientation(int orientation); void setReverseLayout(boolean reverseLayout); int getGapStrategy(); void setGapStrategy(int gapStrategy); @Override void assertNotInLayoutOrScroll(String message); int getSpanCount(); void invalidateSpanAssignments(); boolean getReverseLayout(); @Override void setMeasuredDimension(Rect childrenBounds, int wSpec, int hSpec); @Override void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state); @Override void onLayoutCompleted(RecyclerView.State state); @Override boolean supportsPredictiveItemAnimations(); int[] findFirstVisibleItemPositions(int[] into); int[] findFirstCompletelyVisibleItemPositions(int[] into); int[] findLastVisibleItemPositions(int[] into); int[] findLastCompletelyVisibleItemPositions(int[] into); @Override int computeHorizontalScrollOffset(RecyclerView.State state); @Override int computeVerticalScrollOffset(RecyclerView.State state); @Override int computeHorizontalScrollExtent(RecyclerView.State state); @Override int computeVerticalScrollExtent(RecyclerView.State state); @Override int computeHorizontalScrollRange(RecyclerView.State state); @Override int computeVerticalScrollRange(RecyclerView.State state); @Override void onRestoreInstanceState(Parcelable state); @Override Parcelable onSaveInstanceState(); @Override void onInitializeAccessibilityNodeInfoForItem(RecyclerView.Recycler recycler,
            RecyclerView.State state, View host, AccessibilityNodeInfoCompat info); @Override void onInitializeAccessibilityEvent(AccessibilityEvent event); @Override int getRowCountForAccessibility(RecyclerView.Recycler recycler,
            RecyclerView.State state); @Override int getColumnCountForAccessibility(RecyclerView.Recycler recycler,
            RecyclerView.State state); @Override void offsetChildrenHorizontal(int dx); @Override void offsetChildrenVertical(int dy); @Override void onItemsRemoved(RecyclerView recyclerView, int positionStart, int itemCount); @Override void onItemsAdded(RecyclerView recyclerView, int positionStart, int itemCount); @Override void onItemsChanged(RecyclerView recyclerView); @Override void onItemsMoved(RecyclerView recyclerView, int from, int to, int itemCount); @Override void onItemsUpdated(RecyclerView recyclerView, int positionStart, int itemCount,
            Object payload); @Override boolean canScrollVertically(); @Override boolean canScrollHorizontally(); @Override int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler,
            RecyclerView.State state); @Override int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler,
            RecyclerView.State state); @Override PointF computeScrollVectorForPosition(int targetPosition); @Override void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state,
            int position); @Override void scrollToPosition(int position); void scrollToPositionWithOffset(int position, int offset); @Override @RestrictTo(LIBRARY) void collectAdjacentPrefetchPositions(int dx, int dy, RecyclerView.State state,
            LayoutPrefetchRegistry layoutPrefetchRegistry); @SuppressWarnings("deprecation") @Override RecyclerView.LayoutParams generateDefaultLayoutParams(); @Override RecyclerView.LayoutParams generateLayoutParams(Context c, AttributeSet attrs); @Override RecyclerView.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp); @Override boolean checkLayoutParams(RecyclerView.LayoutParams lp); int getOrientation(); @Nullable @Override View onFocusSearchFailed(View focused, int direction, RecyclerView.Recycler recycler,
            RecyclerView.State state); }
StaggeredGridLayoutManager extends RecyclerView.LayoutManager implements
        RecyclerView.SmoothScroller.ScrollVectorProvider { @Override public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) { LinearSmoothScroller scroller = new LinearSmoothScroller(recyclerView.getContext()); scroller.setTargetPosition(position); startSmoothScroll(scroller); } @SuppressWarnings("unused")  StaggeredGridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr,
            int defStyleRes);  StaggeredGridLayoutManager(int spanCount, int orientation); @Override boolean isAutoMeasureEnabled(); @Override void onScrollStateChanged(int state); @Override void onDetachedFromWindow(RecyclerView view, RecyclerView.Recycler recycler); void setSpanCount(int spanCount); void setOrientation(int orientation); void setReverseLayout(boolean reverseLayout); int getGapStrategy(); void setGapStrategy(int gapStrategy); @Override void assertNotInLayoutOrScroll(String message); int getSpanCount(); void invalidateSpanAssignments(); boolean getReverseLayout(); @Override void setMeasuredDimension(Rect childrenBounds, int wSpec, int hSpec); @Override void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state); @Override void onLayoutCompleted(RecyclerView.State state); @Override boolean supportsPredictiveItemAnimations(); int[] findFirstVisibleItemPositions(int[] into); int[] findFirstCompletelyVisibleItemPositions(int[] into); int[] findLastVisibleItemPositions(int[] into); int[] findLastCompletelyVisibleItemPositions(int[] into); @Override int computeHorizontalScrollOffset(RecyclerView.State state); @Override int computeVerticalScrollOffset(RecyclerView.State state); @Override int computeHorizontalScrollExtent(RecyclerView.State state); @Override int computeVerticalScrollExtent(RecyclerView.State state); @Override int computeHorizontalScrollRange(RecyclerView.State state); @Override int computeVerticalScrollRange(RecyclerView.State state); @Override void onRestoreInstanceState(Parcelable state); @Override Parcelable onSaveInstanceState(); @Override void onInitializeAccessibilityNodeInfoForItem(RecyclerView.Recycler recycler,
            RecyclerView.State state, View host, AccessibilityNodeInfoCompat info); @Override void onInitializeAccessibilityEvent(AccessibilityEvent event); @Override int getRowCountForAccessibility(RecyclerView.Recycler recycler,
            RecyclerView.State state); @Override int getColumnCountForAccessibility(RecyclerView.Recycler recycler,
            RecyclerView.State state); @Override void offsetChildrenHorizontal(int dx); @Override void offsetChildrenVertical(int dy); @Override void onItemsRemoved(RecyclerView recyclerView, int positionStart, int itemCount); @Override void onItemsAdded(RecyclerView recyclerView, int positionStart, int itemCount); @Override void onItemsChanged(RecyclerView recyclerView); @Override void onItemsMoved(RecyclerView recyclerView, int from, int to, int itemCount); @Override void onItemsUpdated(RecyclerView recyclerView, int positionStart, int itemCount,
            Object payload); @Override boolean canScrollVertically(); @Override boolean canScrollHorizontally(); @Override int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler,
            RecyclerView.State state); @Override int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler,
            RecyclerView.State state); @Override PointF computeScrollVectorForPosition(int targetPosition); @Override void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state,
            int position); @Override void scrollToPosition(int position); void scrollToPositionWithOffset(int position, int offset); @Override @RestrictTo(LIBRARY) void collectAdjacentPrefetchPositions(int dx, int dy, RecyclerView.State state,
            LayoutPrefetchRegistry layoutPrefetchRegistry); @SuppressWarnings("deprecation") @Override RecyclerView.LayoutParams generateDefaultLayoutParams(); @Override RecyclerView.LayoutParams generateLayoutParams(Context c, AttributeSet attrs); @Override RecyclerView.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp); @Override boolean checkLayoutParams(RecyclerView.LayoutParams lp); int getOrientation(); @Nullable @Override View onFocusSearchFailed(View focused, int direction, RecyclerView.Recycler recycler,
            RecyclerView.State state); static final int HORIZONTAL; static final int VERTICAL; static final int GAP_HANDLING_NONE; @SuppressWarnings("unused")
    @Deprecated
    static final int GAP_HANDLING_LAZY; static final int GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS; }