added in version 22.1.0
belongs to Maven artifact com.android.support:recyclerview-v7:28.0.0-alpha1

GridLayoutManager.SpanSizeLookup

public static abstract class GridLayoutManager.SpanSizeLookup
extends Object

java.lang.Object
   ↳ android.support.v7.widget.GridLayoutManager.SpanSizeLookup
Known Direct Subclasses


A helper class to provide the number of spans each item occupies.

Default implementation sets each item to occupy exactly 1 span.

Summary

Public constructors

GridLayoutManager.SpanSizeLookup()

Public methods

int getSpanGroupIndex(int adapterPosition, int spanCount)

Returns the index of the group this position belongs.

int getSpanIndex(int position, int spanCount)

Returns the final span index of the provided position.

abstract int getSpanSize(int position)

Returns the number of span occupied by the item at position.

void invalidateSpanIndexCache()

Clears the span index cache.

boolean isSpanIndexCacheEnabled()

Returns whether results of getSpanIndex(int, int) method are cached or not.

void setSpanIndexCacheEnabled(boolean cacheSpanIndices)

Sets whether the results of getSpanIndex(int, int) method should be cached or not.

Inherited methods

From class java.lang.Object

Public constructors

GridLayoutManager.SpanSizeLookup

added in version 22.1.0
GridLayoutManager.SpanSizeLookup ()

Public methods

getSpanGroupIndex

added in version 22.1.0
int getSpanGroupIndex (int adapterPosition, 
                int spanCount)

Returns the index of the group this position belongs.

For example, if grid has 3 columns and each item occupies 1 span, span group index for item 1 will be 0, item 5 will be 1.

Parameters
adapterPosition int: The position in adapter

spanCount int: The total number of spans in the grid

Returns
int The index of the span group including the item at the given adapter position

getSpanIndex

added in version 22.1.0
int getSpanIndex (int position, 
                int spanCount)

Returns the final span index of the provided position.

If you have a faster way to calculate span index for your items, you should override this method. Otherwise, you should enable span index cache (