BaseHeaderAdapter extends RecyclerView.Adapter<BaseRecyclerViewHolder> { @Override @ViewType public int getItemViewType(int position) { if (isPositionHeader(position)) { return TYPE_HEADER; } return TYPE_ITEM; }  @Override BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType); @Override void onBindViewHolder(BaseRecyclerViewHolder holder, int position); @Override int getItemCount(); @Override @ViewType int getItemViewType(int position); void updateItems(List<I> items); void updateItems(List<I> items, H headerData); void updateItems(List<I> items, H headerData, boolean hasHeader);  }
@Test public void should_return_viewtype_header_if_so() { adapter.mHasHeader = true; int viewType = adapter.getItemViewType(0); assertThat(viewType).isEqualTo(BaseHeaderAdapter.TYPE_HEADER); }
@Test public void should_return_viewtype_item_if_so() { adapter.mHasHeader = false; int viewType = adapter.getItemViewType(0); assertThat(viewType).isEqualTo(BaseHeaderAdapter.TYPE_ITEM); }