RecyclerView.Recycler

A Recycler is responsible for managing scrapped or detached item views for reuse.

A "scrapped" view is a view that is still attached to its parent RecyclerView but
that has been marked for removal or reuse.

Typical use of a Recycler by a RecyclerView.LayoutManager will be to obtain views for
an adapter's data set representing the data at a given position or item ID.
If the view to be reused is considered "dirty" the adapter will be asked to rebind it.
If not, the view can be quickly reused by the LayoutManager with no further work.
Clean views that have not requested layout
may be repositioned by a LayoutManager without remeasurement.

Generally, a LayoutManager should acquire its views via getViewForPosition(int)
and let the RecyclerView handle caching. This is a helper method for LayoutManager who
wants to handle its own recycling logic.

Note that, getViewForPosition(int) already binds the View to the position so
you don't need to call this method unless you want to bind this View to another position.

Parameters

view

View: The view to update.

position

int: The position of the item to bind to this View.

clear

public void clear ()

Clear scrap views out of this recycler. Detached views contained within a
recycled view pool will remain.

Usually, LayoutManager does not need to worry about this. However, in some cases, your
LayoutManager may need to call some custom component with item positions in which
case you need the actual adapter position instead of the pre layout position. You
can use this method to convert a pre-layout position to adapter (post layout) position.

Note that if the provided position belongs to a deleted ViewHolder, this method will
return -1.

The Recycler may reuse a scrap or detached view from a shared pool if one is
available for the correct view type. If the adapter has not indicated that the
data at the given position has changed, the Recycler will attempt to hand back
a scrap view that was previously initialized for that data without rebinding.