nus-yam/ex-repair huggingface dataset:
Program: 18978
Project: 18978
Buggy source:
/** 
 * returns the y-value for the given x-index and DataSet index
 * @param index
 * @param dataSet
 * @return
 */
public float getYValueByDataSetIndex(int index,int dataSet){
  DataSet set=mData.getDataSetByIndex(dataSet);
  return set.getYVals().get(index).getVal();
}

Fixed version (ground truth):
/** 
 * returns the y-value for the given x-index and DataSet index
 * @param index
 * @param dataSet
 * @return
 */
public float getYValueByDataSetIndex(int xIndex,int dataSet){
  DataSet set=mData.getDataSetByIndex(dataSet);
  return set.getYValForXIndex(xIndex);
}
Program: 18979
Project: 18979
Buggy source:
/** 
 * Get the y-values from the Series object at the given index across all DataSets. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @param xIndex
 * @return
 */
public ArrayList<Float> getYValsAtIndex(int xIndex){
  ArrayList<Float> vals=new ArrayList<Float>();
  for (int i=0; i < mData.getDataSetCount(); i++) {
    float yVal=mData.getDataSetByIndex(i).getYValForXIndex(xIndex);
    if (!Float.isNaN(yVal))     vals.add(yVal);
  }
  return vals;
}

Fixed version (ground truth):
/** 
 * Returns an array of SelInfo objects for the given x-index. The SelInfo objects give information about the value at the selected index and the DataSet it belongs to. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @param xIndex
 * @return
 */
protected ArrayList<SelInfo> getYValsAtIndex(int xIndex){
  ArrayList<SelInfo> vals=new ArrayList<SelInfo>();
  for (int i=0; i < mData.getDataSetCount(); i++) {
    float yVal=mData.getDataSetByIndex(i).getYValForXIndex(xIndex);
    if (!Float.isNaN(yVal)) {
      vals.add(new SelInfo(yVal,i));
    }
  }
  return vals;
}
Program: 18980
Project: 18980
Buggy source:
/** 
 * Returns the Series object at the given xIndex. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @param xIndex
 * @return
 */
public Series getSeriesForXIndex(int xIndex){
  for (int i=0; i < mYVals.size(); i++) {
    if (xIndex == mYVals.get(i).getXIndex())     return mYVals.get(i);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the Series object at the given xIndex. Returns null if no Series object at that index. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @param xIndex
 * @return
 */
public Series getSeriesForXIndex(int xIndex){
  for (int i=0; i < mYVals.size(); i++) {
    if (xIndex == mYVals.get(i).getXIndex())     return mYVals.get(i);
  }
  return null;
}
Program: 18981
Project: 18981
Buggy source:
public int getType(){
  return mType;
}

Fixed version (ground truth):
/** 
 * returns the type of the DataSet, specified via constructor
 * @return
 */
public int getType(){
  return mType;
}
Program: 18982
Project: 18982
Buggy source:
public float getYMax(){
  return mYMax;
}

Fixed version (ground truth):
/** 
 * returns the maximum y-value this DataSet holds
 * @return
 */
public float getYMax(){
  return mYMax;
}
Program: 18983
Project: 18983
Buggy source:
public float getYMin(){
  return mYMin;
}

Fixed version (ground truth):
/** 
 * returns the minimum y-value this DataSet holds
 * @return
 */
public float getYMin(){
  return mYMin;
}
Program: 18984
Project: 18984
Buggy source:
public ArrayList<Series> getYVals(){
  return mYVals;
}

Fixed version (ground truth):
/** 
 * returns the DataSets Series array
 * @return
 */
public ArrayList<Series> getYVals(){
  return mYVals;
}
Program: 18985
Project: 18985
Buggy source:
public float getYValueSum(){
  return mYValueSum;
}

Fixed version (ground truth):
/** 
 * gets the sum of all y-values
 * @return
 */
public float getYValueSum(){
  return mYValueSum;
}
Program: 18986
Project: 18986
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_barchart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(BarChart)findViewById(R.id.chart1);
  ColorTemplate ct=new ColorTemplate();
  ct.addDataSetColors(ColorTemplate.FRESH_COLORS,this);
  ct.addDataSetColors(new int[]{R.color.liberty_2},this);
  ct.addDataSetColors(ColorTemplate.COLORFUL_COLORS,this);
  mChart.setColorTemplate(ct);
  mChart.setDrawYValues(false);
  mChart.set3DEnabled(false);
  mChart.setYLegendCount(5);
  mChart.setTouchEnabled(true);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_barchart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(BarChart)findViewById(R.id.chart1);
  ColorTemplate ct=new ColorTemplate();
  ct.addDataSetColors(ColorTemplate.FRESH_COLORS,this);
  ct.addDataSetColors(new int[]{R.color.liberty_2},this);
  ct.addDataSetColors(ColorTemplate.COLORFUL_COLORS,this);
  mChart.setColorTemplate(ct);
  mChart.setDrawYValues(false);
  mChart.set3DEnabled(false);
  mChart.setYLegendCount(5);
  mChart.setTouchEnabled(true);
  mChart.setDescription("String_Node_Str");
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
}
Program: 18987
Project: 18987
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_piechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(PieChart)findViewById(R.id.chart1);
  ColorTemplate ct=new ColorTemplate();
  ct.addDataSetColors(ColorTemplate.COLORFUL_COLORS,this);
  ct.addDataSetColors(ColorTemplate.LIBERTY_COLORS,this);
  mChart.setColorTemplate(ct);
  mChart.setDrawYValues(true);
  mChart.setDrawCenterText(true);
  mChart.setDescription("String_Node_Str");
  mChart.setDrawHoleEnabled(true);
  mChart.setDrawXValues(true);
  mChart.setTouchEnabled(true);
  mChart.setUsePercentValues(false);
  mChart.setOnChartValueSelectedListener(this);
  mSeekBarX.setProgress(10);
  mSeekBarY.setProgress(100);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_piechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(PieChart)findViewById(R.id.chart1);
  ColorTemplate ct=new ColorTemplate();
  ct.addDataSetColors(ColorTemplate.COLORFUL_COLORS,this);
  ct.addDataSetColors(ColorTemplate.FRESH_COLORS,this);
  mChart.setColorTemplate(ct);
  mChart.setDrawYValues(true);
  mChart.setDrawCenterText(true);
  mChart.setDescription("String_Node_Str");
  mChart.setDrawHoleEnabled(true);
  mChart.setDrawXValues(true);
  mChart.setTouchEnabled(true);
  mChart.setUsePercentValues(false);
  mChart.setOnChartValueSelectedListener(this);
  mSeekBarX.setProgress(10);
  mSeekBarY.setProgress(100);
}
Program: 18989
Project: 18989
Buggy source:
/** 
 * Sets a colortemplate for the chart that defindes the colors used for drawing. If more values need to be drawn than provided colors available in the colortemplate, colors are repeated.
 * @param ct
 */
public void setColorTemplate(ColorTemplate ct){
  this.mCt=ct;
  prepareDataPaints(ct);
}

Fixed version (ground truth):
/** 
 * Sets a colortemplate for the chart that defindes the colors used for drawing. If more values need to be drawn than provided colors available in the colortemplate, colors are repeated.
 * @param ct
 */
public void setColorTemplate(ColorTemplate ct){
  this.mCt=ct;
}
Program: 18990
Project: 18990
Buggy source:
/** 
 * returns the color value at the given index from the DataSet at the given index
 * @param dataSetIndex
 * @param colorIndex
 * @return
 */
public int getDataSetColor(int dataSetIndex,int colorIndex){
  return mDataSetColors.get(dataSetIndex).get(colorIndex);
}

Fixed version (ground truth):
/** 
 * Returns the color value at the given index from the DataSet at the given index. If index is outofbounds, it restart at lower indices.
 * @param dataSetIndex
 * @param colorIndex
 * @return
 */
public int getDataSetColor(int dataSetIndex,int colorIndex){
  return mDataSetColors.get(dataSetIndex).get(colorIndex % mDataSetColors.get(dataSetIndex).size());
}
Program: 18991
Project: 18991
Buggy source:
@Override protected void drawHighlights(){
  if (mHighlightEnabled && valuesToHighlight()) {
    float angle=0f;
    for (int i=0; i < mIndicesToHightlight.length; i++) {
      int index=mIndicesToHightlight[i].getXIndex();
      if (index >= mDrawAngles.length || index > mDeltaX)       continue;
      if (index == 0)       angle=mChartAngle;
 else       angle=mChartAngle + mAbsoluteAngles[index - 1];
      float sliceDegrees=mDrawAngles[index];
      float shiftangle=(float)Math.toRadians(angle + sliceDegrees / 2f);
      float xShift=mShift * (float)Math.cos(shiftangle);
      float yShift=mShift * (float)Math.sin(shiftangle);
      RectF highlighted=new RectF(mCircleBox.left + xShift,mCircleBox.top + yShift,mCircleBox.right + xShift,mCircleBox.bottom + yShift);
      ArrayList<Integer> colors=mCt.getDataSetColors(mIndicesToHightlight[i].getDataSetIndex());
      mRenderPaint.setColor(colors.get(index % colors.size()));
      mDrawCanvas.drawArc(highlighted,angle,sliceDegrees,true,mRenderPaint);
    }
  }
}

Fixed version (ground truth):
@Override protected void drawHighlights(){
  if (mHighlightEnabled && valuesToHighlight()) {
    float angle=0f;
    for (int i=0; i < mIndicesToHightlight.length; i++) {
      int xIndex=mIndicesToHightlight[i].getXIndex();
      if (xIndex >= mDrawAngles.length || xIndex > mDeltaX)       continue;
      if (xIndex == 0)       angle=mChartAngle;
 else       angle=mChartAngle + mAbsoluteAngles[xIndex - 1];
      float sliceDegrees=mDrawAngles[xIndex];
      float shiftangle=(float)Math.toRadians(angle + sliceDegrees / 2f);
      float xShift=mShift * (float)Math.cos(shiftangle);
      float yShift=mShift * (float)Math.sin(shiftangle);
      RectF highlighted=new RectF(mCircleBox.left + xShift,mCircleBox.top + yShift,mCircleBox.right + xShift,mCircleBox.bottom + yShift);
      DataSet set=mData.getDataSetByIndex(mIndicesToHightlight[i].getDataSetIndex());
      int color=mCt.getDataSetColor(mIndicesToHightlight[i].getDataSetIndex(),set.getIndexInSeries(xIndex));
      mRenderPaint.setColor(color);
      mDrawCanvas.drawArc(highlighted,angle,sliceDegrees,true,mRenderPaint);
    }
  }
}
Program: 18992
Project: 18992
Buggy source:
@Override protected void drawData(){
  float angle=mChartAngle;
  ArrayList<DataSet> dataSets=mData.getDataSets();
  int cnt=0;
  for (int i=0; i < mData.getDataSetCount(); i++) {
    DataSet dataSet=dataSets.get(i);
    ArrayList<Series> series=dataSet.getYVals();
    ArrayList<Integer> colors=mCt.getDataSetColors(i % mCt.getColors().size());
    for (int j=0; j < series.size(); j++) {
      mRenderPaint.setColor(colors.get(j % colors.size()));
      float newangle=mDrawAngles[cnt];
      if (!needsHighlight(series.get(j).getXIndex(),i)) {
        mDrawCanvas.drawArc(mCircleBox,angle,newangle,true,mRenderPaint);
      }
      angle+=newangle;
      cnt++;
    }
  }
}

Fixed version (ground truth):
@Override protected void drawData(){
  float angle=mChartAngle;
  ArrayList<DataSet> dataSets=mData.getDataSets();
  int cnt=0;
  for (int i=0; i < mData.getDataSetCount(); i++) {
    DataSet dataSet=dataSets.get(i);
    ArrayList<Series> series=dataSet.getYVals();
    ArrayList<Integer> colors=mCt.getDataSetColors(i % mCt.getColors().size());
    for (int j=0; j < series.size(); j++) {
      float newangle=mDrawAngles[cnt];
      if (!needsHighlight(series.get(j).getXIndex(),i)) {
        mRenderPaint.setColor(colors.get(j % colors.size()));
        mDrawCanvas.drawArc(mCircleBox,angle,newangle,true,mRenderPaint);
      }
      angle+=newangle;
      cnt++;
    }
  }
}
Program: 18993
Project: 18993
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_linechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setDrawYValues(false);
  mChart.setLineWidth(5f);
  mChart.setCircleSize(5f);
  mChart.setYLegendCount(6);
  mChart.setTouchEnabled(true);
  mChart.setHighlightEnabled(true);
  mChart.setDragEnabled(true);
  mChart.setTouchEnabled(true);
  TextView textView=new TextView(this);
  textView.setVisibility(View.VISIBLE);
  textView.setBackgroundColor(Color.WHITE);
  textView.setPadding(15,15,15,15);
  textView.setText("String_Node_Str");
  mChart.setDrawMarkerView(true);
  mChart.setMarkerView(textView);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_linechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setOnChartValueSelectedListener(this);
  mChart.setDrawYValues(false);
  mChart.setLineWidth(5f);
  mChart.setCircleSize(5f);
  mChart.setYLegendCount(6);
  mChart.setTouchEnabled(true);
  mChart.setHighlightEnabled(true);
  mChart.setDragEnabled(true);
  mChart.setTouchEnabled(true);
  TextView textView=new TextView(this);
  textView.setVisibility(View.VISIBLE);
  textView.setBackgroundColor(Color.WHITE);
  textView.setPadding(15,15,15,15);
  textView.setText("String_Node_Str");
  mChart.setDrawMarkerView(true);
  mChart.setMarkerView(textView);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
}
Program: 18994
Project: 18994
Buggy source:
@Override public void onProgressChanged(SeekBar seekBar,int progress,boolean fromUser){
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < mSeekBarX.getProgress(); i++) {
    xVals.add((i) + "String_Node_Str");
  }
  ArrayList<Series> yVals=new ArrayList<Series>();
  for (int i=0; i < mSeekBarX.getProgress(); i++) {
    float mult=(mSeekBarY.getProgress() + 1);
    float val=(float)(Math.random() * mult * 0.1) + 3;
    yVals.add(new Series(val,i));
  }
  tvX.setText("String_Node_Str" + (mSeekBarX.getProgress() + 1));
  tvY.setText("String_Node_Str" + (mSeekBarY.getProgress() / 10));
  DataSet set=new DataSet(yVals,0);
  ArrayList<DataSet> dataSets=new ArrayList<DataSet>();
  dataSets.add(set);
  ChartData data=new ChartData(xVals,dataSets);
  mChart.setData(data);
  mChart.invalidate();
}

Fixed version (ground truth):
@Override public void onProgressChanged(SeekBar seekBar,int progress,boolean fromUser){
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < mSeekBarX.getProgress(); i++) {
    xVals.add((i) + "String_Node_Str");
  }
  ArrayList<Series> yVals=new ArrayList<Series>();
  for (int i=0; i < mSeekBarX.getProgress(); i++) {
    float mult=(mSeekBarY.getProgress() + 1);
    float val=(float)(Math.random() * mult * 0.1) + 3;
    yVals.add(new Series(val,i));
  }
  tvX.setText("String_Node_Str" + (mSeekBarX.getProgress() + 1));
  tvY.setText("String_Node_Str" + (mSeekBarY.getProgress() / 10));
  DataSet set1=new DataSet(yVals,0);
  ArrayList<DataSet> dataSets=new ArrayList<DataSet>();
  dataSets.add(set1);
  ChartData data=new ChartData(xVals,dataSets);
  mChart.setData(data);
  mChart.invalidate();
}
Program: 18995
Project: 18995
Buggy source:
@Override protected void drawHighlights(){
  if (mHighlightEnabled && valuesToHighlight()) {
    float offsetY=mDeltaY * 0.04f;
    for (int i=0; i < mIndicesToHightlight.length; i++) {
      int index=mIndicesToHightlight[i];
      if (index < mYVals.size()) {
        mHighlightPaint.setAlpha(120);
        float y=mYVals.get(index).getVal();
        float left=index + mBarSpace / 2f;
        float right=index + 1f - mBarSpace / 2f;
        float top=y >= 0 ? y : 0;
        float bottom=y <= 0 ? y : 0;
        RectF highlight=new RectF(left,top,right,bottom);
        transformRect(highlight);
        mDrawCanvas.drawRect(highlight,mHighlightPaint);
        if (mDrawHighlightArrow) {
          mHighlightPaint.setAlpha(200);
          Path arrow=new Path();
          arrow.moveTo(index + 0.5f,y + offsetY * 0.3f);
          arrow.lineTo(index + 0.2f,y + offsetY);
          arrow.lineTo(index + 0.8f,y + offsetY);
          transformPath(arrow);
          mDrawCanvas.drawPath(arrow,mHighlightPaint);
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void drawHighlights(){
  if (mHighlightEnabled && valuesToHighlight()) {
    float offsetY=mDeltaY * 0.04f;
    for (int i=0; i < mIndicesToHightlight.length; i++) {
      int index=mIndicesToHightlight[i];
      if (index < mYVals.size() && index >= 0) {
        mHighlightPaint.setAlpha(120);
        float y=mYVals.get(index).getVal();
        float left=index + mBarSpace / 2f;
        float right=index + 1f - mBarSpace / 2f;
        float top=y >= 0 ? y : 0;
        float bottom=y <= 0 ? y : 0;
        RectF highlight=new RectF(left,top,right,bottom);
        transformRect(highlight);
        mDrawCanvas.drawRect(highlight,mHighlightPaint);
        if (mDrawHighlightArrow) {
          mHighlightPaint.setAlpha(200);
          Path arrow=new Path();
          arrow.moveTo(index + 0.5f,y + offsetY * 0.3f);
          arrow.lineTo(index + 0.2f,y + offsetY);
          arrow.lineTo(index + 0.8f,y + offsetY);
          transformPath(arrow);
          mDrawCanvas.drawPath(arrow,mHighlightPaint);
        }
      }
    }
  }
}
Program: 18996
Project: 18996
Buggy source:
/** 
 * returns the index of the value (on the x-axis) for the given touch point
 * @param x
 * @param y
 * @return
 */
public int getIndexByTouchPoint(float x,float y){
  float[] pts=new float[2];
  pts[0]=x;
  pts[1]=y;
  Matrix tmp=new Matrix();
  mMatrixOffset.invert(tmp);
  tmp.mapPoints(pts);
  mMatrixTouch.invert(tmp);
  tmp.mapPoints(pts);
  mMatrixValueToPx.invert(tmp);
  tmp.mapPoints(pts);
  double touchPointIndex=pts[0];
  double base=Math.floor(touchPointIndex);
  int index=(int)base;
  if (this instanceof LineChart) {
    if (touchPointIndex - base > 0.5) {
      index=(int)base + 1;
    }
  }
  return index;
}

Fixed version (ground truth):
/** 
 * returns the index of the value (on the x-axis) for the given touch point
 * @param x
 * @param y
 * @return
 */
public int getIndexByTouchPoint(float x,float y){
  float[] pts=new float[2];
  pts[0]=x;
  pts[1]=y;
  Matrix tmp=new Matrix();
  mMatrixOffset.invert(tmp);
  tmp.mapPoints(pts);
  mMatrixTouch.invert(tmp);
  tmp.mapPoints(pts);
  mMatrixValueToPx.invert(tmp);
  tmp.mapPoints(pts);
  double touchPointIndex=pts[0];
  double base=Math.floor(touchPointIndex);
  if (touchPointIndex < 0 || touchPointIndex > getValueCount() - 1)   return -1;
  int index=(int)base;
  if (this instanceof LineChart) {
    if (touchPointIndex - base > 0.5) {
      index=(int)base + 1;
    }
  }
  return index;
}
Program: 18997
Project: 18997
Buggy source:
/** 
 * returns the x-value at the given index
 * @param index
 * @return
 */
public String getXValue(int index){
  if (mXVals == null || mXVals.size() >= index)   return null;
 else   return mXVals.get(index);
}

Fixed version (ground truth):
/** 
 * returns the x-value at the given index
 * @param index
 * @return
 */
public String getXValue(int index){
  if (mXVals == null || mXVals.size() <= index)   return null;
 else   return mXVals.get(index);
}
Program: 18998
Project: 18998
Buggy source:
/** 
 * returns true if there are values to highlight, false if there are not checks if the highlight array is null, has a length of zero or contains -1
 * @return
 */
public boolean valuesToHighlight(){
  return mIndicesToHightlight == null || mIndicesToHightlight.length == 0 || mIndicesToHightlight[0] == -1 ? false : true;
}

Fixed version (ground truth):
/** 
 * returns true if there are values to highlight, false if there are not checks if the highlight array is null, has a length of zero or contains -1
 * @return
 */
public boolean valuesToHighlight(){
  return mIndicesToHightlight == null || mIndicesToHightlight.length == 0 || mIndicesToHightlight[0] < 0 ? false : true;
}
Program: 18999
Project: 18999
Buggy source:
@Override protected void drawHighlights(){
  if (mHighlightEnabled && valuesToHighlight()) {
    for (int i=0; i < mIndicesToHightlight.length; i++) {
      int index=mIndicesToHightlight[i];
      if (index < mYVals.size()) {
        float[] pts=new float[]{index,mYChartMax,index,mYChartMin,0,mYVals.get(index).getVal(),mDeltaX,mYVals.get(index).getVal()};
        transformPointArray(pts);
        mDrawCanvas.drawLines(pts,mHighlightPaint);
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void drawHighlights(){
  if (mHighlightEnabled && valuesToHighlight()) {
    for (int i=0; i < mIndicesToHightlight.length; i++) {
      int index=mIndicesToHightlight[i];
      if (index < mYVals.size() && index >= 0) {
        float[] pts=new float[]{index,mYChartMax,index,mYChartMin,0,mYVals.get(index).getVal(),mDeltaX,mYVals.get(index).getVal()};
        transformPointArray(pts);
        mDrawCanvas.drawLines(pts,mHighlightPaint);
      }
    }
  }
}
Program: 19000
Project: 19000
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_linechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setDrawYValues(false);
  mChart.setLineWidth(4f);
  mChart.setCircleSize(4f);
  mChart.setYLegendCount(6);
  mChart.setTouchEnabled(true);
  mChart.setHighlightEnabled(true);
  mChart.setDragEnabled(true);
  mChart.setTouchEnabled(true);
  TextView textView=new TextView(this);
  textView.setVisibility(View.VISIBLE);
  textView.setBackgroundColor(Color.WHITE);
  textView.setPadding(15,15,15,15);
  textView.setText("String_Node_Str");
  mChart.setDrawMarkerView(true);
  mChart.setMarkerView(textView);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_linechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setColorTemplate(new ColorTemplate(ColorTemplate.getColors(this,ColorTemplate.JOYFUL_COLORS)));
  mChart.setDrawTopYLegendEntry(false);
  mChart.setDrawYValues(false);
  mChart.setLineWidth(5f);
  mChart.setCircleSize(5f);
  mChart.setYLegendCount(6);
  mChart.setTouchEnabled(true);
  mChart.setHighlightEnabled(true);
  mChart.setDragEnabled(true);
  mChart.setTouchEnabled(true);
  TextView textView=new TextView(this);
  textView.setVisibility(View.VISIBLE);
  textView.setBackgroundColor(Color.WHITE);
  textView.setPadding(15,15,15,15);
  textView.setText("String_Node_Str");
  mChart.setDrawMarkerView(true);
  mChart.setMarkerView(textView);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
}
Program: 19001
Project: 19001
Buggy source:
/** 
 * draws the circle value indicators
 */
@Override protected void drawAdditional(){
  if (mDrawCircles) {
    ArrayList<DataSet> dataSets=mData.getDataSets();
    for (int i=0; i < mData.getDataSetCount(); i++) {
      DataSet dataSet=dataSets.get(i);
      ArrayList<Series> series=dataSet.getYVals();
      float[] positions=new float[dataSet.getYValCount() * 2];
      for (int j=0; j < positions.length; j+=2) {
        positions[j]=series.get(j / 2).getXIndex();
        positions[j + 1]=series.get(j / 2).getVal();
      }
      transformPointArray(positions);
      for (int j=0; j < positions.length; j+=2) {
        if (positions[j] < mContentRect.left || positions[j] > mContentRect.right)         continue;
        mDrawCanvas.drawCircle(positions[j],positions[j + 1],mCircleSize,mCirclePaintOuter);
        mDrawCanvas.drawCircle(positions[j],positions[j + 1],mCircleSize / 2,mCirclePaintInner);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * draws the circle value indicators
 */
@Override protected void drawAdditional(){
  if (mDrawCircles) {
    ArrayList<DataSet> dataSets=mData.getDataSets();
    for (int i=0; i < mData.getDataSetCount(); i++) {
      DataSet dataSet=dataSets.get(i);
      ArrayList<Series> series=dataSet.getYVals();
      float[] positions=new float[dataSet.getYValCount() * 2];
      for (int j=0; j < positions.length; j+=2) {
        positions[j]=series.get(j / 2).getXIndex();
        positions[j + 1]=series.get(j / 2).getVal();
      }
      transformPointArray(positions);
      for (int j=0; j < positions.length; j+=2) {
        if (positions[j] < mContentRect.left || positions[j] > mContentRect.right)         continue;
        mDrawCanvas.drawCircle(positions[j],positions[j + 1],mCircleSize,mDrawPaints[i % mDrawPaints.length]);
        mDrawCanvas.drawCircle(positions[j],positions[j + 1],mCircleSize / 2,mCirclePaintInner);
      }
    }
  }
}
Program: 19002
Project: 19002
Buggy source:
@Override protected void prepareDataPaints(ColorTemplate ct){
  if (ct == null)   return;
  mDrawPaints=new Paint[ct.getColors().size()];
  for (int i=0; i < ct.getColors().size(); i++) {
    mDrawPaints[i]=new Paint(Paint.ANTI_ALIAS_FLAG);
    mDrawPaints[i].setStrokeWidth(mLineWidth);
    mDrawPaints[i].setStyle(Style.STROKE);
    mDrawPaints[i].setColor(ct.getColors().get(i));
  }
}

Fixed version (ground truth):
@Override protected void prepareDataPaints(ColorTemplate ct){
  if (ct == null)   return;
  mDrawPaints=new Paint[ct.getColors().size()];
  for (int i=0; i < ct.getColors().size(); i++) {
    mDrawPaints[i]=new Paint(Paint.ANTI_ALIAS_FLAG);
    mDrawPaints[i].setStrokeWidth(mLineWidth);
    mDrawPaints[i].setStyle(Style.FILL);
    mDrawPaints[i].setColor(ct.getColors().get(i));
  }
}
Program: 19003
Project: 19003
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_barchart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(BarChart)findViewById(R.id.chart1);
  mChart.setColorTemplate(new ColorTemplate(ColorTemplate.getColors(this,ColorTemplate.FRESH_COLORS)));
  mChart.setDrawValues(false);
  mChart.set3DEnabled(false);
  mChart.setDrawAdditional(true);
  mChart.setYLegendCount(5);
  mChart.setTouchEnabled(true);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_barchart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(BarChart)findViewById(R.id.chart1);
  mChart.setColorTemplate(new ColorTemplate(ColorTemplate.getColors(this,ColorTemplate.FRESH_COLORS)));
  mChart.setDrawValues(false);
  mChart.set3DEnabled(false);
  mChart.setYLegendCount(5);
  mChart.setTouchEnabled(true);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
}
Program: 19004
Project: 19004
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_linechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setDrawValues(false);
  mChart.setLineWidth(5f);
  mChart.setCircleSize(5f);
  mChart.setDrawAdditional(true);
  mChart.setYLegendCount(6);
  mChart.setTouchEnabled(true);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(R.layout.activity_linechart);
  tvX=(TextView)findViewById(R.id.tvXMax);
  tvY=(TextView)findViewById(R.id.tvYMax);
  mSeekBarX=(SeekBar)findViewById(R.id.seekBar1);
  mSeekBarX.setOnSeekBarChangeListener(this);
  mSeekBarY=(SeekBar)findViewById(R.id.seekBar2);
  mSeekBarY.setOnSeekBarChangeListener(this);
  mChart=(LineChart)findViewById(R.id.chart1);
  mChart.setDrawValues(false);
  mChart.setLineWidth(5f);
  mChart.setCircleSize(5f);
  mChart.setYLegendCount(6);
  mChart.setTouchEnabled(true);
  mSeekBarX.setProgress(45);
  mSeekBarY.setProgress(100);
}
Program: 19005
Project: 19005
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.actionToggleRound:
{
      if (mChart.isYLegendRounded())       mChart.setRoundedYLegend(false);
 else       mChart.setRoundedYLegend(true);
      mChart.invalidate();
      break;
    }
case R.id.actionToggleValues:
{
    if (mChart.isDrawValuesEnabled())     mChart.setDrawValues(false);
 else     mChart.setDrawValues(true);
    mChart.invalidate();
    break;
  }
case R.id.actionToggleFilled:
{
  if (mChart.isDrawFilledEnabled())   mChart.setDrawFilled(false);
 else   mChart.setDrawFilled(true);
  mChart.invalidate();
  break;
}
case R.id.actionToggleCircles:
{
if (mChart.isDrawAdditionalEnabled()) mChart.setDrawAdditional(false);
 else mChart.setDrawAdditional(true);
mChart.invalidate();
break;
}
case R.id.actionToggleStartzero:
{
if (mChart.isStartAtZeroEnabled()) mChart.setStartAtZero(false);
 else mChart.setStartAtZero(true);
mChart.invalidate();
break;
}
case R.id.actionToggleAdjustXLegend:
{
if (mChart.isAdjustXLegendEnabled()) mChart.setAdjustXLegend(false);
 else mChart.setAdjustXLegend(true);
mChart.invalidate();
break;
}
case R.id.actionSave:
{
mChart.saveToPath("String_Node_Str" + System.currentTimeMillis(),"String_Node_Str");
break;
}
}
return true;
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.actionToggleRound:
{
      if (mChart.isYLegendRounded())       mChart.setRoundedYLegend(false);
 else       mChart.setRoundedYLegend(true);
      mChart.invalidate();
      break;
    }
case R.id.actionToggleValues:
{
    if (mChart.isDrawValuesEnabled())     mChart.setDrawValues(false);
 else     mChart.setDrawValues(true);
    mChart.invalidate();
    break;
  }
case R.id.actionToggleFilled:
{
  if (mChart.isDrawFilledEnabled())   mChart.setDrawFilled(false);
 else   mChart.setDrawFilled(true);
  mChart.invalidate();
  break;
}
case R.id.actionToggleCircles:
{
if (mChart.isDrawCirclesEnabled()) mChart.setDrawCircles(false);
 else mChart.setDrawCircles(true);
mChart.invalidate();
break;
}
case R.id.actionToggleStartzero:
{
if (mChart.isStartAtZeroEnabled()) mChart.setStartAtZero(false);
 else mChart.setStartAtZero(true);
mChart.invalidate();
break;
}
case R.id.actionToggleAdjustXLegend:
{
if (mChart.isAdjustXLegendEnabled()) mChart.setAdjustXLegend(false);
 else mChart.setAdjustXLegend(true);
mChart.invalidate();
break;
}
case R.id.actionSave:
{
mChart.saveToPath("String_Node_Str" + System.currentTimeMillis(),"String_Node_Str");
break;
}
}
return true;
}
Program: 19006
Project: 19006
Buggy source:
/** 
 * draws the circle value indicators
 */
@Override protected void drawAdditional(){
  if (!mDrawAdditional)   return;
  if (mDrawCircles) {
    float[] positions=new float[mYVals.size() * 2];
    for (int i=0; i < positions.length; i+=2) {
      positions[i]=i / 2;
      positions[i + 1]=mYVals.get(i / 2);
    }
    transformPointArray(positions);
    for (int i=0; i < positions.length; i+=2) {
      mDrawCanvas.drawCircle(positions[i],positions[i + 1],mCircleSize,mCirclePaintOuter);
      mDrawCanvas.drawCircle(positions[i],positions[i + 1],mCircleSize / 2,mCirclePaintInner);
    }
  }
}

Fixed version (ground truth):
/** 
 * draws the circle value indicators
 */
@Override protected void drawAdditional(){
  if (mDrawCircles) {
    float[] positions=new float[mYVals.size() * 2];
    for (int i=0; i < positions.length; i+=2) {
      positions[i]=i / 2;
      positions[i + 1]=mYVals.get(i / 2);
    }
    transformPointArray(positions);
    for (int i=0; i < positions.length; i+=2) {
      mDrawCanvas.drawCircle(positions[i],positions[i + 1],mCircleSize,mCirclePaintOuter);
      mDrawCanvas.drawCircle(positions[i],positions[i + 1],mCircleSize / 2,mCirclePaintInner);
    }
  }
}
Program: 19007
Project: 19007
Buggy source:
@Override public void onFiltersChanged(TagFilterHolder filters){
  CharSequence filtersDesc=filters.describeFilters(getResources(),getContext().getTheme());
  mFiltersDescription.setText(filtersDesc);
  if (filters.hasAnyFilters()) {
    mFiltersBar.setVisibility(VISIBLE);
    mContent.setTranslationY(mFiltersBar.getHeight());
  }
 else {
    mFiltersBar.setVisibility(INVISIBLE);
    mContent.setTranslationY(0f);
  }
}

Fixed version (ground truth):
@Override public void onFiltersChanged(TagFilterHolder filters){
  CharSequence filtersDesc=filters.describeFilters(getResources(),getContext().getTheme());
  mFiltersDescription.setText(filtersDesc);
  if (filters.hasAnyFilters()) {
    mFiltersBar.setVisibility(VISIBLE);
    mContent.setTranslationY(mFiltersBar.getHeight());
    offsetFilters(mFiltersBar.getHeight(),0);
  }
 else {
    mFiltersBar.setVisibility(INVISIBLE);
    offsetFilters(mFiltersBar.getHeight(),0);
    mContent.setTranslationY(0f);
  }
}
Program: 19009
Project: 19009
Buggy source:
public void updateMenuView(){
  final int menuSize=mMenu.size();
  if (menuSize != mButtons.length) {
    buildMenuView();
    return;
  }
  int previousSelectedId=mSelectedItemId;
  for (int i=0; i < menuSize; i++) {
    MenuItem item=mMenu.getItem(i);
    if (item.isChecked()) {
      mSelectedItemId=item.getItemId();
      mSelectedItemPosition=i;
    }
  }
  if (previousSelectedId != mSelectedItemId) {
    TransitionManager.beginDelayedTransition(this,mSet);
  }
  for (int i=0; i < menuSize; i++) {
    mPresenter.setUpdateSuspended(true);
    if (mButtons[i] != null) {
      mButtons[i].initialize((MenuItemImpl)mMenu.getItem(i),0);
    }
    mPresenter.setUpdateSuspended(false);
  }
}

Fixed version (ground truth):
public void updateMenuView(){
  if (mMenu == null || mButtons == null)   return;
  final int menuSize=mMenu.size();
  if (menuSize != mButtons.length) {
    buildMenuView();
    return;
  }
  int previousSelectedId=mSelectedItemId;
  for (int i=0; i < menuSize; i++) {
    MenuItem item=mMenu.getItem(i);
    if (item.isChecked()) {
      mSelectedItemId=item.getItemId();
      mSelectedItemPosition=i;
    }
  }
  if (previousSelectedId != mSelectedItemId) {
    TransitionManager.beginDelayedTransition(this,mSet);
  }
  for (int i=0; i < menuSize; i++) {
    mPresenter.setUpdateSuspended(true);
    if (mButtons[i] != null) {
      mButtons[i].initialize((MenuItemImpl)mMenu.getItem(i),0);
    }
    mPresenter.setUpdateSuspended(false);
  }
}
Program: 19010
Project: 19010
Buggy source:
@Override public void onFiltersChanged(TagFilterHolder filters){
  CharSequence filtersDesc=filters.describeFilters(getResources(),getContext().getTheme());
  mFiltersDescription.setText(filtersDesc);
  if (filters.hasAnyFilters()) {
    mFiltersBar.setVisibility(VISIBLE);
    mContent.setTranslationY(mFiltersBar.getHeight());
  }
 else {
    mFiltersBar.setVisibility(INVISIBLE);
    mContent.setTranslationY(0f);
  }
}

Fixed version (ground truth):
@Override public void onFiltersChanged(TagFilterHolder filters){
  CharSequence filtersDesc=filters.describeFilters(getResources(),getContext().getTheme());
  mFiltersDescription.setText(filtersDesc);
  if (filters.hasAnyFilters()) {
    mFiltersBar.setVisibility(VISIBLE);
    mContent.setTranslationY(mFiltersBar.getHeight());
    offsetFilters(mFiltersBar.getHeight(),0);
  }
 else {
    mFiltersBar.setVisibility(INVISIBLE);
    offsetFilters(mFiltersBar.getHeight(),0);
    mContent.setTranslationY(0f);
  }
}
Program: 19012
Project: 19012
Buggy source:
@Override public void onAddEventsClicked(int conferenceDay){
  AnalyticsHelper.sendEvent("String_Node_Str","String_Node_Str",String.valueOf(conferenceDay));
  ScheduleActivity.launchScheduleForConferenceDay(getContext(),conferenceDay);
}

Fixed version (ground truth):
@Override public void onAddEventsClicked(int conferenceDay){
  AnalyticsHelper.sendEvent("String_Node_Str","String_Node_Str",String.valueOf(conferenceDay));
  ScheduleActivity.launchScheduleForConferenceDay(getContext(),conferenceDay);
  getActivity().finish();
}
Program: 19014
Project: 19014
Buggy source:
SessionsFilterAdapter(Context context,TagMetadata filters,Bundle savedState){
  mInflater=LayoutInflater.from(context);
  mItems=new ArrayList<>();
  buildFiltersList(filters);
  restoreFromState(savedState);
}

Fixed version (ground truth):
SessionsFilterAdapter(Context context,TagMetadata filters,Bundle savedState){
  restoreFromState(savedState);
  mInflater=LayoutInflater.from(context);
  mItems=new ArrayList<>();
  buildFiltersList(filters);
}
Program: 19015
Project: 19015
Buggy source:
private void restoreFromState(Bundle savedState){
  if (savedState != null) {
    TagFilterHolder filterHolder=savedState.getParcelable(STATE_FILTERS);
    if (filterHolder != null) {
      mTagFilterHolder=filterHolder;
    }
  }
}

Fixed version (ground truth):
private void restoreFromState(Bundle savedState){
  if (savedState != null) {
    TagFilterHolder filterHolder=savedState.getParcelable(STATE_FILTERS);
    if (filterHolder != null) {
      mTagFilterHolder=filterHolder;
    }
  }
  if (mTagFilterHolder == null) {
    mTagFilterHolder=new TagFilterHolder();
  }
}
Program: 19016
Project: 19016
Buggy source:
/** 
 * @param tag The tag to check in the filter
 * @return boolean Return a boolean indicating that the tagId is present.
 */
public boolean contains(Tag tag){
  return mSelectedTopics.contains(tag) || mSelectedTopics.contains(tag);
}

Fixed version (ground truth):
/** 
 * @param tag The tag to check in the filter
 * @return boolean Return a boolean indicating that the tagId is present.
 */
public boolean contains(Tag tag){
  return mSelectedTypes.contains(tag) || mSelectedTopics.contains(tag);
}
Program: 19018
Project: 19018
Buggy source:
SessionsFilterAdapter(Context context,TagMetadata filters,Bundle savedState){
  mInflater=LayoutInflater.from(context);
  mItems=new ArrayList<>();
  buildFiltersList(filters);
  restoreFromState(savedState);
}

Fixed version (ground truth):
SessionsFilterAdapter(Context context,TagMetadata filters,Bundle savedState){
  restoreFromState(savedState);
  mInflater=LayoutInflater.from(context);
  mItems=new ArrayList<>();
  buildFiltersList(filters);
}
Program: 19019
Project: 19019
Buggy source:
private void restoreFromState(Bundle savedState){
  if (savedState != null) {
    TagFilterHolder filterHolder=savedState.getParcelable(STATE_FILTERS);
    if (filterHolder != null) {
      mTagFilterHolder=filterHolder;
    }
  }
}

Fixed version (ground truth):
private void restoreFromState(Bundle savedState){
  if (savedState != null) {
    TagFilterHolder filterHolder=savedState.getParcelable(STATE_FILTERS);
    if (filterHolder != null) {
      mTagFilterHolder=filterHolder;
    }
  }
  if (mTagFilterHolder == null) {
    mTagFilterHolder=new TagFilterHolder();
  }
}
Program: 19020
Project: 19020
Buggy source:
/** 
 * @param tag The tag to check in the filter
 * @return boolean Return a boolean indicating that the tagId is present.
 */
public boolean contains(Tag tag){
  return mSelectedTopics.contains(tag) || mSelectedTopics.contains(tag);
}

Fixed version (ground truth):
/** 
 * @param tag The tag to check in the filter
 * @return boolean Return a boolean indicating that the tagId is present.
 */
public boolean contains(Tag tag){
  return mSelectedTypes.contains(tag) || mSelectedTopics.contains(tag);
}
Program: 19021
Project: 19021
Buggy source:
@Override public void onAddEventsClicked(int conferenceDay){
  AnalyticsHelper.sendEvent("String_Node_Str","String_Node_Str",String.valueOf(conferenceDay));
  ScheduleActivity.launchScheduleForConferenceDay(getContext(),conferenceDay);
}

Fixed version (ground truth):
@Override public void onAddEventsClicked(int conferenceDay){
  AnalyticsHelper.sendEvent("String_Node_Str","String_Node_Str",String.valueOf(conferenceDay));
  ScheduleActivity.launchScheduleForConferenceDay(getContext(),conferenceDay);
  getActivity().finish();
}
Program: 19022
Project: 19022
Buggy source:
private void updateReservationStatus(ScheduleItem item){
  if (FirebaseAuth.getInstance().getCurrentUser() == null || RegistrationUtils.isRegisteredAttendee(mReservationStatus.getContext()) != RegistrationUtils.REGSTATUS_REGISTERED || item.isKeynote() || item.reservationStatus == RESERVATION_STATUS_UNRESERVED) {
    mReservationStatus.setVisibility(GONE);
    return;
  }
  if (item.reservationStatus == RESERVATION_STATUS_RESERVED || item.reservationStatus == RESERVATION_STATUS_WAITLISTED) {
    mReservationStatus.setVisibility(VISIBLE);
    mReservationStatus.setCompoundDrawablesWithIntrinsicBounds(item.reservationStatus == RESERVATION_STATUS_RESERVED ? R.drawable.ic_reserved : R.drawable.ic_waitlisted,0,0,0);
    mReservationStatus.setText(item.reservationStatus == RESERVATION_STATUS_RESERVED ? R.string.schedule_item_reserved : R.string.schedule_item_waitlisted);
  }
}

Fixed version (ground truth):
private void updateReservationStatus(ScheduleItem item){
  if (item.reservationStatus == RESERVATION_STATUS_RESERVED || item.reservationStatus == RESERVATION_STATUS_WAITLISTED) {
    mReservationStatus.setVisibility(VISIBLE);
    mReservationStatus.setCompoundDrawablesWithIntrinsicBounds(item.reservationStatus == RESERVATION_STATUS_RESERVED ? R.drawable.ic_reserved : R.drawable.ic_waitlisted,0,0,0);
    mReservationStatus.setText(item.reservationStatus == RESERVATION_STATUS_RESERVED ? R.string.schedule_item_reserved : R.string.schedule_item_waitlisted);
  }
 else {
    mReservationStatus.setVisibility(GONE);
  }
}
Program: 19023
Project: 19023
Buggy source:
private void updateReservationStatus(ScheduleItem item){
  if (FirebaseAuth.getInstance().getCurrentUser() == null || RegistrationUtils.isRegisteredAttendee(mReservationStatus.getContext()) != RegistrationUtils.REGSTATUS_REGISTERED || item.isKeynote() || item.reservationStatus == RESERVATION_STATUS_UNRESERVED) {
    mReservationStatus.setVisibility(GONE);
    return;
  }
  if (item.reservationStatus == RESERVATION_STATUS_RESERVED || item.reservationStatus == RESERVATION_STATUS_WAITLISTED) {
    mReservationStatus.setVisibility(VISIBLE);
    mReservationStatus.setCompoundDrawablesWithIntrinsicBounds(item.reservationStatus == RESERVATION_STATUS_RESERVED ? R.drawable.ic_reserved : R.drawable.ic_waitlisted,0,0,0);
    mReservationStatus.setText(item.reservationStatus == RESERVATION_STATUS_RESERVED ? R.string.schedule_item_reserved : R.string.schedule_item_waitlisted);
  }
}

Fixed version (ground truth):
private void updateReservationStatus(ScheduleItem item){
  if (item.reservationStatus == RESERVATION_STATUS_RESERVED || item.reservationStatus == RESERVATION_STATUS_WAITLISTED) {
    mReservationStatus.setVisibility(VISIBLE);
    mReservationStatus.setCompoundDrawablesWithIntrinsicBounds(item.reservationStatus == RESERVATION_STATUS_RESERVED ? R.drawable.ic_reserved : R.drawable.ic_waitlisted,0,0,0);
    mReservationStatus.setText(item.reservationStatus == RESERVATION_STATUS_RESERVED ? R.string.schedule_item_reserved : R.string.schedule_item_waitlisted);
  }
 else {
    mReservationStatus.setVisibility(GONE);
  }
}
Program: 19024
Project: 19024
Buggy source:
public ReserveButton(Context context,AttributeSet attrs){
  super(context,attrs,R.attr.reserveButtonStyle);
  LayoutInflater.from(context).inflate(R.layout.reserve_button,this,true);
  text=(TextView)findViewById(R.id.reserve_text);
  text.setText(status.text);
}

Fixed version (ground truth):
public ReserveButton(Context context,AttributeSet attrs){
  super(context,attrs,R.attr.reserveButtonStyle);
  LayoutInflater.from(context).inflate(R.layout.reserve_button,this,true);
  text=(TextView)findViewById(R.id.reserve_text);
  setStatus(ReservationStatus.RESERVABLE);
}
Program: 19025
Project: 19025
Buggy source:
public void setStatus(ReservationStatus status){
  this.status=status;
  refreshDrawableState();
  text.setText(status.text);
}

Fixed version (ground truth):
public void setStatus(ReservationStatus status){
  if (this.status == status)   return;
  this.status=status;
  refreshDrawableState();
  text.setText(status.text);
}
Program: 19026
Project: 19026
Buggy source:
public ReserveButton(Context context,AttributeSet attrs){
  super(context,attrs,R.attr.reserveButtonStyle);
  LayoutInflater.from(context).inflate(R.layout.reserve_button,this,true);
  text=(TextView)findViewById(R.id.reserve_text);
  text.setText(status.text);
}

Fixed version (ground truth):
public ReserveButton(Context context,AttributeSet attrs){
  super(context,attrs,R.attr.reserveButtonStyle);
  LayoutInflater.from(context).inflate(R.layout.reserve_button,this,true);
  text=(TextView)findViewById(R.id.reserve_text);
  setStatus(ReservationStatus.RESERVABLE);
}