@Test public void getItemResourceFromType_header1() { assertEquals( R.layout.article_item_header_1, adapter.getItemResourceFromType(ArticleAdapter.TYPE_HEADER_1)); }
@VisibleForTesting int getItemResourceFromType(int viewType) { switch (viewType) { case TYPE_HEADER_IMAGE: return R.layout.article_item_header; case TYPE_TITLE: return R.layout.article_item_title; case TYPE_PARAGRAPH: return R.layout.article_item_paragraph; case TYPE_INLINE_IMAGE: return R.layout.article_item_image; case TYPE_HEADER_1: return R.layout.article_item_header_1; case TYPE_HEADER_2: return R.layout.article_item_header_2; case TYPE_HEADER_3: return R.layout.article_item_header_3; case TYPE_HEADER_4: return R.layout.article_item_header_4; case TYPE_HEADER_5: return R.layout.article_item_header_5; case TYPE_HEADER_6: return R.layout.article_item_header_6; case TYPE_BLOCKQUOTE: return R.layout.article_item_blockquote; case TYPE_PRE: return R.layout.article_item_pre; case TYPE_UNORDERED_LIST_ITEM: return R.layout.article_item_unordered_list_item; case TYPE_ORDERED_LIST_ITEM: return R.layout.article_item_ordered_list_item; default: return R.layout.article_item_other; } }
ArticleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { @VisibleForTesting int getItemResourceFromType(int viewType) { switch (viewType) { case TYPE_HEADER_IMAGE: return R.layout.article_item_header; case TYPE_TITLE: return R.layout.article_item_title; case TYPE_PARAGRAPH: return R.layout.article_item_paragraph; case TYPE_INLINE_IMAGE: return R.layout.article_item_image; case TYPE_HEADER_1: return R.layout.article_item_header_1; case TYPE_HEADER_2: return R.layout.article_item_header_2; case TYPE_HEADER_3: return R.layout.article_item_header_3; case TYPE_HEADER_4: return R.layout.article_item_header_4; case TYPE_HEADER_5: return R.layout.article_item_header_5; case TYPE_HEADER_6: return R.layout.article_item_header_6; case TYPE_BLOCKQUOTE: return R.layout.article_item_blockquote; case TYPE_PRE: return R.layout.article_item_pre; case TYPE_UNORDERED_LIST_ITEM: return R.layout.article_item_unordered_list_item; case TYPE_ORDERED_LIST_ITEM: return R.layout.article_item_ordered_list_item; default: return R.layout.article_item_other; } } }
ArticleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { @VisibleForTesting int getItemResourceFromType(int viewType) { switch (viewType) { case TYPE_HEADER_IMAGE: return R.layout.article_item_header; case TYPE_TITLE: return R.layout.article_item_title; case TYPE_PARAGRAPH: return R.layout.article_item_paragraph; case TYPE_INLINE_IMAGE: return R.layout.article_item_image; case TYPE_HEADER_1: return R.layout.article_item_header_1; case TYPE_HEADER_2: return R.layout.article_item_header_2; case TYPE_HEADER_3: return R.layout.article_item_header_3; case TYPE_HEADER_4: return R.layout.article_item_header_4; case TYPE_HEADER_5: return R.layout.article_item_header_5; case TYPE_HEADER_6: return R.layout.article_item_header_6; case TYPE_BLOCKQUOTE: return R.layout.article_item_blockquote; case TYPE_PRE: return R.layout.article_item_pre; case TYPE_UNORDERED_LIST_ITEM: return R.layout.article_item_unordered_list_item; case TYPE_ORDERED_LIST_ITEM: return R.layout.article_item_ordered_list_item; default: return R.layout.article_item_other; } } ArticleAdapter(Article article, int accentColor, int textSize, int theme); }
ArticleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { @VisibleForTesting int getItemResourceFromType(int viewType) { switch (viewType) { case TYPE_HEADER_IMAGE: return R.layout.article_item_header; case TYPE_TITLE: return R.layout.article_item_title; case TYPE_PARAGRAPH: return R.layout.article_item_paragraph; case TYPE_INLINE_IMAGE: return R.layout.article_item_image; case TYPE_HEADER_1: return R.layout.article_item_header_1; case TYPE_HEADER_2: return R.layout.article_item_header_2; case TYPE_HEADER_3: return R.layout.article_item_header_3; case TYPE_HEADER_4: return R.layout.article_item_header_4; case TYPE_HEADER_5: return R.layout.article_item_header_5; case TYPE_HEADER_6: return R.layout.article_item_header_6; case TYPE_BLOCKQUOTE: return R.layout.article_item_blockquote; case TYPE_PRE: return R.layout.article_item_pre; case TYPE_UNORDERED_LIST_ITEM: return R.layout.article_item_unordered_list_item; case TYPE_ORDERED_LIST_ITEM: return R.layout.article_item_ordered_list_item; default: return R.layout.article_item_other; } } ArticleAdapter(Article article, int accentColor, int textSize, int theme); @Override RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType); @Override void onBindViewHolder(RecyclerView.ViewHolder holder, int position); @Override int getItemViewType(int position); @Override int getItemCount(); @Override void onAttachedToRecyclerView(RecyclerView recyclerView); }
ArticleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { @VisibleForTesting int getItemResourceFromType(int viewType) { switch (viewType) { case TYPE_HEADER_IMAGE: return R.layout.article_item_header; case TYPE_TITLE: return R.layout.article_item_title; case TYPE_PARAGRAPH: return R.layout.article_item_paragraph; case TYPE_INLINE_IMAGE: return R.layout.article_item_image; case TYPE_HEADER_1: return R.layout.article_item_header_1; case TYPE_HEADER_2: return R.layout.article_item_header_2; case TYPE_HEADER_3: return R.layout.article_item_header_3; case TYPE_HEADER_4: return R.layout.article_item_header_4; case TYPE_HEADER_5: return R.layout.article_item_header_5; case TYPE_HEADER_6: return R.layout.article_item_header_6; case TYPE_BLOCKQUOTE: return R.layout.article_item_blockquote; case TYPE_PRE: return R.layout.article_item_pre; case TYPE_UNORDERED_LIST_ITEM: return R.layout.article_item_unordered_list_item; case TYPE_ORDERED_LIST_ITEM: return R.layout.article_item_ordered_list_item; default: return R.layout.article_item_other; } } ArticleAdapter(Article article, int accentColor, int textSize, int theme); @Override RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType); @Override void onBindViewHolder(RecyclerView.ViewHolder holder, int position); @Override int getItemViewType(int position); @Override int getItemCount(); @Override void onAttachedToRecyclerView(RecyclerView recyclerView);  }