Program: 142381
Project: 142381
Buggy source:
private void refresh(){
  this.removeAllViews();
  TableLayout table=new TableLayout(this.getContext());
  int days=data.days().length;
  int rows=(int)Math.ceil(days / TABLE_LENGTH);
  dayViews=new View[days];
  table.setShrinkAllColumns(true);
  table.setStretchAllColumns(true);
  tRows=new TableRow[rows];
  for (int i=0; i < tRows.length; ++i) {
    tRows[i]=new TableRow(this.getContext());
  }
  Calendar c=Calendar.getInstance();
  c.setTime(data.anchor());
  c.roll(Calendar.DAY_OF_YEAR,-(data.days().length - 1));
  int currentRow=0;
  for (int i=0; i < days; ++i) {
    DotsDay day=data.days()[i];
    TableRow.LayoutParams dayParams=new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
    dayParams.setMargins(1,1,1,1);
    View dayView=getDayView(c,day,i);
    tRows[currentRow].addView(dayView);
    dayViews[i]=dayView;
    if (i % TABLE_LENGTH == TABLE_LENGTH - 1) {
      currentRow=currentRow + 1;
    }
    c.roll(Calendar.DAY_OF_YEAR,1);
  }
  for (int i=0; i < tRows.length; ++i) {
    table.addView(tRows[i]);
  }
  Button done=new Button(this.getContext());
  done.setId(666);
  done.setText("String_Node_Str");
  done.setOnClickListener(new OnClickListener(){
    public void onClick(    View v){
      listener.doneWithDOTS();
    }
  }
);
  RelativeLayout topPane=new RelativeLayout(this.getContext());
  LayoutParams params=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
  params.addRule(RelativeLayout.ABOVE,done.getId());
  params.addRule(RelativeLayout.ALIGN_PARENT_TOP,RelativeLayout.TRUE);
  this.addView(topPane,params);
  table.setGravity(Gravity.CENTER_VERTICAL);
  params=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
  params.addRule(RelativeLayout.CENTER_VERTICAL,RelativeLayout.TRUE);
  topPane.addView(table,params);
  params=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
  params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE);
  this.addView(done,params);
}

Fixed version (ground truth):
private void refresh(){
  this.removeAllViews();
  TableLayout table=new TableLayout(this.getContext());
  int days=data.days().length;
  int rows=(int)Math.ceil(days / TABLE_LENGTH);
  dayViews=new View[days];
  table.setShrinkAllColumns(true);
  table.setStretchAllColumns(true);
  tRows=new TableRow[rows];
  for (int i=0; i < tRows.length; ++i) {
    tRows[i]=new TableRow(this.getContext());
  }
  Calendar c=Calendar.getInstance();
  c.setTime(data.anchor());
  c.add(Calendar.DATE,-(data.days().length - 1));
  int currentRow=0;
  for (int i=0; i < days; ++i) {
    DotsDay day=data.days()[i];
    TableRow.LayoutParams dayParams=new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
    dayParams.setMargins(1,1,1,1);
    View dayView=getDayView(c,day,i);
    tRows[currentRow].addView(dayView);
    dayViews[i]=dayView;
    if (i % TABLE_LENGTH == TABLE_LENGTH - 1) {
      currentRow=currentRow + 1;
    }
    c.add(Calendar.DATE,1);
  }
  for (int i=0; i < tRows.length; ++i) {
    table.addView(tRows[i]);
  }
  Button done=new Button(this.getContext());
  done.setId(666);
  done.setText("String_Node_Str");
  done.setOnClickListener(new OnClickListener(){
    public void onClick(    View v){
      listener.doneWithDOTS();
    }
  }
);
  RelativeLayout topPane=new RelativeLayout(this.getContext());
  LayoutParams params=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
  params.addRule(RelativeLayout.ABOVE,done.getId());
  params.addRule(RelativeLayout.ALIGN_PARENT_TOP,RelativeLayout.TRUE);
  this.addView(topPane,params);
  table.setGravity(Gravity.CENTER_VERTICAL);
  params=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
  params.addRule(RelativeLayout.CENTER_VERTICAL,RelativeLayout.TRUE);
  topPane.addView(table,params);
  params=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
  params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE);
  this.addView(done,params);
}