public abstract static class RecyclerView.ViewCacheExtension extends Object
When RecyclerView.Recycler.getViewForPosition(int)
is called, Recycler checks attached scrap and
first level cache to find a matching View. If it cannot find a suitable View, Recycler will
call the #getViewForPositionAndType(Recycler, int, int)
before checking
RecyclerView.RecycledViewPool
.
Note that, Recycler never sends Views to this method to be cached. It is developers responsibility to decide whether they want to keep their Views in this custom cache or let the default recycling policy handle it.
Constructor and Description |
---|
ViewCacheExtension() |
Modifier and Type | Method and Description |
---|---|
abstract View |
getViewForPositionAndType(RecyclerView.Recycler recycler,
int position,
int type)
Returns a View that can be binded to the given Adapter position.
|
public abstract View getViewForPositionAndType(RecyclerView.Recycler recycler, int position, int type)
This method should not create a new View. Instead, it is expected to return
an already created View that can be re-used for the given type and position.
If the View is marked as ignored, it should first call
RecyclerView.LayoutManager.stopIgnoringView(View)
before returning the View.
RecyclerView will re-bind the returned View to the position if necessary.
recycler
- The Recycler that can be used to bind the Viewposition
- The adapter positiontype
- The type of the View, defined by adapterRecyclerView.LayoutManager.ignoreView(View)