Program: 14500
Project: 14500
Buggy source:
public static void reloadGroupViews(final Context ctx,final ExpandableListAdapter mAdapter,final SparseBooleanArray mGroupIdToExpandedMap,final LinearLayout mLinearLayout,final int maxNumberOfItemsToshow){
  if (ctx == null || mLinearLayout == null || mAdapter == null || mGroupIdToExpandedMap == null) {
    return;
  }
  int groupCount=Math.min(mAdapter.getGroupCount(),maxNumberOfItemsToshow);
  if (groupCount == 0) {
    mLinearLayout.removeAllViews();
    return;
  }
  int numExistingGroupViews=mLinearLayout.getChildCount();
  if (groupCount < numExistingGroupViews) {
    int numToRemove=numExistingGroupViews - groupCount;
    mLinearLayout.removeViews(groupCount,numToRemove);
    numExistingGroupViews=groupCount;
  }
  int bgColor=Color.TRANSPARENT;
  for (int i=0; i < groupCount; i++) {
    boolean isExpanded=mGroupIdToExpandedMap.get(i);
    final View groupView;
    if (i < numExistingGroupViews) {
      View convertView=mLinearLayout.getChildAt(i);
      groupView=mAdapter.getGroupView(i,isExpanded,convertView,mLinearLayout);
      groupView.setBackgroundColor(bgColor);
      setViewBackgroundWithoutResettingPadding(groupView,i == 0 ? 0 : R.drawable.stats_list_item_odd_background);
    }
 else {
      groupView=mAdapter.getGroupView(i,isExpanded,null,mLinearLayout);
      groupView.setBackgroundColor(bgColor);
      setViewBackgroundWithoutResettingPadding(groupView,i == 0 ? 0 : R.drawable.stats_list_item_odd_background);
      mLinearLayout.addView(groupView);
    }
    if (isExpanded) {
      StatsUIHelper.showChildViews(mAdapter,mLinearLayout,i,groupView,false);
    }
    final int groupPosition=i;
    groupView.setOnClickListener(new View.OnClickListener(){
      @Override public void onClick(      View v){
        if (mAdapter.getChildrenCount(groupPosition) == 0) {
          return;
        }
        boolean shouldExpand=!mGroupIdToExpandedMap.get(groupPosition);
        mGroupIdToExpandedMap.put(groupPosition,shouldExpand);
        if (shouldExpand) {
          StatsUIHelper.showChildViews(mAdapter,mLinearLayout,groupPosition,groupView,true);
        }
 else {
          StatsUIHelper.hideChildViews(groupView,true);
        }
      }
    }
);
  }
}

Fixed version (ground truth):
public static void reloadGroupViews(final Context ctx,final ExpandableListAdapter mAdapter,final SparseBooleanArray mGroupIdToExpandedMap,final LinearLayout mLinearLayout,final int maxNumberOfItemsToshow){
  if (ctx == null || mLinearLayout == null || mAdapter == null || mGroupIdToExpandedMap == null) {
    return;
  }
  int groupCount=Math.min(mAdapter.getGroupCount(),maxNumberOfItemsToshow);
  if (groupCount == 0) {
    mLinearLayout.removeAllViews();
    return;
  }
  int numExistingGroupViews=mLinearLayout.getChildCount();
  if (groupCount < numExistingGroupViews) {
    int numToRemove=numExistingGroupViews - groupCount;
    mLinearLayout.removeViews(groupCount,numToRemove);
    numExistingGroupViews=groupCount;
  }
  int bgColor=Color.TRANSPARENT;
  for (int i=0; i < groupCount; i++) {
    boolean isExpanded=mGroupIdToExpandedMap.get(i);
    final View groupView;
    if (i < numExistingGroupViews) {
      View convertView=mLinearLayout.getChildAt(i);
      groupView=mAdapter.getGroupView(i,isExpanded,convertView,mLinearLayout);
      groupView.setBackgroundColor(bgColor);
      setViewBackgroundWithoutResettingPadding(groupView,i == 0 ? 0 : R.drawable.stats_list_item_background);
    }
 else {
      groupView=mAdapter.getGroupView(i,isExpanded,null,mLinearLayout);
      groupView.setBackgroundColor(bgColor);
      setViewBackgroundWithoutResettingPadding(groupView,i == 0 ? 0 : R.drawable.stats_list_item_background);
      mLinearLayout.addView(groupView);
    }
    if (isExpanded) {
      StatsUIHelper.showChildViews(mAdapter,mLinearLayout,i,groupView,false);
    }
    final int groupPosition=i;
    groupView.setOnClickListener(new View.OnClickListener(){
      @Override public void onClick(      View v){
        if (mAdapter.getChildrenCount(groupPosition) == 0) {
          return;
        }
        boolean shouldExpand=!mGroupIdToExpandedMap.get(groupPosition);
        mGroupIdToExpandedMap.put(groupPosition,shouldExpand);
        if (shouldExpand) {
          StatsUIHelper.showChildViews(mAdapter,mLinearLayout,groupPosition,groupView,true);
        }
 else {
          StatsUIHelper.hideChildViews(groupView,groupPosition,true);
        }
      }
    }
);
  }
}