Using the factory with the RecyclerView
As we saw briefly earlier in the book, RecyclerViews make use of an internal LayoutManager. This in turn communicates with the data set by use of an adapter. These adapters serve exactly the same function as the adapter design pattern we explored earlier in the book. The function may not appear so readily apparent, but it acts as a connection between a dataset and a recycler view's layout manager. The adapter crosses this bridge with its ViewHolder. The workings of the adapter are neatly separated from the client code, and all we need are a few lines to create a new adapter and layout manager.
With this in mind and our data ready, we can quickly put an adapter together by following these simple steps:
Begin by creating this new class in your main package:
public class DataAdapter extends RecyclerView.Adapter<DataAdapter.ViewHolder> {
It requires the following field and constructor:
private List<Cheese> cheeses; public DataAdapter...