Program: 15439
Project: 15439
Buggy source:
public VerticalToolbar generateToolbar(final Context context,final Fragment fragmentParent,final SideToolbarOverlay overlay){
  final VerticalToolbar toolbar=new VerticalToolbar(context);
  final EnumSet<Action> itemsPref=PrefsUtility.pref_menus_post_toolbar_items(context,PreferenceManager.getDefaultSharedPreferences(context));
  final Action[] possibleItems={Action.ACTION_MENU,fragmentParent instanceof CommentListingFragment ? Action.LINK_SWITCH : Action.COMMENTS_SWITCH,Action.UPVOTE,Action.DOWNVOTE,Action.SAVE,Action.HIDE,Action.REPLY,Action.EXTERNAL,Action.SAVE_IMAGE,Action.SHARE,Action.COPY,Action.USER_PROFILE,Action.PROPERTIES};
  final EnumMap<Action,Integer> iconsDark=new EnumMap<Action,Integer>(Action.class);
  iconsDark.put(Action.ACTION_MENU,R.drawable.ic_action_overflow);
  iconsDark.put(Action.COMMENTS_SWITCH,R.drawable.ic_action_comments_dark);
  iconsDark.put(Action.LINK_SWITCH,imageUrl != null ? R.drawable.ic_action_image_dark : R.drawable.ic_action_page_dark);
  iconsDark.put(Action.UPVOTE,R.drawable.ic_action_thumb_up_dark);
  iconsDark.put(Action.DOWNVOTE,R.drawable.ic_action_thumb_down_dark);
  iconsDark.put(Action.SAVE,R.drawable.ic_action_star_filled_dark);
  iconsDark.put(Action.HIDE,R.drawable.ic_action_cross_dark);
  iconsDark.put(Action.REPLY,R.drawable.ic_action_reply_dark);
  iconsDark.put(Action.EXTERNAL,R.drawable.ic_action_globe_dark);
  iconsDark.put(Action.SAVE_IMAGE,R.drawable.ic_action_save_dark);
  iconsDark.put(Action.SHARE,R.drawable.ic_action_share_dark);
  iconsDark.put(Action.COPY,R.drawable.ic_action_copy_dark);
  iconsDark.put(Action.USER_PROFILE,R.drawable.ic_action_person_dark);
  iconsDark.put(Action.PROPERTIES,R.drawable.ic_action_info_dark);
  final EnumMap<Action,Integer> iconsLight=new EnumMap<Action,Integer>(Action.class);
  iconsLight.put(Action.ACTION_MENU,R.drawable.ic_action_overflow);
  iconsLight.put(Action.COMMENTS_SWITCH,R.drawable.ic_action_comments_light);
  iconsDark.put(Action.LINK_SWITCH,imageUrl != null ? R.drawable.ic_action_image_light : R.drawable.ic_action_page_light);
  iconsLight.put(Action.UPVOTE,R.drawable.ic_action_thumb_up_light);
  iconsLight.put(Action.DOWNVOTE,R.drawable.ic_action_thumb_down_light);
  iconsLight.put(Action.SAVE,R.drawable.ic_action_star_filled_light);
  iconsLight.put(Action.HIDE,R.drawable.ic_action_cross_light);
  iconsLight.put(Action.REPLY,R.drawable.ic_action_reply_light);
  iconsLight.put(Action.EXTERNAL,R.drawable.ic_action_globe_light);
  iconsLight.put(Action.SAVE_IMAGE,R.drawable.ic_action_save_light);
  iconsLight.put(Action.SHARE,R.drawable.ic_action_share_light);
  iconsLight.put(Action.COPY,R.drawable.ic_action_copy_light);
  iconsLight.put(Action.USER_PROFILE,R.drawable.ic_action_person_light);
  iconsLight.put(Action.PROPERTIES,R.drawable.ic_action_info_light);
  for (  final Action action : possibleItems) {
    if (action == Action.SAVE_IMAGE && imageUrl == null)     continue;
    if (itemsPref.contains(action)) {
      final FlatImageButton ib=new FlatImageButton(context);
      final int buttonPadding=General.dpToPixels(context,10);
      ib.setPadding(buttonPadding,buttonPadding,buttonPadding,buttonPadding);
      if (action == Action.UPVOTE && isUpvoted() || action == Action.DOWNVOTE && isDownvoted() || action == Action.SAVE && isSaved() || action == Action.HIDE && isHidden()) {
        ib.setBackgroundColor(Color.WHITE);
        ib.setImageResource(iconsLight.get(action));
      }
 else {
        ib.setImageResource(iconsDark.get(action));
      }
      ib.setOnClickListener(new View.OnClickListener(){
        public void onClick(        View v){
          final Action actionToTake;
switch (action) {
case UPVOTE:
            actionToTake=isUpvoted() ? Action.UNVOTE : Action.UPVOTE;
          break;
case DOWNVOTE:
        actionToTake=isDownvoted() ? Action.UNVOTE : Action.DOWNVOTE;
      break;
case SAVE:
    actionToTake=isSaved() ? Action.UNSAVE : Action.SAVE;
  break;
case HIDE:
actionToTake=isHidden() ? Action.UNHIDE : Action.HIDE;
break;
default :
actionToTake=action;
break;
}
onActionMenuItemSelected(RedditPreparedPost.this,fragmentParent,actionToTake);
overlay.hide();
}
}
);
toolbar.addItem(ib);
}
}
return toolbar;
}

Fixed version (ground truth):
public VerticalToolbar generateToolbar(final Context context,final Fragment fragmentParent,final SideToolbarOverlay overlay){
  final VerticalToolbar toolbar=new VerticalToolbar(context);
  final EnumSet<Action> itemsPref=PrefsUtility.pref_menus_post_toolbar_items(context,PreferenceManager.getDefaultSharedPreferences(context));
  final Action[] possibleItems={Action.ACTION_MENU,fragmentParent instanceof CommentListingFragment ? Action.LINK_SWITCH : Action.COMMENTS_SWITCH,Action.UPVOTE,Action.DOWNVOTE,Action.SAVE,Action.HIDE,Action.REPLY,Action.EXTERNAL,Action.SAVE_IMAGE,Action.SHARE,Action.COPY,Action.USER_PROFILE,Action.PROPERTIES};
  final EnumMap<Action,Integer> iconsDark=new EnumMap<Action,Integer>(Action.class);
  iconsDark.put(Action.ACTION_MENU,R.drawable.ic_action_overflow);
  iconsDark.put(Action.COMMENTS_SWITCH,R.drawable.ic_action_comments_dark);
  iconsDark.put(Action.LINK_SWITCH,imageUrl != null ? R.drawable.ic_action_image_dark : R.drawable.ic_action_page_dark);
  iconsDark.put(Action.UPVOTE,R.drawable.ic_action_thumb_up_dark);
  iconsDark.put(Action.DOWNVOTE,R.drawable.ic_action_thumb_down_dark);
  iconsDark.put(Action.SAVE,R.drawable.ic_action_star_filled_dark);
  iconsDark.put(Action.HIDE,R.drawable.ic_action_cross_dark);
  iconsDark.put(Action.REPLY,R.drawable.ic_action_reply_dark);
  iconsDark.put(Action.EXTERNAL,R.drawable.ic_action_globe_dark);
  iconsDark.put(Action.SAVE_IMAGE,R.drawable.ic_action_save_dark);
  iconsDark.put(Action.SHARE,R.drawable.ic_action_share_dark);
  iconsDark.put(Action.COPY,R.drawable.ic_action_copy_dark);
  iconsDark.put(Action.USER_PROFILE,R.drawable.ic_action_person_dark);
  iconsDark.put(Action.PROPERTIES,R.drawable.ic_action_info_dark);
  final EnumMap<Action,Integer> iconsLight=new EnumMap<Action,Integer>(Action.class);
  iconsLight.put(Action.ACTION_MENU,R.drawable.ic_action_overflow);
  iconsLight.put(Action.COMMENTS_SWITCH,R.drawable.ic_action_comments_light);
  iconsLight.put(Action.LINK_SWITCH,imageUrl != null ? R.drawable.ic_action_image_light : R.drawable.ic_action_page_light);
  iconsLight.put(Action.UPVOTE,R.drawable.ic_action_thumb_up_light);
  iconsLight.put(Action.DOWNVOTE,R.drawable.ic_action_thumb_down_light);
  iconsLight.put(Action.SAVE,R.drawable.ic_action_star_filled_light);
  iconsLight.put(Action.HIDE,R.drawable.ic_action_cross_light);
  iconsLight.put(Action.REPLY,R.drawable.ic_action_reply_light);
  iconsLight.put(Action.EXTERNAL,R.drawable.ic_action_globe_light);
  iconsLight.put(Action.SAVE_IMAGE,R.drawable.ic_action_save_light);
  iconsLight.put(Action.SHARE,R.drawable.ic_action_share_light);
  iconsLight.put(Action.COPY,R.drawable.ic_action_copy_light);
  iconsLight.put(Action.USER_PROFILE,R.drawable.ic_action_person_light);
  iconsLight.put(Action.PROPERTIES,R.drawable.ic_action_info_light);
  for (  final Action action : possibleItems) {
    if (action == Action.SAVE_IMAGE && imageUrl == null)     continue;
    if (itemsPref.contains(action)) {
      final FlatImageButton ib=new FlatImageButton(context);
      final int buttonPadding=General.dpToPixels(context,10);
      ib.setPadding(buttonPadding,buttonPadding,buttonPadding,buttonPadding);
      if (action == Action.UPVOTE && isUpvoted() || action == Action.DOWNVOTE && isDownvoted() || action == Action.SAVE && isSaved() || action == Action.HIDE && isHidden()) {
        ib.setBackgroundColor(Color.WHITE);
        ib.setImageResource(iconsLight.get(action));
      }
 else {
        ib.setImageResource(iconsDark.get(action));
      }
      ib.setOnClickListener(new View.OnClickListener(){
        public void onClick(        View v){
          final Action actionToTake;
switch (action) {
case UPVOTE:
            actionToTake=isUpvoted() ? Action.UNVOTE : Action.UPVOTE;
          break;
case DOWNVOTE:
        actionToTake=isDownvoted() ? Action.UNVOTE : Action.DOWNVOTE;
      break;
case SAVE:
    actionToTake=isSaved() ? Action.UNSAVE : Action.SAVE;
  break;
case HIDE:
actionToTake=isHidden() ? Action.UNHIDE : Action.HIDE;
break;
default :
actionToTake=action;
break;
}
onActionMenuItemSelected(RedditPreparedPost.this,fragmentParent,actionToTake);
overlay.hide();
}
}
);
toolbar.addItem(ib);
}
}
return toolbar;
}