public class SpanSizeLookup
extends GridLayoutManager.SpanSizeLookup
GridLayoutManager.SpanSizeLookup
. This exposes an package-private
method as public method used inside the library.
Also it adds caching for GridLayoutManager.SpanSizeLookup#getSpanGroupIndex(int, int)
method. This method os called often by the library hence the caching.Constructor and Description |
---|
SpanSizeLookup(Cache cache)
Constructor to initialize the SpanSizeLookup class.
|
Modifier and Type | Method and Description |
---|---|
void |
clearCache()
When the adapter's data set changes, this method will be called to clear the cache.
|
int |
getCachedSpanIndex(int position,
int spanCount) |
int |
getSpanGroupIndex(int adapterPosition,
int spanCount)
Returns the index of the group this position belongs.
|
int |
getSpanSize(int adapterPosition) |
void |
setAdapter(MultiViewAdapter multiViewAdapter)
Attach the adapter to the SpanSizeLookup
|
public SpanSizeLookup(Cache cache)
public void clearCache()
public void setAdapter(MultiViewAdapter multiViewAdapter)
multiViewAdapter
- Adapter to be attachedpublic int getSpanSize(int adapterPosition)
public int getCachedSpanIndex(int position, int spanCount)
public int getSpanGroupIndex(int adapterPosition, int spanCount)
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.
adapterPosition
- The position in adapterspanCount
- The total number of spans in the grid