Program: 14378
Project: 14378
Buggy source:
@Override public void onBindViewHolder(NoteViewHolder noteViewHolder,Cursor cursor){
  final Bucket.ObjectCursor<Note> objectCursor=(Bucket.ObjectCursor<Note>)cursor;
  noteViewHolder.noteId=objectCursor.getSimperiumKey();
  Note.NoteTimeGroup timeGroup=Note.getTimeGroupForTimestamp(getLongForColumnName(objectCursor,Note.Schema.TIMESTAMP_INDEX));
  Note.NoteTimeGroup previousTimeGroup=null;
  if (objectCursor.getPosition() > 0 && objectCursor.moveToPrevious()) {
    previousTimeGroup=Note.getTimeGroupForTimestamp(getLongForColumnName(objectCursor,Note.Schema.TIMESTAMP_INDEX));
    objectCursor.moveToNext();
  }
  if (previousTimeGroup != null && previousTimeGroup == timeGroup) {
    noteViewHolder.headerView.setVisibility(View.GONE);
  }
 else {
    if (timeGroup == Note.NoteTimeGroup.GROUP_TODAY) {
      noteViewHolder.headerText.setText(mContext.getString(R.string.stats_timeframe_today).toUpperCase());
    }
 else     if (timeGroup == Note.NoteTimeGroup.GROUP_YESTERDAY) {
      noteViewHolder.headerText.setText(mContext.getString(R.string.stats_timeframe_yesterday).toUpperCase());
    }
 else     if (timeGroup == Note.NoteTimeGroup.GROUP_OLDER_TWO_DAYS) {
      noteViewHolder.headerText.setText(mContext.getString(R.string.older_two_days).toUpperCase());
    }
 else     if (timeGroup == Note.NoteTimeGroup.GROUP_OLDER_WEEK) {
      noteViewHolder.headerText.setText(mContext.getString(R.string.older_last_week).toUpperCase());
    }
 else {
      noteViewHolder.headerText.setText(mContext.getString(R.string.older_month).toUpperCase());
    }
    noteViewHolder.headerView.setVisibility(View.VISIBLE);
  }
  if (mHiddenNoteIds.size() > 0 && mHiddenNoteIds.contains(objectCursor.getSimperiumKey())) {
    noteViewHolder.contentView.setVisibility(View.GONE);
    noteViewHolder.headerView.setVisibility(View.GONE);
  }
 else {
    noteViewHolder.contentView.setVisibility(View.VISIBLE);
  }
  CommentStatus commentStatus=CommentStatus.UNKNOWN;
  if (SqlUtils.sqlToBool(getIntForColumnName(objectCursor,Note.Schema.IS_UNAPPROVED_INDEX))) {
    commentStatus=CommentStatus.UNAPPROVED;
  }
  String localStatus=getStringForColumnName(objectCursor,Note.Schema.LOCAL_STATUS);
  if (!TextUtils.isEmpty(localStatus)) {
    commentStatus=CommentStatus.fromString(localStatus);
  }
  if (mModeratingNoteIds.size() > 0 && mModeratingNoteIds.contains(objectCursor.getSimperiumKey())) {
    noteViewHolder.progressBar.setVisibility(View.VISIBLE);
  }
 else {
    noteViewHolder.progressBar.setVisibility(View.GONE);
  }
  String noteSubjectHtml=getStringForColumnName(objectCursor,Note.Schema.SUBJECT_INDEX).trim();
  CharSequence noteSubjectSpanned=Html.fromHtml(noteSubjectHtml);
  noteSubjectSpanned=noteSubjectSpanned.subSequence(0,TextUtils.getTrimmedLength(noteSubjectSpanned));
  noteViewHolder.txtSubject.setText(noteSubjectSpanned);
  String noteSubjectNoticon=getStringForColumnName(objectCursor,Note.Schema.COMMENT_SUBJECT_NOTICON);
  if (!TextUtils.isEmpty(noteSubjectNoticon)) {
    CommentUtils.indentTextViewFirstLine(noteViewHolder.txtSubject,DisplayUtils.dpToPx(mContext,22));
    noteViewHolder.txtSubjectNoticon.setText(noteSubjectNoticon);
    noteViewHolder.txtSubjectNoticon.setVisibility(View.VISIBLE);
  }
 else {
    noteViewHolder.txtSubjectNoticon.setVisibility(View.GONE);
  }
  String noteSnippet=getStringForColumnName(objectCursor,Note.Schema.SNIPPET_INDEX);
  if (!TextUtils.isEmpty(noteSnippet)) {
    noteViewHolder.txtSubject.setMaxLines(2);
    noteViewHolder.txtDetail.setText(noteSnippet);
    noteViewHolder.txtDetail.setVisibility(View.VISIBLE);
  }
 else {
    noteViewHolder.txtSubject.setMaxLines(3);
    noteViewHolder.txtDetail.setVisibility(View.GONE);
  }
  String avatarUrl=GravatarUtils.fixGravatarUrl(getStringForColumnName(objectCursor,Note.Schema.ICON_URL_INDEX),mAvatarSz);
  noteViewHolder.imgAvatar.setImageUrl(avatarUrl,WPNetworkImageView.ImageType.AVATAR);
  boolean isUnread=SqlUtils.sqlToBool(getIntForColumnName(objectCursor,Note.Schema.UNREAD_INDEX));
  String noticonCharacter=getStringForColumnName(objectCursor,Note.Schema.NOTICON_INDEX);
  if (!TextUtils.isEmpty(noticonCharacter)) {
    noteViewHolder.noteIcon.setText(noticonCharacter);
    if (commentStatus == CommentStatus.UNAPPROVED) {
      noteViewHolder.noteIcon.setBackgroundResource(R.drawable.shape_oval_orange);
    }
 else     if (isUnread) {
      noteViewHolder.noteIcon.setBackgroundResource(R.drawable.shape_oval_blue_white_stroke);
    }
 else {
      noteViewHolder.noteIcon.setBackgroundResource(R.drawable.shape_oval_grey);
    }
    noteViewHolder.noteIcon.setVisibility(View.VISIBLE);
  }
 else {
    noteViewHolder.noteIcon.setVisibility(View.GONE);
  }
  if (isUnread) {
    noteViewHolder.itemView.setBackgroundResource(mUnreadBackgroundResId);
  }
 else {
    noteViewHolder.itemView.setBackgroundResource(mReadBackgroundResId);
  }
}

Fixed version (ground truth):
@Override public void onBindViewHolder(NoteViewHolder noteViewHolder,Cursor cursor){
  final Bucket.ObjectCursor<Note> objectCursor=(Bucket.ObjectCursor<Note>)cursor;
  final String noteId=objectCursor.getSimperiumKey();
  Note.NoteTimeGroup timeGroup=Note.getTimeGroupForTimestamp(getLongForColumnName(objectCursor,Note.Schema.TIMESTAMP_INDEX));
  Note.NoteTimeGroup previousTimeGroup=null;
  if (objectCursor.getPosition() > 0 && objectCursor.moveToPrevious()) {
    previousTimeGroup=Note.getTimeGroupForTimestamp(getLongForColumnName(objectCursor,Note.Schema.TIMESTAMP_INDEX));
    objectCursor.moveToNext();
  }
  if (previousTimeGroup != null && previousTimeGroup == timeGroup) {
    noteViewHolder.headerView.setVisibility(View.GONE);
  }
 else {
    if (timeGroup == Note.NoteTimeGroup.GROUP_TODAY) {
      noteViewHolder.headerText.setText(mContext.getString(R.string.stats_timeframe_today).toUpperCase());
    }
 else     if (timeGroup == Note.NoteTimeGroup.GROUP_YESTERDAY) {
      noteViewHolder.headerText.setText(mContext.getString(R.string.stats_timeframe_yesterday).toUpperCase());
    }
 else     if (timeGroup == Note.NoteTimeGroup.GROUP_OLDER_TWO_DAYS) {
      noteViewHolder.headerText.setText(mContext.getString(R.string.older_two_days).toUpperCase());
    }
 else     if (timeGroup == Note.NoteTimeGroup.GROUP_OLDER_WEEK) {
      noteViewHolder.headerText.setText(mContext.getString(R.string.older_last_week).toUpperCase());
    }
 else {
      noteViewHolder.headerText.setText(mContext.getString(R.string.older_month).toUpperCase());
    }
    noteViewHolder.headerView.setVisibility(View.VISIBLE);
  }
  if (mHiddenNoteIds.size() > 0 && mHiddenNoteIds.contains(objectCursor.getSimperiumKey())) {
    noteViewHolder.contentView.setVisibility(View.GONE);
    noteViewHolder.headerView.setVisibility(View.GONE);
  }
 else {
    noteViewHolder.contentView.setVisibility(View.VISIBLE);
  }
  CommentStatus commentStatus=CommentStatus.UNKNOWN;
  if (SqlUtils.sqlToBool(getIntForColumnName(objectCursor,Note.Schema.IS_UNAPPROVED_INDEX))) {
    commentStatus=CommentStatus.UNAPPROVED;
  }
  String localStatus=getStringForColumnName(objectCursor,Note.Schema.LOCAL_STATUS);
  if (!TextUtils.isEmpty(localStatus)) {
    commentStatus=CommentStatus.fromString(localStatus);
  }
  if (mModeratingNoteIds.size() > 0 && mModeratingNoteIds.contains(objectCursor.getSimperiumKey())) {
    noteViewHolder.progressBar.setVisibility(View.VISIBLE);
  }
 else {
    noteViewHolder.progressBar.setVisibility(View.GONE);
  }
  String noteSubjectHtml=getStringForColumnName(objectCursor,Note.Schema.SUBJECT_INDEX).trim();
  CharSequence noteSubjectSpanned=Html.fromHtml(noteSubjectHtml);
  noteSubjectSpanned=noteSubjectSpanned.subSequence(0,TextUtils.getTrimmedLength(noteSubjectSpanned));
  noteViewHolder.txtSubject.setText(noteSubjectSpanned);
  String noteSubjectNoticon=getStringForColumnName(objectCursor,Note.Schema.COMMENT_SUBJECT_NOTICON);
  if (!TextUtils.isEmpty(noteSubjectNoticon)) {
    CommentUtils.indentTextViewFirstLine(noteViewHolder.txtSubject,DisplayUtils.dpToPx(mContext,22));
    noteViewHolder.txtSubjectNoticon.setText(noteSubjectNoticon);
    noteViewHolder.txtSubjectNoticon.setVisibility(View.VISIBLE);
  }
 else {
    noteViewHolder.txtSubjectNoticon.setVisibility(View.GONE);
  }
  String noteSnippet=getStringForColumnName(objectCursor,Note.Schema.SNIPPET_INDEX);
  if (!TextUtils.isEmpty(noteSnippet)) {
    noteViewHolder.txtSubject.setMaxLines(2);
    noteViewHolder.txtDetail.setText(noteSnippet);
    noteViewHolder.txtDetail.setVisibility(View.VISIBLE);
  }
 else {
    noteViewHolder.txtSubject.setMaxLines(3);
    noteViewHolder.txtDetail.setVisibility(View.GONE);
  }
  String avatarUrl=GravatarUtils.fixGravatarUrl(getStringForColumnName(objectCursor,Note.Schema.ICON_URL_INDEX),mAvatarSz);
  noteViewHolder.imgAvatar.setImageUrl(avatarUrl,WPNetworkImageView.ImageType.AVATAR);
  boolean isUnread=SqlUtils.sqlToBool(getIntForColumnName(objectCursor,Note.Schema.UNREAD_INDEX));
  String noticonCharacter=getStringForColumnName(objectCursor,Note.Schema.NOTICON_INDEX);
  if (!TextUtils.isEmpty(noticonCharacter)) {
    noteViewHolder.noteIcon.setText(noticonCharacter);
    if (commentStatus == CommentStatus.UNAPPROVED) {
      noteViewHolder.noteIcon.setBackgroundResource(R.drawable.shape_oval_orange);
    }
 else     if (isUnread) {
      noteViewHolder.noteIcon.setBackgroundResource(R.drawable.shape_oval_blue_white_stroke);
    }
 else {
      noteViewHolder.noteIcon.setBackgroundResource(R.drawable.shape_oval_grey);
    }
    noteViewHolder.noteIcon.setVisibility(View.VISIBLE);
  }
 else {
    noteViewHolder.noteIcon.setVisibility(View.GONE);
  }
  if (isUnread) {
    noteViewHolder.itemView.setBackgroundResource(mUnreadBackgroundResId);
  }
 else {
    noteViewHolder.itemView.setBackgroundResource(mReadBackgroundResId);
  }
  noteViewHolder.itemView.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      if (mOnNoteClickListener != null && noteId != null) {
        mOnNoteClickListener.onClickNote(noteId);
      }
    }
  }
);
}