@Test public void temporaryGapHandling() throws Throwable { int fullSpanIndex = 200; setupByConfig(new Config().spanCount(2).itemCount(500)); mAdapter.mFullSpanItems.add(fullSpanIndex); waitFirstLayout(); smoothScrollToPosition(fullSpanIndex + 200); assertNull("test sanity. full span item should not be visible", mRecyclerView.findViewHolderForAdapterPosition(fullSpanIndex)); mLayoutManager.expectLayouts(1); mAdapter.deleteAndNotify(fullSpanIndex + 1, 3); mLayoutManager.waitForLayout(1); smoothScrollToPosition(0); mLayoutManager.expectLayouts(1); smoothScrollToPosition(fullSpanIndex + 2 * (AVG_ITEM_PER_VIEW - 1)); String log = mLayoutManager.layoutToString("post gap"); mLayoutManager.assertNoLayout("if an interim gap is fixed, it should not cause a " + "relayout " + log, 2); View fullSpan = mLayoutManager.findViewByPosition(fullSpanIndex); assertNotNull("full span item should be there:\n" + log, fullSpan); View view1 = mLayoutManager.findViewByPosition(fullSpanIndex + 1); assertNotNull("next view should be there\n" + log, view1); View view2 = mLayoutManager.findViewByPosition(fullSpanIndex + 2); assertNotNull("+2 view should be there\n" + log, view2); LayoutParams lp1 = (LayoutParams) view1.getLayoutParams(); LayoutParams lp2 = (LayoutParams) view2.getLayoutParams(); assertEquals("view 1 span index", 0, lp1.getSpanIndex()); assertEquals("view 2 span index", 1, lp2.getSpanIndex()); assertEquals("no gap between span and view 1", mLayoutManager.mPrimaryOrientation.getDecoratedEnd(fullSpan), mLayoutManager.mPrimaryOrientation.getDecoratedStart(view1)); assertEquals("no gap between span and view 2", mLayoutManager.mPrimaryOrientation.getDecoratedEnd(fullSpan), mLayoutManager.mPrimaryOrientation.getDecoratedStart(view2)); }
@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; }