private void bindViewHolderToThreadRow(DiscussionThreadViewHolder holder) {
    holder.authorLayoutViewHolder.populateViewHolder(
        config,
        discussionThread,
        discussionThread,
        initialTimeStampMs,
        new Runnable() {
          @Override
          public void run() {
            listener.onClickAuthor(discussionThread.getAuthor());
          }
        });

    holder.threadTitleTextView.setText(discussionThread.getTitle());

    holder.threadBodyTextView.setText(
        DiscussionTextUtils.parseHtml(discussionThread.getRenderedBody()));

    String groupName = discussionThread.getGroupName();
    if (groupName == null) {
      holder.threadVisibilityTextView.setText(R.string.discussion_post_visibility_everyone);
    } else {
      holder.threadVisibilityTextView.setText(
          ResourceUtil.getFormattedString(
              context.getResources(),
              R.string.discussion_post_visibility_cohort,
              "cohort",
              groupName));
    }

    bindSocialView(holder.socialLayoutViewHolder, discussionThread);

    bindNumberResponsesView(holder.numberResponsesViewHolder);

    holder.discussionReportViewHolder.reportLayout.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(final View v) {
            SetThreadFlaggedTask task =
                new SetThreadFlaggedTask(
                    context, discussionThread, !discussionThread.isAbuseFlagged()) {
                  @Override
                  public void onSuccess(DiscussionThread topicThread) {
                    super.onSuccess(topicThread);
                    discussionThread = topicThread;
                    notifyItemChanged(0);
                  }
                };
            task.setProgressCallback(null);
            task.execute();
          }
        });

    holder.discussionReportViewHolder.setReported(discussionThread.isAbuseFlagged());
  }
  @Override
  public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
    if (getItemViewType(position) == RowType.PROGRESS) return;
    final ResponseOrCommentViewHolder holder = (ResponseOrCommentViewHolder) viewHolder;
    final DiscussionComment discussionComment;
    final IconDrawable iconDrawable;
    if (position == 0) {
      discussionComment = response;

      DiscussionTextUtils.setEndorsedState(
          holder.authorLayoutViewHolder.answerTextView, thread, response);
      final int childCount = discussionComment.getChildCount();
      holder.discussionCommentCountReportTextView.setText(
          context
              .getResources()
              .getQuantityString(
                  R.plurals.number_responses_or_comments_comments_label, childCount, childCount));
      iconDrawable =
          new IconDrawable(context, FontAwesomeIcons.fa_comment)
              .sizeRes(context, R.dimen.edx_small)
              .colorRes(context, R.color.edx_brand_gray_base);
      holder.discussionCommentCountReportTextView.setOnClickListener(null);
      holder.discussionCommentCountReportTextView.setClickable(false);

    } else {
      holder.authorLayoutViewHolder.answerTextView.setVisibility(View.GONE);
      discussionComment = discussionComments.get(position - 1);

      iconDrawable =
          new IconDrawable(context, FontAwesomeIcons.fa_flag)
              .sizeRes(context, R.dimen.edx_small)
              .colorRes(
                  context,
                  discussionComment.isAbuseFlagged()
                      ? R.color.edx_brand_primary_base
                      : R.color.edx_brand_gray_base);
      holder.discussionCommentCountReportTextView.setText(
          discussionComment.isAbuseFlagged()
              ? context.getString(R.string.discussion_responses_reported_label)
              : context.getString(R.string.discussion_responses_report_label));
      holder.discussionCommentCountReportTextView.setTextColor(
          context.getResources().getColor(R.color.edx_brand_gray_base));

      holder.discussionCommentCountReportTextView.setOnClickListener(
          new View.OnClickListener() {
            public void onClick(final View v) {
              listener.reportComment(discussionComment);
            }
          });
    }

    holder.authorLayoutViewHolder.populateViewHolder(
        config,
        discussionComment,
        discussionComment,
        initialTimeStampMs,
        new Runnable() {
          @Override
          public void run() {
            listener.onClickAuthor(discussionComment.getAuthor());
          }
        });

    TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(
        holder.discussionCommentCountReportTextView, iconDrawable, null, null, null);

    DiscussionTextUtils.renderHtml(
        holder.discussionCommentBody, discussionComment.getRenderedBody());
  }
  private void bindViewHolderToResponseRow(
      DiscussionResponseViewHolder holder, final int position) {
    final DiscussionComment comment =
        discussionResponses.get(
            position - 1); // Subtract 1 for the discussion thread row at position 0

    holder.authorLayoutViewHolder.populateViewHolder(
        config,
        comment,
        comment,
        initialTimeStampMs,
        new Runnable() {
          @Override
          public void run() {
            listener.onClickAuthor(comment.getAuthor());
          }
        });

    if (comment.isEndorsed()) {
      holder.authorLayoutViewHolder.answerTextView.setVisibility(View.VISIBLE);
      holder.responseAnswerAuthorTextView.setVisibility(View.VISIBLE);
      DiscussionThread.ThreadType threadType = discussionThread.getType();
      DiscussionTextUtils.AuthorAttributionLabel authorAttributionLabel;
      @StringRes int endorsementTypeStringRes;
      switch (threadType) {
        case QUESTION:
          authorAttributionLabel = DiscussionTextUtils.AuthorAttributionLabel.ANSWER;
          endorsementTypeStringRes = R.string.discussion_responses_answer;
          break;
        case DISCUSSION:
        default:
          authorAttributionLabel = DiscussionTextUtils.AuthorAttributionLabel.ENDORSEMENT;
          endorsementTypeStringRes = R.string.discussion_responses_endorsed;
          break;
      }
      holder.authorLayoutViewHolder.answerTextView.setText(endorsementTypeStringRes);
      DiscussionTextUtils.setAuthorAttributionText(
          holder.responseAnswerAuthorTextView,
          authorAttributionLabel,
          comment.getEndorserData(),
          initialTimeStampMs,
          new Runnable() {
            @Override
            public void run() {
              listener.onClickAuthor(comment.getEndorsedBy());
            }
          });
    } else {
      holder.authorLayoutViewHolder.answerTextView.setVisibility(View.GONE);
      holder.responseAnswerAuthorTextView.setVisibility(View.GONE);
    }

    holder.responseCommentBodyTextView.setText(
        DiscussionTextUtils.parseHtml(comment.getRenderedBody()));

    if (discussionThread.isClosed() && comment.getChildCount() == 0) {
      holder.addCommentLayout.setEnabled(false);
    } else {
      holder.addCommentLayout.setEnabled(true);
      holder.addCommentLayout.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (comment.getChildCount() > 0) {
                listener.onClickViewComments(comment);
              } else {
                listener.onClickAddComment(comment);
              }
            }
          });
    }

    bindNumberCommentsView(holder.numberResponsesViewHolder, comment);
    bindSocialView(holder.socialLayoutViewHolder, position, comment);

    holder.discussionReportViewHolder.reportLayout.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(final View v) {
            SetCommentFlaggedTask task =
                new SetCommentFlaggedTask(context, comment, !comment.isAbuseFlagged()) {
                  @Override
                  public void onSuccess(DiscussionComment comment) {
                    super.onSuccess(comment);
                    discussionResponses.set(position - 1, comment);
                    notifyItemChanged(position);
                  }
                };
            task.setProgressCallback(null);
            task.execute();
          }
        });

    holder.discussionReportViewHolder.setReported(comment.isAbuseFlagged());

    holder.socialLayoutViewHolder.threadFollowContainer.setVisibility(View.INVISIBLE);
  }