@Test public void onCreateViewHolder_blockquote() { assertTrue( adapter.onCreateViewHolder(generateViewGroup(), ArticleAdapter.TYPE_BLOCKQUOTE) instanceof ArticleAdapter.BlockQuoteViewHolder); }
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); View view = LayoutInflater.from(context) .inflate(getItemResourceFromType(viewType), parent, false); switch (viewType) { case TYPE_HEADER_IMAGE: return new HeaderImageViewHolder(view); case TYPE_TITLE: return new TitleTextViewHolder(view, accentColor); case TYPE_INLINE_IMAGE: return new ImageViewHolder(view); case TYPE_BLOCKQUOTE: return new BlockQuoteViewHolder(view, accentColor); case TYPE_HEADER_1: case TYPE_HEADER_2: case TYPE_HEADER_3: case TYPE_HEADER_4: case TYPE_HEADER_5: case TYPE_HEADER_6: return new SubtitleTextViewHolder(view, accentColor); case TYPE_UNORDERED_LIST_ITEM: case TYPE_ORDERED_LIST_ITEM: case TYPE_PARAGRAPH: case TYPE_PRE: default: return new TextViewHolder(view, accentColor); } }
ArticleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); View view = LayoutInflater.from(context) .inflate(getItemResourceFromType(viewType), parent, false); switch (viewType) { case TYPE_HEADER_IMAGE: return new HeaderImageViewHolder(view); case TYPE_TITLE: return new TitleTextViewHolder(view, accentColor); case TYPE_INLINE_IMAGE: return new ImageViewHolder(view); case TYPE_BLOCKQUOTE: return new BlockQuoteViewHolder(view, accentColor); case TYPE_HEADER_1: case TYPE_HEADER_2: case TYPE_HEADER_3: case TYPE_HEADER_4: case TYPE_HEADER_5: case TYPE_HEADER_6: return new SubtitleTextViewHolder(view, accentColor); case TYPE_UNORDERED_LIST_ITEM: case TYPE_ORDERED_LIST_ITEM: case TYPE_PARAGRAPH: case TYPE_PRE: default: return new TextViewHolder(view, accentColor); } } }
ArticleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); View view = LayoutInflater.from(context) .inflate(getItemResourceFromType(viewType), parent, false); switch (viewType) { case TYPE_HEADER_IMAGE: return new HeaderImageViewHolder(view); case TYPE_TITLE: return new TitleTextViewHolder(view, accentColor); case TYPE_INLINE_IMAGE: return new ImageViewHolder(view); case TYPE_BLOCKQUOTE: return new BlockQuoteViewHolder(view, accentColor); case TYPE_HEADER_1: case TYPE_HEADER_2: case TYPE_HEADER_3: case TYPE_HEADER_4: case TYPE_HEADER_5: case TYPE_HEADER_6: return new SubtitleTextViewHolder(view, accentColor); case TYPE_UNORDERED_LIST_ITEM: case TYPE_ORDERED_LIST_ITEM: case TYPE_PARAGRAPH: case TYPE_PRE: default: return new TextViewHolder(view, accentColor); } } ArticleAdapter(Article article, int accentColor, int textSize, int theme); }
ArticleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); View view = LayoutInflater.from(context) .inflate(getItemResourceFromType(viewType), parent, false); switch (viewType) { case TYPE_HEADER_IMAGE: return new HeaderImageViewHolder(view); case TYPE_TITLE: return new TitleTextViewHolder(view, accentColor); case TYPE_INLINE_IMAGE: return new ImageViewHolder(view); case TYPE_BLOCKQUOTE: return new BlockQuoteViewHolder(view, accentColor); case TYPE_HEADER_1: case TYPE_HEADER_2: case TYPE_HEADER_3: case TYPE_HEADER_4: case TYPE_HEADER_5: case TYPE_HEADER_6: return new SubtitleTextViewHolder(view, accentColor); case TYPE_UNORDERED_LIST_ITEM: case TYPE_ORDERED_LIST_ITEM: case TYPE_PARAGRAPH: case TYPE_PRE: default: return new TextViewHolder(view, accentColor); } } 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> { @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); View view = LayoutInflater.from(context) .inflate(getItemResourceFromType(viewType), parent, false); switch (viewType) { case TYPE_HEADER_IMAGE: return new HeaderImageViewHolder(view); case TYPE_TITLE: return new TitleTextViewHolder(view, accentColor); case TYPE_INLINE_IMAGE: return new ImageViewHolder(view); case TYPE_BLOCKQUOTE: return new BlockQuoteViewHolder(view, accentColor); case TYPE_HEADER_1: case TYPE_HEADER_2: case TYPE_HEADER_3: case TYPE_HEADER_4: case TYPE_HEADER_5: case TYPE_HEADER_6: return new SubtitleTextViewHolder(view, accentColor); case TYPE_UNORDERED_LIST_ITEM: case TYPE_ORDERED_LIST_ITEM: case TYPE_PARAGRAPH: case TYPE_PRE: default: return new TextViewHolder(view, accentColor); } } 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);  }