/** * finds the int ItemViewType from the IItem which exists at the given position * * @param position the global position * @return the viewType for this position */ @Override public int getItemViewType(int position) { return getItem(position).getType(); }
/** * 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); }
/** * overwrite the getItemViewType to correctly return the value from the FastAdapter * * @param position * @return */ @Override public int getItemViewType(int position) { if (shouldInsertItemAtPosition(position)) { return getItem(position).getType(); } else { return mAdapter.getItemViewType(position - itemInsertedBeforeCount(position)); } }