@Override protected void bind(final ItemViewHolder holder, final Item item) { super.bind(holder, item); if (item == null) { return; } holder.mPostedTextView.setText(item.getDisplayedTime(mContext, false, true)); if (item.getKidCount() > 0) { holder.mCommentButton.setText( mContext .getResources() .getQuantityString(R.plurals.comments_count, item.getKidCount(), item.getKidCount())); holder.mCommentButton.setVisibility(View.VISIBLE); holder.mCommentButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { openItem(item); } }); } }
@Override protected void bind(SubmissionViewHolder holder, final Item item) { super.bind(holder, item); holder.mPostedTextView.setText( item.getDisplayedTime(mContext, false, !TextUtils.equals(item.getBy(), mUsername))); holder.mMoreButton.setVisibility(View.GONE); if (TextUtils.equals(item.getType(), Item.COMMENT_TYPE)) { holder.mTitleTextView.setText(null); holder.itemView.setOnClickListener(null); holder.mCommentButton.setVisibility(View.GONE); } else { holder.mTitleTextView.setText(item.getDisplayedTitle()); holder.mCommentButton.setVisibility(View.VISIBLE); holder.mCommentButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { openItem(item); } }); } holder.mTitleTextView.setVisibility( holder.mTitleTextView.length() > 0 ? View.VISIBLE : View.GONE); holder.mContentTextView.setVisibility( holder.mContentTextView.length() > 0 ? View.VISIBLE : View.GONE); if (!mExpanded.contains(item.getId()) && item.getParentItem() != null) { mExpanded.add(item.getId()); new Handler() .post( new Runnable() { @Override public void run() { mItems.add(0, item.getParentItem()); // recursive notifyItemRangeChanged(1, mItems.size()); notifyItemInserted(0); } }); } }
public ThreadPreviewRecyclerViewAdapter(ItemManager itemManager, Item item) { super(itemManager); mItems.add(item); mUsername = item.getBy(); }