Anatomy of RecyclerView: a Search for a ViewHolder

Intro

RecycledViewPool

public static class RecycledViewPool {    private SparseArray<ArrayList<ViewHolder>> mScrap =                   new SparseArray<>();    private SparseIntArray mMaxScrap = new SparseIntArray();    public ViewHolder getRecycledView(int viewType) {        ArrayList<ViewHolder> scrapHeap = mScrap.get(viewType);
recyclerView.getRecycledViewPool()
.setMaxRecycledViews(SOME_VIEW_TYPE, POOL_CAPACITY);

Offtopic: pre-layout, post-layout and predictive animations

RecycledViewPool, continued

View Cache

Pool and Cache in Action

recyclerView.getRecycledViewPool().setMaxRecycledViews(0, 20);adapter.notifyDataSetChanged();new Handler().post(new Runnable() {    @Override    public void run() {        recyclerView.getRecycledViewPool()
.setMaxRecycledViews(0, 1);
}});

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store