Program: 14547
Project: 14547
Buggy source:
private void updateStatusViews(){
  if (!isAdded() || !hasComment())   return;
  final int moderationDrawResId;
  final int moderationTextResId;
  final CommentStatus newStatus;
  final int statusTextResId;
  final int statusColor;
switch (mComment.getStatusEnum()) {
case APPROVED:
    moderationDrawResId=R.drawable.ic_comment_moderate_approve_active;
  moderationTextResId=R.string.comment_status_approved;
newStatus=CommentStatus.UNAPPROVED;
statusTextResId=R.string.comment_status_approved;
statusColor=getActivity().getResources().getColor(R.color.calypso_orange);
mBtnModerateComment.setTextColor(getActivity().getResources().getColor(R.color.calypso_orange));
break;
case UNAPPROVED:
moderationDrawResId=R.drawable.ic_comment_moderate_approve;
moderationTextResId=R.string.mnu_comment_approve;
newStatus=CommentStatus.APPROVED;
statusTextResId=R.string.comment_status_unapproved;
statusColor=getActivity().getResources().getColor(R.color.calypso_orange);
mBtnModerateComment.setTextColor(getActivity().getResources().getColor(R.color.calypso_blue));
break;
case SPAM:
moderationDrawResId=R.drawable.ic_comment_moderate_approve;
moderationTextResId=R.string.mnu_comment_approve;
newStatus=CommentStatus.APPROVED;
statusTextResId=R.string.comment_status_spam;
statusColor=getActivity().getResources().getColor(R.color.comment_status_spam);
break;
case TRASH:
moderationDrawResId=R.drawable.ic_comment_moderate_approve;
moderationTextResId=R.string.mnu_comment_approve;
newStatus=CommentStatus.APPROVED;
statusTextResId=R.string.comment_status_trash;
statusColor=getActivity().getResources().getColor(R.color.comment_status_spam);
break;
default :
return;
}
int commentActionCount=0;
if (mNote != null && canLike()) {
commentActionCount++;
mBtnLikeComment.setVisibility(View.VISIBLE);
toggleLikeButton(mNote.hasLikedComment());
}
 else {
mBtnLikeComment.setVisibility(View.GONE);
}
if (mIsUsersBlog && mComment.getStatusEnum() != CommentStatus.APPROVED) {
mTxtStatus.setText(getString(statusTextResId).toUpperCase());
mTxtStatus.setTextColor(statusColor);
if (mTxtStatus.getVisibility() != View.VISIBLE) {
mTxtStatus.clearAnimation();
AniUtils.fadeIn(mTxtStatus);
}
}
 else {
mTxtStatus.setVisibility(View.GONE);
}
if (canModerate()) {
commentActionCount++;
setTextDrawable(mBtnModerateComment,moderationDrawResId);
mBtnModerateComment.setText(moderationTextResId);
mBtnModerateComment.setOnClickListener(new View.OnClickListener(){
@Override public void onClick(View v){
moderateComment(newStatus);
}
}
);
mBtnModerateComment.setVisibility(View.VISIBLE);
}
 else {
mBtnModerateComment.setVisibility(View.GONE);
}
if (canMarkAsSpam()) {
commentActionCount++;
mBtnSpamComment.setVisibility(View.VISIBLE);
if (mComment.getStatusEnum() == CommentStatus.SPAM) {
mBtnSpamComment.setText(R.string.mnu_comment_unspam);
}
 else {
mBtnSpamComment.setText(R.string.mnu_comment_spam);
}
}
 else {
mBtnSpamComment.setVisibility(View.GONE);
}
if (canTrash()) {
commentActionCount++;
mBtnTrashComment.setVisibility(View.VISIBLE);
}
 else {
mBtnTrashComment.setVisibility(View.GONE);
}
if (canEdit()) {
commentActionCount++;
mBtnEditComment.setVisibility(View.VISIBLE);
}
 else {
mBtnEditComment.setVisibility(View.GONE);
}
if (commentActionCount > 3) {
if (commentActionCount >= 4 && canEdit()) {
mBtnEditComment.setVisibility(View.GONE);
}
if (commentActionCount == 5 && canMarkAsSpam()) {
mBtnSpamComment.setVisibility(View.GONE);
}
mBtnMore.setVisibility(View.VISIBLE);
}
 else {
mBtnMore.setVisibility(View.GONE);
}
mLayoutButtons.setVisibility(View.VISIBLE);
}

Fixed version (ground truth):
private void updateStatusViews(){
  if (!isAdded() || !hasComment())   return;
  final int moderationDrawResId;
  final int moderationTextResId;
  final CommentStatus newStatus;
  final int statusTextResId;
  final int statusColor;
switch (mComment.getStatusEnum()) {
case APPROVED:
    moderationDrawResId=R.drawable.ic_comment_moderate_approve_active;
  moderationTextResId=R.string.comment_status_approved;
newStatus=CommentStatus.UNAPPROVED;
statusTextResId=R.string.comment_status_approved;
statusColor=getActivity().getResources().getColor(R.color.calypso_orange);
mBtnModerateComment.setTextColor(getActivity().getResources().getColor(R.color.calypso_orange));
break;
case UNAPPROVED:
moderationDrawResId=R.drawable.ic_comment_moderate_approve;
moderationTextResId=R.string.mnu_comment_approve;
newStatus=CommentStatus.APPROVED;
statusTextResId=R.string.comment_status_unapproved;
statusColor=getActivity().getResources().getColor(R.color.calypso_orange);
mBtnModerateComment.setTextColor(getActivity().getResources().getColor(R.color.calypso_blue));
break;
case SPAM:
moderationDrawResId=R.drawable.ic_comment_moderate_approve;
moderationTextResId=R.string.mnu_comment_approve;
newStatus=CommentStatus.APPROVED;
statusTextResId=R.string.comment_status_spam;
statusColor=getActivity().getResources().getColor(R.color.comment_status_spam);
mBtnModerateComment.setTextColor(getActivity().getResources().getColor(R.color.calypso_blue));
break;
case TRASH:
moderationDrawResId=R.drawable.ic_comment_moderate_approve;
moderationTextResId=R.string.mnu_comment_approve;
newStatus=CommentStatus.APPROVED;
statusTextResId=R.string.comment_status_trash;
statusColor=getActivity().getResources().getColor(R.color.comment_status_spam);
mBtnModerateComment.setTextColor(getActivity().getResources().getColor(R.color.calypso_blue));
break;
default :
return;
}
int commentActionCount=0;
if (mNote != null && canLike()) {
commentActionCount++;
mBtnLikeComment.setVisibility(View.VISIBLE);
toggleLikeButton(mNote.hasLikedComment());
}
 else {
mBtnLikeComment.setVisibility(View.GONE);
}
if (mIsUsersBlog && mComment.getStatusEnum() != CommentStatus.APPROVED) {
mTxtStatus.setText(getString(statusTextResId).toUpperCase());
mTxtStatus.setTextColor(statusColor);
if (mTxtStatus.getVisibility() != View.VISIBLE) {
mTxtStatus.clearAnimation();
AniUtils.fadeIn(mTxtStatus);
}
}
 else {
mTxtStatus.setVisibility(View.GONE);
}
if (canModerate()) {
commentActionCount++;
setTextDrawable(mBtnModerateComment,moderationDrawResId);
mBtnModerateComment.setText(moderationTextResId);
mBtnModerateComment.setOnClickListener(new View.OnClickListener(){
@Override public void onClick(View v){
moderateComment(newStatus);
}
}
);
mBtnModerateComment.setVisibility(View.VISIBLE);
}
 else {
mBtnModerateComment.setVisibility(View.GONE);
}
if (canMarkAsSpam()) {
commentActionCount++;
mBtnSpamComment.setVisibility(View.VISIBLE);
if (mComment.getStatusEnum() == CommentStatus.SPAM) {
mBtnSpamComment.setText(R.string.mnu_comment_unspam);
}
 else {
mBtnSpamComment.setText(R.string.mnu_comment_spam);
}
}
 else {
mBtnSpamComment.setVisibility(View.GONE);
}
if (canTrash()) {
commentActionCount++;
mBtnTrashComment.setVisibility(View.VISIBLE);
}
 else {
mBtnTrashComment.setVisibility(View.GONE);
}
if (canEdit()) {
commentActionCount++;
mBtnEditComment.setVisibility(View.VISIBLE);
}
 else {
mBtnEditComment.setVisibility(View.GONE);
}
if (commentActionCount > 3) {
if (commentActionCount >= 4 && canEdit()) {
mBtnEditComment.setVisibility(View.GONE);
}
if (commentActionCount == 5 && canMarkAsSpam()) {
mBtnSpamComment.setVisibility(View.GONE);
}
mBtnMore.setVisibility(View.VISIBLE);
}
 else {
mBtnMore.setVisibility(View.GONE);
}
mLayoutButtons.setVisibility(View.VISIBLE);
}