/** * is called inside the onCreateViewHolder method and creates the viewHolder based on the provided viewTyp * * @param parent the parent which will host the View * @param viewType the type of the ViewHolder we want to create * @return the generated ViewHolder based on the given viewType */ @Override public RecyclerView.ViewHolder onPreCreateViewHolder(FastAdapter<Item> fastAdapter, ViewGroup parent, int viewType) { return fastAdapter.getTypeInstance(viewType).getViewHolder(parent); }
/** * the onCreateViewHolder is managed by the FastAdapter so forward this correctly * * @param parent * @param viewType * @return */ @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { //TODO OPTIMIZE for (Item item : mItems) { if (item.getType() == viewType) { return item.getViewHolder(parent); } } return mAdapter.onCreateViewHolder(parent, viewType); }