nus-yam/ex-repair huggingface dataset:
Program: 26634
Project: 26634
Buggy source:
public void animateCheck(){
  changeBackground();
  ObjectAnimator objectAnimator;
  if (check) {
    objectAnimator=ObjectAnimator.ofFloat(this,"String_Node_Str",ball.xFin);
  }
 else {
    objectAnimator=ObjectAnimator.ofFloat(this,"String_Node_Str",ball.xIni);
  }
  objectAnimator.setDuration(300);
  objectAnimator.start();
}

Fixed version (ground truth):
public void animateCheck(){
  changeBackground();
  ObjectAnimator objectAnimator;
  if (eventCheck) {
    objectAnimator=ObjectAnimator.ofFloat(this,"String_Node_Str",ball.xFin);
  }
 else {
    objectAnimator=ObjectAnimator.ofFloat(this,"String_Node_Str",ball.xIni);
  }
  objectAnimator.setDuration(300);
  objectAnimator.start();
}
Program: 26635
Project: 26635
Buggy source:
public void setChecked(boolean check){
  invalidate();
  this.check=check;
  ball.animateCheck();
}

Fixed version (ground truth):
public void setChecked(boolean check){
  invalidate();
  this.check=check;
  this.eventCheck=check;
  ball.animateCheck();
}
Program: 26636
Project: 26636
Buggy source:
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  if (!placedBall)   placeBall();
  Bitmap bitmap=Bitmap.createBitmap(canvas.getWidth(),canvas.getHeight(),Bitmap.Config.ARGB_8888);
  Canvas temp=new Canvas(bitmap);
  Paint paint=new Paint();
  paint.setAntiAlias(true);
  paint.setColor((check) ? backgroundColor : Color.parseColor("String_Node_Str"));
  paint.setStrokeWidth(Utils.dpToPx(2,getResources()));
  temp.drawLine(getHeight() / 2,getHeight() / 2,getWidth() - getHeight() / 2,getHeight() / 2,paint);
  Paint transparentPaint=new Paint();
  transparentPaint.setAntiAlias(true);
  transparentPaint.setColor(getResources().getColor(android.R.color.transparent));
  transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
  temp.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,ViewHelper.getY(ball) + ball.getHeight() / 2,ball.getWidth() / 2,transparentPaint);
  canvas.drawBitmap(bitmap,0,0,new Paint());
  if (press) {
    paint.setColor((check) ? makePressColor() : Color.parseColor("String_Node_Str"));
    canvas.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,getHeight() / 2,getHeight() / 2,paint);
  }
  invalidate();
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  if (!placedBall)   placeBall();
  Bitmap bitmap=Bitmap.createBitmap(canvas.getWidth(),canvas.getHeight(),Bitmap.Config.ARGB_8888);
  Canvas temp=new Canvas(bitmap);
  Paint paint=new Paint();
  paint.setAntiAlias(true);
  paint.setColor((eventCheck) ? backgroundColor : Color.parseColor("String_Node_Str"));
  paint.setStrokeWidth(Utils.dpToPx(2,getResources()));
  temp.drawLine(getHeight() / 2,getHeight() / 2,getWidth() - getHeight() / 2,getHeight() / 2,paint);
  Paint transparentPaint=new Paint();
  transparentPaint.setAntiAlias(true);
  transparentPaint.setColor(getResources().getColor(android.R.color.transparent));
  transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
  temp.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,ViewHelper.getY(ball) + ball.getHeight() / 2,ball.getWidth() / 2,transparentPaint);
  canvas.drawBitmap(bitmap,0,0,new Paint());
  if (press) {
    paint.setColor((check) ? makePressColor() : Color.parseColor("String_Node_Str"));
    canvas.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,getHeight() / 2,getHeight() / 2,paint);
  }
  invalidate();
}
Program: 26637
Project: 26637
Buggy source:
public void changeBackground(){
  if (check) {
    setBackgroundResource(R.drawable.background_checkbox);
    LayerDrawable layer=(LayerDrawable)getBackground();
    GradientDrawable shape=(GradientDrawable)layer.findDrawableByLayerId(R.id.shape_bacground);
    shape.setColor(backgroundColor);
  }
 else {
    setBackgroundResource(R.drawable.background_switch_ball_uncheck);
  }
}

Fixed version (ground truth):
public void changeBackground(){
  if (eventCheck) {
    setBackgroundResource(R.drawable.background_checkbox);
    LayerDrawable layer=(LayerDrawable)getBackground();
    GradientDrawable shape=(GradientDrawable)layer.findDrawableByLayerId(R.id.shape_bacground);
    shape.setColor(backgroundColor);
  }
 else {
    setBackgroundResource(R.drawable.background_switch_ball_uncheck);
  }
}
Program: 26638
Project: 26638
Buggy source:
@Override public boolean onTouchEvent(MotionEvent event){
  if (isEnabled()) {
    isLastTouch=true;
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
      press=true;
    }
 else     if (event.getAction() == MotionEvent.ACTION_MOVE) {
      float x=event.getX();
      x=(x < ball.xIni) ? ball.xIni : x;
      x=(x > ball.xFin) ? ball.xFin : x;
      if (x > ball.xCen) {
        check=true;
      }
 else {
        check=false;
      }
      ViewHelper.setX(ball,x);
      ball.changeBackground();
      if ((event.getX() <= getWidth() && event.getX() >= 0)) {
        isLastTouch=false;
        press=false;
      }
    }
 else     if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
      press=false;
      isLastTouch=false;
      if (eventCheck != check) {
        eventCheck=check;
        if (onCheckListener != null)         onCheckListener.onCheck(check);
      }
      if ((event.getX() <= getWidth() && event.getX() >= 0)) {
        ball.animateCheck();
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent event){
  if (isEnabled()) {
    isLastTouch=true;
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
      press=true;
    }
 else     if (event.getAction() == MotionEvent.ACTION_MOVE) {
      float x=event.getX();
      x=(x < ball.xIni) ? ball.xIni : x;
      x=(x > ball.xFin) ? ball.xFin : x;
      if (x > ball.xCen) {
        eventCheck=true;
      }
 else {
        eventCheck=false;
      }
      ViewHelper.setX(ball,x);
      ball.changeBackground();
      if ((event.getX() <= getWidth() && event.getX() >= 0)) {
        isLastTouch=false;
        press=false;
      }
    }
 else     if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
      press=false;
      isLastTouch=false;
      if (eventCheck != check) {
        check=eventCheck;
        if (onCheckListener != null)         onCheckListener.onCheck(check);
      }
      if ((event.getX() <= getWidth() && event.getX() >= 0)) {
        ball.animateCheck();
      }
    }
  }
  return true;
}
Program: 26639
Project: 26639
Buggy source:
public void animateCheck(){
  changeBackground();
  ObjectAnimator objectAnimator;
  if (check) {
    objectAnimator=ObjectAnimator.ofFloat(this,"String_Node_Str",ball.xFin);
  }
 else {
    objectAnimator=ObjectAnimator.ofFloat(this,"String_Node_Str",ball.xIni);
  }
  objectAnimator.setDuration(300);
  objectAnimator.start();
}

Fixed version (ground truth):
public void animateCheck(){
  changeBackground();
  ObjectAnimator objectAnimator;
  if (eventCheck) {
    objectAnimator=ObjectAnimator.ofFloat(this,"String_Node_Str",ball.xFin);
  }
 else {
    objectAnimator=ObjectAnimator.ofFloat(this,"String_Node_Str",ball.xIni);
  }
  objectAnimator.setDuration(300);
  objectAnimator.start();
}
Program: 26640
Project: 26640
Buggy source:
public void setChecked(boolean check){
  invalidate();
  this.check=check;
  ball.animateCheck();
}

Fixed version (ground truth):
public void setChecked(boolean check){
  invalidate();
  this.check=check;
  this.eventCheck=check;
  ball.animateCheck();
}
Program: 26641
Project: 26641
Buggy source:
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  if (!placedBall)   placeBall();
  Bitmap bitmap=Bitmap.createBitmap(canvas.getWidth(),canvas.getHeight(),Bitmap.Config.ARGB_8888);
  Canvas temp=new Canvas(bitmap);
  Paint paint=new Paint();
  paint.setAntiAlias(true);
  paint.setColor((check) ? backgroundColor : Color.parseColor("String_Node_Str"));
  paint.setStrokeWidth(Utils.dpToPx(2,getResources()));
  temp.drawLine(getHeight() / 2,getHeight() / 2,getWidth() - getHeight() / 2,getHeight() / 2,paint);
  Paint transparentPaint=new Paint();
  transparentPaint.setAntiAlias(true);
  transparentPaint.setColor(getResources().getColor(android.R.color.transparent));
  transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
  temp.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,ViewHelper.getY(ball) + ball.getHeight() / 2,ball.getWidth() / 2,transparentPaint);
  canvas.drawBitmap(bitmap,0,0,new Paint());
  if (press) {
    paint.setColor((check) ? makePressColor() : Color.parseColor("String_Node_Str"));
    canvas.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,getHeight() / 2,getHeight() / 2,paint);
  }
  invalidate();
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  if (!placedBall)   placeBall();
  Bitmap bitmap=Bitmap.createBitmap(canvas.getWidth(),canvas.getHeight(),Bitmap.Config.ARGB_8888);
  Canvas temp=new Canvas(bitmap);
  Paint paint=new Paint();
  paint.setAntiAlias(true);
  paint.setColor((eventCheck) ? backgroundColor : Color.parseColor("String_Node_Str"));
  paint.setStrokeWidth(Utils.dpToPx(2,getResources()));
  temp.drawLine(getHeight() / 2,getHeight() / 2,getWidth() - getHeight() / 2,getHeight() / 2,paint);
  Paint transparentPaint=new Paint();
  transparentPaint.setAntiAlias(true);
  transparentPaint.setColor(getResources().getColor(android.R.color.transparent));
  transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
  temp.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,ViewHelper.getY(ball) + ball.getHeight() / 2,ball.getWidth() / 2,transparentPaint);
  canvas.drawBitmap(bitmap,0,0,new Paint());
  if (press) {
    paint.setColor((check) ? makePressColor() : Color.parseColor("String_Node_Str"));
    canvas.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,getHeight() / 2,getHeight() / 2,paint);
  }
  invalidate();
}
Program: 26642
Project: 26642
Buggy source:
public void changeBackground(){
  if (check) {
    setBackgroundResource(R.drawable.background_checkbox);
    LayerDrawable layer=(LayerDrawable)getBackground();
    GradientDrawable shape=(GradientDrawable)layer.findDrawableByLayerId(R.id.shape_bacground);
    shape.setColor(backgroundColor);
  }
 else {
    setBackgroundResource(R.drawable.background_switch_ball_uncheck);
  }
}

Fixed version (ground truth):
public void changeBackground(){
  if (eventCheck) {
    setBackgroundResource(R.drawable.background_checkbox);
    LayerDrawable layer=(LayerDrawable)getBackground();
    GradientDrawable shape=(GradientDrawable)layer.findDrawableByLayerId(R.id.shape_bacground);
    shape.setColor(backgroundColor);
  }
 else {
    setBackgroundResource(R.drawable.background_switch_ball_uncheck);
  }
}
Program: 26643
Project: 26643
Buggy source:
@Override public boolean onTouchEvent(MotionEvent event){
  isLastTouch=true;
  if (event.getAction() == MotionEvent.ACTION_DOWN) {
    press=true;
  }
 else   if (event.getAction() == MotionEvent.ACTION_MOVE) {
    float x=event.getX();
    x=(x < ball.xIni) ? ball.xIni : x;
    x=(x > ball.xFin) ? ball.xFin : x;
    if (x > ball.xCen) {
      check=true;
    }
 else {
      check=false;
    }
    ViewHelper.setX(ball,x);
    ball.changeBackground();
    if ((event.getX() <= getWidth() && event.getX() >= 0) && (event.getY() <= getHeight() && event.getY() >= 0)) {
      isLastTouch=false;
      press=false;
    }
  }
 else   if (event.getAction() == MotionEvent.ACTION_UP) {
    press=false;
    isLastTouch=false;
    if (eventCheck != check) {
      eventCheck=check;
      if (onCheckListener != null)       onCheckListener.onCheck(check);
    }
    if ((event.getX() <= getWidth() && event.getX() >= 0) && (event.getY() <= getHeight() && event.getY() >= 0)) {
      ball.animateCheck();
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent event){
  isLastTouch=true;
  if (event.getAction() == MotionEvent.ACTION_DOWN) {
    startRedraw();
    press=true;
  }
 else   if (event.getAction() == MotionEvent.ACTION_MOVE) {
    float x=event.getX();
    x=(x < ball.xIni) ? ball.xIni : x;
    x=(x > ball.xFin) ? ball.xFin : x;
    if (x > ball.xCen) {
      check=true;
    }
 else {
      check=false;
    }
    ViewHelper.setX(ball,x);
    ball.changeBackground();
    if ((event.getX() <= getWidth() && event.getX() >= 0) && (event.getY() <= getHeight() && event.getY() >= 0)) {
      isLastTouch=false;
      press=false;
    }
  }
 else   if (event.getAction() == MotionEvent.ACTION_UP) {
    press=false;
    isLastTouch=false;
    if (eventCheck != check) {
      eventCheck=check;
      if (onCheckListener != null)       onCheckListener.onCheck(check);
    }
    if ((event.getX() <= getWidth() && event.getX() >= 0) && (event.getY() <= getHeight() && event.getY() >= 0)) {
      ball.animateCheck();
    }
 else {
      stopRedraw();
    }
  }
  return true;
}
Program: 26644
Project: 26644
Buggy source:
public void animateCheck(){
  changeBackground();
  ObjectAnimator objectAnimator;
  if (check) {
    objectAnimator=ObjectAnimator.ofFloat(this,"String_Node_Str",ball.xFin);
  }
 else {
    objectAnimator=ObjectAnimator.ofFloat(this,"String_Node_Str",ball.xIni);
  }
  objectAnimator.setDuration(300);
  objectAnimator.start();
}

Fixed version (ground truth):
public void animateCheck(){
  changeBackground();
  ObjectAnimator objectAnimator;
  if (check) {
    objectAnimator=ObjectAnimator.ofFloat(this,"String_Node_Str",ball.xFin);
  }
 else {
    objectAnimator=ObjectAnimator.ofFloat(this,"String_Node_Str",ball.xIni);
  }
  objectAnimator.addListener(animatorListener);
  objectAnimator.setDuration(300);
  objectAnimator.start();
}
Program: 26645
Project: 26645
Buggy source:
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  if (!placedBall)   placeBall();
  Bitmap bitmap=Bitmap.createBitmap(canvas.getWidth(),canvas.getHeight(),Bitmap.Config.ARGB_8888);
  Canvas temp=new Canvas(bitmap);
  Paint paint=new Paint();
  paint.setAntiAlias(true);
  paint.setColor((check) ? backgroundColor : Color.parseColor("String_Node_Str"));
  paint.setStrokeWidth(Utils.dpToPx(2,getResources()));
  temp.drawLine(getHeight() / 2,getHeight() / 2,getWidth() - getHeight() / 2,getHeight() / 2,paint);
  Paint transparentPaint=new Paint();
  transparentPaint.setAntiAlias(true);
  transparentPaint.setColor(getResources().getColor(android.R.color.transparent));
  transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
  temp.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,ViewHelper.getY(ball) + ball.getHeight() / 2,ball.getWidth() / 2,transparentPaint);
  canvas.drawBitmap(bitmap,0,0,new Paint());
  if (press) {
    paint.setColor((check) ? makePressColor() : Color.parseColor("String_Node_Str"));
    canvas.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,getHeight() / 2,getHeight() / 2,paint);
  }
  invalidate();
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  if (!placedBall)   placeBall();
  Bitmap bitmap=Bitmap.createBitmap(canvas.getWidth(),canvas.getHeight(),Bitmap.Config.ARGB_8888);
  Canvas temp=new Canvas(bitmap);
  Paint paint=new Paint();
  paint.setAntiAlias(true);
  paint.setColor((check) ? backgroundColor : Color.parseColor("String_Node_Str"));
  paint.setStrokeWidth(Utils.dpToPx(2,getResources()));
  temp.drawLine(getHeight() / 2,getHeight() / 2,getWidth() - getHeight() / 2,getHeight() / 2,paint);
  Paint transparentPaint=new Paint();
  transparentPaint.setAntiAlias(true);
  transparentPaint.setColor(getResources().getColor(android.R.color.transparent));
  transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
  temp.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,ViewHelper.getY(ball) + ball.getHeight() / 2,ball.getWidth() / 2,transparentPaint);
  canvas.drawBitmap(bitmap,0,0,new Paint());
  if (press) {
    paint.setColor((check) ? makePressColor() : Color.parseColor("String_Node_Str"));
    canvas.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,getHeight() / 2,getHeight() / 2,paint);
  }
  if (canRedraw) {
    invalidate();
  }
}
Program: 26646
Project: 26646
Buggy source:
public void setBackgroundColor(int color){
  this.backgroundColor=color;
  if (isEnabled())   beforeBackground=backgroundColor;
  try {
    LayerDrawable layer=(LayerDrawable)getBackground();
    GradientDrawable shape=(GradientDrawable)layer.findDrawableByLayerId(R.id.shape_bacground);
    shape.setColor(backgroundColor);
    rippleColor=makePressColor();
  }
 catch (  Exception ex) {
  }
}

Fixed version (ground truth):
public void setBackgroundColor(int color){
  backgroundColor=color;
  if (isEnabled())   beforeBackground=backgroundColor;
  try {
    LayerDrawable layer=(LayerDrawable)getBackground();
    GradientDrawable shape=(GradientDrawable)layer.findDrawableByLayerId(R.id.shape_bacground);
    shape.setColor(backgroundColor);
    rippleColor=super.makePressColor(255);
  }
 catch (  Exception ex) {
  }
}
Program: 26647
Project: 26647
Buggy source:
@Override public boolean onTouchEvent(MotionEvent event){
  if (isEnabled()) {
    isLastTouch=true;
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
      radius=getHeight() / rippleSize;
      x=event.getX();
      y=event.getY();
    }
 else     if (event.getAction() == MotionEvent.ACTION_MOVE) {
      radius=getHeight() / rippleSize;
      x=event.getX();
      y=event.getY();
      if (!((event.getX() <= getWidth() && event.getX() >= 0) && (event.getY() <= getHeight() && event.getY() >= 0))) {
        isLastTouch=false;
        x=-1;
        y=-1;
      }
    }
 else     if (event.getAction() == MotionEvent.ACTION_UP) {
      if ((event.getX() <= getWidth() && event.getX() >= 0) && (event.getY() <= getHeight() && event.getY() >= 0)) {
        radius++;
      }
 else {
        isLastTouch=false;
        x=-1;
        y=-1;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent event){
  if (isEnabled()) {
    isLastTouch=true;
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
      radius=getHeight() / rippleSize;
      x=event.getX();
      y=event.getY();
    }
 else     if (event.getAction() == MotionEvent.ACTION_MOVE) {
      radius=getHeight() / rippleSize;
      x=event.getX();
      y=event.getY();
      if (!((event.getX() <= getWidth() && event.getX() >= 0) && (event.getY() <= getHeight() && event.getY() >= 0))) {
        isLastTouch=false;
        x=-1;
        y=-1;
      }
    }
 else     if (event.getAction() == MotionEvent.ACTION_UP) {
      if ((event.getX() <= getWidth() && event.getX() >= 0) && (event.getY() <= getHeight() && event.getY() >= 0)) {
        radius++;
      }
 else {
        isLastTouch=false;
        x=-1;
        y=-1;
      }
      if (clickAfterRipple == false && onClickListener != null) {
        onClickListener.onClick(this);
      }
    }
  }
  return true;
}
Program: 26648
Project: 26648
Buggy source:
public Bitmap makeCircle(){
  Bitmap output=Bitmap.createBitmap(getWidth() - Utils.dpToPx(6,getResources()),getHeight() - Utils.dpToPx(7,getResources()),Config.ARGB_8888);
  Canvas canvas=new Canvas(output);
  canvas.drawARGB(0,0,0,0);
  Paint paint=new Paint();
  paint.setAntiAlias(true);
  paint.setColor(rippleColor);
  canvas.drawCircle(x,y,radius,paint);
  if (radius > getHeight() / rippleSize)   radius+=rippleSpeed;
  if (radius >= getWidth()) {
    x=-1;
    y=-1;
    radius=getHeight() / rippleSize;
    if (onClickListener != null)     onClickListener.onClick(this);
  }
  return output;
}

Fixed version (ground truth):
public Bitmap makeCircle(){
  Bitmap output=Bitmap.createBitmap(getWidth() - Utils.dpToPx(6,getResources()),getHeight() - Utils.dpToPx(7,getResources()),Config.ARGB_8888);
  Canvas canvas=new Canvas(output);
  canvas.drawARGB(0,0,0,0);
  Paint paint=new Paint();
  paint.setAntiAlias(true);
  paint.setColor(rippleColor);
  canvas.drawCircle(x,y,radius,paint);
  if (radius > getHeight() / rippleSize) {
    radius+=rippleSpeed;
  }
  if (radius >= getWidth()) {
    x=-1;
    y=-1;
    radius=getHeight() / rippleSize;
    if (clickAfterRipple == true && onClickListener != null) {
      onClickListener.onClick(this);
    }
  }
  return output;
}
Program: 26649
Project: 26649
Buggy source:
/** 
 * Make a dark color to ripple effect
 * @return
 */
protected int makePressColor(){
  int r=(this.backgroundColor >> 16) & 0xFF;
  int g=(this.backgroundColor >> 8) & 0xFF;
  int b=(this.backgroundColor >> 0) & 0xFF;
  r=(r - 30 < 0) ? 0 : r - 30;
  g=(g - 30 < 0) ? 0 : g - 30;
  b=(b - 30 < 0) ? 0 : b - 30;
  return Color.rgb(r,g,b);
}

Fixed version (ground truth):
/** 
 * @return 涟漪上的暗色如果自定义了颜色，就返回自定义的颜色。如果没有，那么就生成颜色
 */
@Override protected int makePressColor(int alpha){
  if (rippleColor != null) {
    return rippleColor;
  }
 else {
    return super.makePressColor(alpha);
  }
}
Program: 26650
Project: 26650
Buggy source:
public Button(Context context,AttributeSet attrs){
  super(context,attrs);
  setDefaultProperties();
  setAttributes(attrs);
  beforeBackground=backgroundColor;
  if (rippleColor == null)   rippleColor=makePressColor();
}

Fixed version (ground truth):
public Button(Context context,AttributeSet attrs){
  super(context,attrs);
  onInitDefaultValues();
  onInitAttributes(attrs);
}
Program: 26651
Project: 26651
Buggy source:
public void setBackgroundColor(int color){
  backgroundColor=color;
  if (isEnabled())   beforeBackground=backgroundColor;
  textButton.setTextColor(color);
}

Fixed version (ground truth):
@Override @Deprecated public void setBackgroundColor(int color){
}
Program: 26652
Project: 26652
Buggy source:
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  if (x != -1) {
    Paint paint=new Paint();
    paint.setAntiAlias(true);
    paint.setColor(makePressColor());
    canvas.drawCircle(x,y,radius,paint);
    if (radius > getHeight() / rippleSize)     radius+=rippleSpeed;
    if (radius >= getWidth()) {
      x=-1;
      y=-1;
      radius=getHeight() / rippleSize;
      if (onClickListener != null)       onClickListener.onClick(this);
    }
  }
  invalidate();
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  if (x != -1) {
    Paint paint=new Paint();
    paint.setAntiAlias(true);
    paint.setColor(rippleColor);
    canvas.drawCircle(x,y,radius,paint);
    if (radius > getHeight() / rippleSize)     radius+=rippleSpeed;
    if (radius >= getWidth()) {
      x=-1;
      y=-1;
      radius=getHeight() / rippleSize;
      if (clickAfterRipple == true && onClickListener != null) {
        onClickListener.onClick(this);
      }
    }
  }
  invalidate();
}
Program: 26653
Project: 26653
Buggy source:
@Override protected void setDefaultProperties(){
  super.minWidth=80;
  super.minHeight=36;
  super.background=R.drawable.background_button_rectangle;
  super.setDefaultProperties();
  rippleSpeed=Utils.dpToPx(3,getResources());
}

Fixed version (ground truth):
@Override protected void setDefaultProperties(){
  super.minWidth=80;
  super.minHeight=36;
  super.background=R.drawable.background_button_rectangle;
  super.setDefaultProperties();
}
Program: 26654
Project: 26654
Buggy source:
protected void setAttributes(AttributeSet attrs){
  int bacgroundColor=attrs.getAttributeResourceValue(ANDROIDXML,"String_Node_Str",-1);
  if (bacgroundColor != -1) {
    setBackgroundColor(getResources().getColor(bacgroundColor));
  }
 else {
    String background=attrs.getAttributeValue(ANDROIDXML,"String_Node_Str");
    if (background != null)     setBackgroundColor(Color.parseColor(background));
  }
  String value=attrs.getAttributeValue(ANDROIDXML,"String_Node_Str");
  String text=null;
  int textResource=attrs.getAttributeResourceValue(ANDROIDXML,"String_Node_Str",-1);
  if (textResource != -1) {
    text=getResources().getString(textResource);
  }
 else {
    text=attrs.getAttributeValue(ANDROIDXML,"String_Node_Str");
  }
  if (text != null) {
    textButton=new TextView(getContext());
    textButton.setText(text);
    textButton.setTextColor(Color.WHITE);
    textButton.setTypeface(null,Typeface.BOLD);
    RelativeLayout.LayoutParams params=new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.CENTER_IN_PARENT,RelativeLayout.TRUE);
    params.setMargins(Utils.dpToPx(5,getResources()),Utils.dpToPx(5,getResources()),Utils.dpToPx(5,getResources()),Utils.dpToPx(5,getResources()));
    textButton.setLayoutParams(params);
    addView(textButton);
  }
}

Fixed version (ground truth):
protected void setAttributes(AttributeSet attrs){
  int bacgroundColor=attrs.getAttributeResourceValue(ANDROIDXML,"String_Node_Str",-1);
  if (bacgroundColor != -1) {
    setBackgroundColor(getResources().getColor(bacgroundColor));
  }
 else {
    String background=attrs.getAttributeValue(ANDROIDXML,"String_Node_Str");
    if (background != null)     setBackgroundColor(Color.parseColor(background));
  }
  String value=attrs.getAttributeValue(ANDROIDXML,"String_Node_Str");
  String text=null;
  int textResource=attrs.getAttributeResourceValue(ANDROIDXML,"String_Node_Str",-1);
  if (textResource != -1) {
    text=getResources().getString(textResource);
  }
 else {
    text=attrs.getAttributeValue(ANDROIDXML,"String_Node_Str");
  }
  if (text != null) {
    textButton=new TextView(getContext());
    textButton.setText(text);
    textButton.setTextColor(Color.WHITE);
    textButton.setTypeface(null,Typeface.BOLD);
    RelativeLayout.LayoutParams params=new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.CENTER_IN_PARENT,RelativeLayout.TRUE);
    params.setMargins(Utils.dpToPx(5,getResources()),Utils.dpToPx(5,getResources()),Utils.dpToPx(5,getResources()),Utils.dpToPx(5,getResources()));
    textButton.setLayoutParams(params);
    addView(textButton);
  }
  rippleSpeed=attrs.getAttributeFloatValue(MATERIALDESIGNXML,"String_Node_Str",Utils.dpToPx(6,getResources()));
}
Program: 26655
Project: 26655
Buggy source:
public void setChecked(boolean check){
  this.check=check;
  if (check) {
    step=0;
  }
  if (check)   checkView.changeBackground();
}

Fixed version (ground truth):
public void setChecked(boolean check){
  this.check=check;
  setPressed(false);
  changeBackgroundColor(getResources().getColor(android.R.color.transparent));
  if (check) {
    step=0;
  }
  if (check)   checkView.changeBackground();
}
Program: 26656
Project: 26656
Buggy source:
protected void setAttributes(AttributeSet attrs){
  int bacgroundColor=attrs.getAttributeResourceValue(ANDROIDXML,"String_Node_Str",-1);
  if (bacgroundColor != -1) {
    setBackgroundColor(getResources().getColor(bacgroundColor));
  }
 else {
    String background=attrs.getAttributeValue(ANDROIDXML,"String_Node_Str");
    if (background != null)     setBackgroundColor(Color.parseColor(background));
 else     setBackgroundColor(this.backgroundColor);
  }
}

Fixed version (ground truth):
protected void setAttributes(AttributeSet attrs){
  int bacgroundColor=attrs.getAttributeResourceValue(ANDROIDXML,"String_Node_Str",-1);
  if (bacgroundColor != -1) {
    setBackgroundColor(getResources().getColor(bacgroundColor));
  }
 else {
    String background=attrs.getAttributeValue(ANDROIDXML,"String_Node_Str");
    if (background != null)     setBackgroundColor(Color.parseColor(background));
 else     setBackgroundColor(this.backgroundColor);
  }
  int rippleColor=attrs.getAttributeResourceValue(MATERIALDESIGNXML,"String_Node_Str",-1);
  if (rippleColor != -1) {
    setRippleColor(getResources().getColor(rippleColor));
  }
 else {
    String background=attrs.getAttributeValue(MATERIALDESIGNXML,"String_Node_Str");
    if (background != null)     setRippleColor(Color.parseColor(background));
 else     setRippleColor(makePressColor());
  }
  rippleSpeed=attrs.getAttributeFloatValue(MATERIALDESIGNXML,"String_Node_Str",20f);
}
Program: 26657
Project: 26657
Buggy source:
/** 
 * Convert Dp to Pixel
 */
public static int dpToPx(float dp,Resources resources){
  float px=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,dp,resources.getDisplayMetrics());
  return (int)px;
}

Fixed version (ground truth):
/** 
 * Convert Dp to Pixel 将dp转换为pixel
 */
public static int dpToPx(float dp,Resources resources){
  float px=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,dp,resources.getDisplayMetrics());
  return (int)px;
}
Program: 26658
Project: 26658
Buggy source:
public void setBackgroundColor(int color){
  this.backgroundColor=color;
  if (isEnabled())   beforeBackground=backgroundColor;
  LayerDrawable layer=(LayerDrawable)getBackground();
  GradientDrawable shape=(GradientDrawable)layer.findDrawableByLayerId(R.id.shape_bacground);
  shape.setColor(backgroundColor);
}

Fixed version (ground truth):
public void setBackgroundColor(int color){
  this.backgroundColor=color;
  if (isEnabled()) {
    beforeBackground=backgroundColor;
  }
  LayerDrawable layer=(LayerDrawable)getBackground();
  GradientDrawable shape=null;
  if (!isInEditMode()) {
    shape=(GradientDrawable)layer.findDrawableByLayerId(R.id.shape_bacground);
    shape.setColor(backgroundColor);
  }
}
Program: 26659
Project: 26659
Buggy source:
protected void setAttributes(AttributeSet attrs){
  setBackgroundResource(R.drawable.background_button_rectangle);
  int bacgroundColor=attrs.getAttributeResourceValue(ANDROIDXML,"String_Node_Str",-1);
  if (bacgroundColor != -1) {
    setBackgroundColor(getResources().getColor(bacgroundColor));
  }
 else {
    String background=attrs.getAttributeValue(ANDROIDXML,"String_Node_Str");
    if (background != null)     setBackgroundColor(Color.parseColor(background));
 else     setBackgroundColor(this.backgroundColor);
  }
}

Fixed version (ground truth):
protected void setAttributes(AttributeSet attrs){
  if (!isInEditMode()) {
    setBackgroundResource(R.drawable.background_button_rectangle);
  }
  int bacgroundColor=attrs.getAttributeResourceValue(ANDROIDXML,"String_Node_Str",-1);
  if (bacgroundColor != -1) {
    setBackgroundColor(getResources().getColor(bacgroundColor));
  }
 else {
    String background=attrs.getAttributeValue(ANDROIDXML,"String_Node_Str");
    if (background != null)     setBackgroundColor(Color.parseColor(background));
 else     setBackgroundColor(this.backgroundColor);
  }
}
Program: 26660
Project: 26660
Buggy source:
public void onCheck(boolean check);

Fixed version (ground truth):
public void onCheck(boolean isChecked);
Program: 26661
Project: 26661
Buggy source:
@Override public void setBackgroundColor(int color){
  backgroundColor=color;
  if (isEnabled())   beforeBackground=backgroundColor;
  changeBackgroundColor(color);
}

Fixed version (ground truth):
@Override public void setBackgroundColor(int color){
  backgroundColor=color;
  if (isEnabled()) {
    beforeBackground=backgroundColor;
  }
  changeBackgroundColor(color);
}
Program: 26662
Project: 26662
Buggy source:
@Override public boolean onTouchEvent(MotionEvent event){
  if (isEnabled()) {
    isLastTouch=true;
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
      changeBackgroundColor((check) ? makePressColor() : Color.parseColor("String_Node_Str"));
    }
 else     if (event.getAction() == MotionEvent.ACTION_UP) {
      changeBackgroundColor(getResources().getColor(android.R.color.transparent));
      press=false;
      if ((event.getX() <= getWidth() && event.getX() >= 0) && (event.getY() <= getHeight() && event.getY() >= 0)) {
        isLastTouch=false;
        check=!check;
        if (onCheckListener != null)         onCheckListener.onCheck(check);
        if (check) {
          step=0;
        }
        if (check)         checkView.changeBackground();
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent event){
  if (isEnabled()) {
    isLastTouch=true;
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
      changeBackgroundColor((check) ? makePressColor(70) : Color.parseColor("String_Node_Str"));
    }
 else     if (event.getAction() == MotionEvent.ACTION_UP) {
      changeBackgroundColor(getResources().getColor(android.R.color.transparent));
      press=false;
      if ((event.getX() <= getWidth() && event.getX() >= 0) && (event.getY() <= getHeight() && event.getY() >= 0)) {
        isLastTouch=false;
        check=!check;
        if (onCheckListener != null)         onCheckListener.onCheck(check);
        if (check) {
          step=0;
        }
        if (check)         checkView.changeBackground();
      }
    }
  }
  return true;
}
Program: 26663
Project: 26663
Buggy source:
public Check(Context context){
  super(context);
  setBackgroundResource(R.drawable.background_checkbox_uncheck);
  sprite=BitmapFactory.decodeResource(context.getResources(),R.drawable.sprite_check);
}

Fixed version (ground truth):
public Check(Context context){
  super(context);
  if (!isInEditMode()) {
    setBackgroundResource(R.drawable.background_checkbox_uncheck);
  }
  sprite=BitmapFactory.decodeResource(context.getResources(),R.drawable.sprite_check);
}
Program: 26664
Project: 26664
Buggy source:
protected void setAttributes(AttributeSet attrs){
  setBackgroundResource(R.drawable.background_checkbox);
  setMinimumHeight(Utils.dpToPx(48,getResources()));
  setMinimumWidth(Utils.dpToPx(48,getResources()));
  int bacgroundColor=attrs.getAttributeResourceValue(ANDROIDXML,"String_Node_Str",-1);
  if (bacgroundColor != -1) {
    setBackgroundColor(getResources().getColor(bacgroundColor));
  }
 else {
    int background=attrs.getAttributeIntValue(ANDROIDXML,"String_Node_Str",-1);
    if (background != -1)     setBackgroundColor(background);
  }
  boolean check=attrs.getAttributeBooleanValue(MATERIALDESIGNXML,"String_Node_Str",false);
  if (check) {
    post(new Runnable(){
      @Override public void run(){
        setChecked(true);
        setPressed(false);
        changeBackgroundColor(getResources().getColor(android.R.color.transparent));
      }
    }
);
  }
  checkView=new Check(getContext());
  RelativeLayout.LayoutParams params=new LayoutParams(Utils.dpToPx(20,getResources()),Utils.dpToPx(20,getResources()));
  params.addRule(RelativeLayout.CENTER_IN_PARENT,RelativeLayout.TRUE);
  checkView.setLayoutParams(params);
  addView(checkView);
}

Fixed version (ground truth):
protected void setAttributes(AttributeSet attrs){
  if (!isInEditMode()) {
    setBackgroundResource(R.drawable.background_checkbox);
  }
 else {
    setBackgroundResource(android.R.drawable.checkbox_on_background);
  }
  setBackgroundAttributes(attrs);
  boolean check=attrs.getAttributeBooleanValue(MATERIALDESIGNXML,"String_Node_Str",false);
  if (check) {
    post(new Runnable(){
      @Override public void run(){
        setChecked(true);
        setPressed(false);
        changeBackgroundColor(getResources().getColor(android.R.color.transparent));
      }
    }
);
  }
  float size=20;
  String checkBoxSize=attrs.getAttributeValue(MATERIALDESIGNXML,"String_Node_Str");
  if (checkBoxSize != null) {
    size=Utils.dipOrDpToFloat(checkBoxSize);
  }
  checkView=new Check(getContext());
  RelativeLayout.LayoutParams params=new LayoutParams(Utils.dpToPx(size,getResources()),Utils.dpToPx(size,getResources()));
  params.addRule(RelativeLayout.CENTER_IN_PARENT,RelativeLayout.TRUE);
  checkView.setLayoutParams(params);
  addView(checkView);
}
Program: 26665
Project: 26665
Buggy source:
public CheckBox(Context context,AttributeSet attrs){
  super(context,attrs);
  setAttributes(attrs);
}

Fixed version (ground truth):
public CheckBox(Context context,AttributeSet attrs){
  super(context,attrs);
  backgroundColor=Color.parseColor("String_Node_Str");
  minWidth=48;
  minHeight=48;
  setAttributes(attrs);
}
Program: 26666
Project: 26666
Buggy source:
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  if (check) {
    if (step < 11)     step++;
  }
 else {
    if (step >= 0)     step--;
    if (step == -1)     changeBackground();
  }
  Rect src=new Rect(40 * step,0,(40 * step) + 40,40);
  Rect dst=new Rect(0,0,this.getWidth() - 2,this.getHeight());
  canvas.drawBitmap(sprite,src,dst,null);
  invalidate();
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  if (check) {
    if (step < 11)     step++;
  }
 else {
    if (step >= 0)     step--;
    if (step == -1)     changeBackground();
  }
  Rect src=new Rect(40 * step,0,(40 * step) + 40,40);
  Rect dst=new Rect(0,0,this.getWidth() - 2,this.getHeight());
  if (!isInEditMode()) {
    canvas.drawBitmap(sprite,src,dst,null);
  }
  invalidate();
}
Program: 26667
Project: 26667
Buggy source:
public void changeBackground(){
  if (check) {
    setBackgroundResource(R.drawable.background_checkbox_check);
    LayerDrawable layer=(LayerDrawable)getBackground();
    GradientDrawable shape=(GradientDrawable)layer.findDrawableByLayerId(R.id.shape_bacground);
    shape.setColor(backgroundColor);
  }
 else {
    setBackgroundResource(R.drawable.background_checkbox_uncheck);
  }
}

Fixed version (ground truth):
public void changeBackground(){
  if (check) {
    setBackgroundResource(R.drawable.background_checkbox_check);
    LayerDrawable layer=(LayerDrawable)getBackground();
    GradientDrawable shape=(GradientDrawable)layer.findDrawableByLayerId(R.id.shape_bacground);
    shape.setColor(backgroundColor);
  }
 else {
    if (!isInEditMode()) {
      setBackgroundResource(R.drawable.background_checkbox_uncheck);
    }
  }
}
Program: 26668
Project: 26668
Buggy source:
@Override public void onClick(View arg0){
  setChecked(iSchecked ? false : true);
}

Fixed version (ground truth):
@Override public void onClick(View v){
  setChecked(iSchecked ? false : true);
}
Program: 26669
Project: 26669
Buggy source:
@Override public boolean onTouchEvent(MotionEvent event){
  if (isEnabled()) {
    isLastTouch=true;
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
      press=true;
    }
 else     if (event.getAction() == MotionEvent.ACTION_MOVE) {
      float x=event.getX();
      x=(x < ball.xIni) ? ball.xIni : x;
      x=(x > ball.xFin) ? ball.xFin : x;
      if (x > ball.xCen) {
        iSchecked=true;
      }
 else {
        iSchecked=false;
      }
      ViewHelper.setX(ball,x);
      ball.changeBackground();
      if (event.getX() <= getWidth() && event.getX() >= 0) {
        isLastTouch=false;
        press=false;
      }
    }
 else     if (event.getAction() == MotionEvent.ACTION_UP) {
      press=false;
      isLastTouch=false;
      if (eventCheck != iSchecked) {
        eventCheck=iSchecked;
        if (onCheckListener != null)         onCheckListener.onCheck(iSchecked);
      }
      if (event.getX() <= getWidth() && event.getX() >= 0) {
        ball.animateCheck();
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent event){
  if (isEnabled()) {
    isLastTouch=true;
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
      press=true;
    }
 else     if (event.getAction() == MotionEvent.ACTION_MOVE) {
      requestDisallowInterceptTouchEvent(true);
      float x=event.getX();
      x=(x < ball.xIni) ? ball.xIni : x;
      x=(x > ball.xFin) ? ball.xFin : x;
      if (x > ball.xCen) {
        iSchecked=true;
      }
 else {
        iSchecked=false;
      }
      ViewHelper.setX(ball,x);
      ball.changeBackground();
      if (event.getX() <= getWidth() && event.getX() >= 0) {
        isLastTouch=false;
        press=false;
      }
    }
 else     if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
      requestDisallowInterceptTouchEvent(false);
      press=false;
      isLastTouch=false;
      if (eventCheck != iSchecked) {
        eventCheck=iSchecked;
        if (onCheckListener != null)         onCheckListener.onCheck(iSchecked);
      }
      if (event.getX() <= getWidth() && event.getX() >= 0) {
        ball.animateCheck();
      }
    }
  }
  return true;
}
Program: 26670
Project: 26670
Buggy source:
@Override protected void setAttributes(AttributeSet attrs){
  super.setAttributes(attrs);
  getBackground().setAlpha(0);
  iSchecked=attrs.getAttributeBooleanValue(MATERIALDESIGNXML,"String_Node_Str",false);
  eventCheck=iSchecked;
  setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View arg0){
      setChecked(iSchecked ? false : true);
    }
  }
);
  float size=20;
  String thumbSize=attrs.getAttributeValue(MATERIALDESIGNXML,"String_Node_Str");
  if (thumbSize != null) {
    size=Utils.dipOrDpToFloat(thumbSize);
  }
  ball=new Ball(getContext());
  setThumbParams(size);
  addView(ball);
}

Fixed version (ground truth):
@Override protected void setAttributes(AttributeSet attrs){
  super.setAttributes(attrs);
  if (!isInEditMode()) {
    getBackground().setAlpha(0);
  }
  iSchecked=attrs.getAttributeBooleanValue(MATERIALDESIGNXML,"String_Node_Str",false);
  eventCheck=iSchecked;
  setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View arg0){
      setChecked(iSchecked ? false : true);
    }
  }
);
  float size=20;
  String thumbSize=attrs.getAttributeValue(MATERIALDESIGNXML,"String_Node_Str");
  if (thumbSize != null) {
    size=Utils.dipOrDpToFloat(thumbSize);
  }
  ball=new Ball(getContext());
  setThumbParams(size);
  addView(ball);
  ball.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      setChecked(iSchecked ? false : true);
    }
  }
);
}
Program: 26671
Project: 26671
Buggy source:
/** 
 * 这里看似是得到控件相对的坐标，但是如果这个滑动条在可以上下滚动的布局中就会出现问题。 因为这里的坐标都是死的，在上下滚动的view中父控件的top仍旧不变，但实际上是应该获得动态数值的。
 * @error
 * @param myView
 * @return
 */
public static int getRelativeTop(View myView){
  myView.getParent().requestLayout();
  if (myView.getId() == android.R.id.content)   return myView.getTop();
 else   return myView.getTop() + getRelativeTop((View)myView.getParent());
}

Fixed version (ground truth):
/** 
 * 这里看似是得到控件相对的坐标，但是如果这个滑动条在可以上下滚动的布局中就会出现问题。 因为这里的坐标都是死的，在上下滚动的view中父控件的top仍旧不变，但实际上是应该获得动态数值的。
 * @param myView
 * @return
 */
public static int getRelativeTop(View myView){
  Rect bounds=new Rect();
  myView.getGlobalVisibleRect(bounds);
  return bounds.top;
}
Program: 26673
Project: 26673
Buggy source:
/** 
 * Checks if the broadcast is a fat beacon
 * @param serviceData The ble advertised Eddystone URL Service UUID service data
 * @return true if it is a fat beacon, false otherwise
 */
public static boolean isFatBeacon(byte[] serviceData){
  return (serviceData != null && serviceData.length > 3 && isUrlFrame(serviceData) && serviceData[2] == TITLE_TYPE);
}

Fixed version (ground truth):
/** 
 * Checks if the broadcast is a fat beacon.
 * @param serviceData The ble advertised Eddystone URL Service UUID service data
 * @return true if it is a fat beacon, false otherwise
 */
public static boolean isFatBeacon(byte[] serviceData){
  return (serviceData != null && serviceData.length > 3 && isUrlFrame(serviceData) && serviceData[2] == TITLE_TYPE);
}
Program: 26674
Project: 26674
Buggy source:
/** 
 * Getter for the Eddystone URL
 * @return Eddystone URL
 */
public String getUrl(){
  return mUrl;
}

Fixed version (ground truth):
/** 
 * Getter for the Eddystone URL.
 * @return Eddystone URL
 */
public String getUrl(){
  return mUrl;
}
Program: 26675
Project: 26675
Buggy source:
/** 
 * Getter for the Tx Power Level
 * @return Tx Power Level
 */
public byte getTxPowerLevel(){
  return mTxPower;
}

Fixed version (ground truth):
/** 
 * Getter for the Tx Power Level.
 * @return Tx Power Level
 */
public byte getTxPowerLevel(){
  return mTxPower;
}
Program: 26676
Project: 26676
Buggy source:
/** 
 * Reads the title of a fat beacon broadcast
 * @param serviceData The ble advertised Eddystone URL Service UUID service data
 * @return Title encoded in the broadcast
 */
public static String getFatBeaconTitle(byte[] serviceData){
  if (serviceData.length > 2) {
    String title=new String(Arrays.copyOfRange(serviceData,3,serviceData.length)).trim();
    return title.indexOf('\uFFFD') == -1 ? title : "String_Node_Str";
  }
  return "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Reads the title of a fat beacon broadcast.
 * @param serviceData The ble advertised Eddystone URL Service UUID service data
 * @return Title encoded in the broadcast
 */
public static String getFatBeaconTitle(byte[] serviceData){
  if (serviceData.length > 2) {
    String title=new String(Arrays.copyOfRange(serviceData,3,serviceData.length)).trim();
    return title.indexOf('\uFFFD') == -1 ? title : "String_Node_Str";
  }
  return "String_Node_Str";
}
Program: 26677
Project: 26677
Buggy source:
/** 
 * Checks if the broadcast is a Eddystone URL
 * @param serviceData The ble advertised Eddystone URL Service UUID service data
 * @return true if it is a URL, false otherwise
 */
public static boolean isUrlFrame(byte[] serviceData){
  return serviceData != null && serviceData.length > 0 && (serviceData[0] & 0xf0) == URL_FRAME_TYPE;
}

Fixed version (ground truth):
/** 
 * Checks if the broadcast is a Eddystone URL.
 * @param serviceData The ble advertised Eddystone URL Service UUID service data
 * @return true if it is a URL, false otherwise
 */
public static boolean isUrlFrame(byte[] serviceData){
  return serviceData != null && serviceData.length > 0 && (serviceData[0] & 0xf0) == URL_FRAME_TYPE;
}
Program: 26678
Project: 26678
Buggy source:
/** 
 * Getter for the flags
 * @return flags
 */
public byte getFlags(){
  return mFlags;
}

Fixed version (ground truth):
/** 
 * Getter for the flags.
 * @return flags
 */
public byte getFlags(){
  return mFlags;
}
Program: 26679
Project: 26679
Buggy source:
@Override public void onConnectionStateChange(BluetoothGatt gatt,int status,int newState){
  if (newState == BluetoothProfile.STATE_CONNECTED && status == gatt.GATT_SUCCESS) {
    Log.i(TAG,"String_Node_Str");
    mBluetoothGatt=gatt;
    html=new StringBuilder("String_Node_Str");
    if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
      gatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH);
      gatt.requestMtu(505);
    }
 else {
      gatt.discoverServices();
    }
  }
 else   if (newState == BluetoothProfile.STATE_DISCONNECTED) {
    Log.i(TAG,"String_Node_Str");
    close();
  }
 else   if (status != gatt.GATT_SUCCESS) {
    Log.i(TAG,"String_Node_Str" + status);
    close();
  }
}

Fixed version (ground truth):
@Override public void onConnectionStateChange(BluetoothGatt gatt,int status,int newState){
  if (newState == BluetoothProfile.STATE_CONNECTED && status == gatt.GATT_SUCCESS) {
    Log.i(TAG,"String_Node_Str");
    mBluetoothGatt=gatt;
    html=new StringBuilder("String_Node_Str");
    if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
      gatt.requestConnectionPriority(CONNECTION_PRIORITY_HIGH);
      gatt.requestMtu(505);
    }
 else {
      gatt.discoverServices();
    }
  }
 else   if (newState == BluetoothProfile.STATE_DISCONNECTED) {
    Log.i(TAG,"String_Node_Str");
    close();
  }
 else   if (status != gatt.GATT_SUCCESS) {
    Log.i(TAG,"String_Node_Str" + status);
    close();
  }
}
Program: 26680
Project: 26680
Buggy source:
private void showFragment(Fragment newFragment,String fragmentTag,boolean addToBackStack){
  FragmentTransaction transaction=getFragmentManager().beginTransaction().setCustomAnimations(R.animator.fade_in_and_slide_up_fragment,R.animator.fade_out_fragment,R.animator.fade_in_activity,R.animator.fade_out_fragment).replace(R.id.main_activity_container,newFragment,fragmentTag);
  if (addToBackStack) {
    transaction.addToBackStack(null);
  }
  transaction.commit();
}

Fixed version (ground truth):
@SuppressLint("String_Node_Str") private void showFragment(Fragment newFragment,String fragmentTag,boolean addToBackStack){
  FragmentTransaction transaction=getFragmentManager().beginTransaction().setCustomAnimations(R.animator.fade_in_and_slide_up_fragment,R.animator.fade_out_fragment,R.animator.fade_in_activity,R.animator.fade_out_fragment).replace(R.id.main_activity_container,newFragment,fragmentTag);
  if (addToBackStack) {
    transaction.addToBackStack(null);
  }
  transaction.commit();
}