nus-yam/ex-repair huggingface dataset:
Program: 38519
Project: 38519
Buggy source:
private void updateImageCache(){
  HashSet<Path> toBeRemoved=new HashSet<Path>(mImageCache.keySet());
  for (int i=mActiveStart; i < mActiveEnd; ++i) {
    MediaItem item=mData[i % DATA_CACHE_SIZE];
    if (item == null)     continue;
    Path path=item.getPath();
    ImageEntry entry=mImageCache.get(path);
    toBeRemoved.remove(path);
    if (entry != null) {
      if (Math.abs(i - mCurrentIndex) > 1) {
        if (entry.fullImageTask != null) {
          entry.fullImageTask.cancel();
          entry.fullImageTask=null;
        }
        entry.fullImage=null;
        entry.requestedFullImage=MediaObject.INVALID_DATA_VERSION;
      }
      if (entry.requestedScreenNail != item.getDataVersion()) {
        if (entry.screenNail instanceof BitmapScreenNail) {
          BitmapScreenNail s=(BitmapScreenNail)entry.screenNail;
          s.updatePlaceholderSize(item.getWidth(),item.getHeight());
        }
      }
    }
 else {
      entry=new ImageEntry();
      mImageCache.put(path,entry);
    }
  }
  for (  Path path : toBeRemoved) {
    ImageEntry entry=mImageCache.remove(path);
    if (entry.fullImageTask != null)     entry.fullImageTask.cancel();
    if (entry.screenNailTask != null)     entry.screenNailTask.cancel();
    if (entry.screenNail != null)     entry.screenNail.recycle();
  }
}

Fixed version (ground truth):
private void updateImageCache(){
  HashSet<Path> toBeRemoved=new HashSet<Path>(mImageCache.keySet());
  for (int i=mActiveStart; i < mActiveEnd; ++i) {
    MediaItem item=mData[i % DATA_CACHE_SIZE];
    if (item == null)     continue;
    Path path=item.getPath();
    ImageEntry entry=mImageCache.get(path);
    toBeRemoved.remove(path);
    if (entry != null) {
      if (Math.abs(i - mCurrentIndex) > 1) {
        if (entry.fullImageTask != null) {
          entry.fullImageTask.cancel();
          entry.fullImageTask=null;
        }
        entry.fullImage=null;
        entry.requestedFullImage=MediaObject.INVALID_DATA_VERSION;
      }
      if (entry.requestedScreenNail != item.getDataVersion()) {
        if (entry.screenNail instanceof TiledScreenNail) {
          TiledScreenNail s=(TiledScreenNail)entry.screenNail;
          s.updatePlaceholderSize(item.getWidth(),item.getHeight());
        }
      }
    }
 else {
      entry=new ImageEntry();
      mImageCache.put(path,entry);
    }
  }
  for (  Path path : toBeRemoved) {
    ImageEntry entry=mImageCache.remove(path);
    if (entry.fullImageTask != null)     entry.fullImageTask.cancel();
    if (entry.screenNailTask != null)     entry.screenNailTask.cancel();
    if (entry.screenNail != null)     entry.screenNail.recycle();
  }
  updateScreenNailUploadQueue();
}
Program: 38520
Project: 38520
Buggy source:
private void transitionFromAlbumPageIfNeeded(){
  TransitionStore transitions=mActivity.getTransitionStore();
  int albumPageTransition=transitions.get(KEY_ALBUMPAGE_TRANSITION,MSG_ALBUMPAGE_NONE);
  if (albumPageTransition == MSG_ALBUMPAGE_NONE && mAppBridge != null && mRecenterCameraOnResume) {
    mCurrentIndex=0;
    mPhotoView.resetToFirstPicture();
  }
 else {
    int resumeIndex=transitions.get(KEY_INDEX_HINT,-1);
    if (resumeIndex >= 0) {
      if (mInCameraRoll) {
        resumeIndex++;
      }
      if (resumeIndex < mMediaSet.getMediaItemCount()) {
        mCurrentIndex=resumeIndex;
        mModel.moveTo(mCurrentIndex);
      }
    }
  }
  if (albumPageTransition == MSG_ALBUMPAGE_RESUMED) {
    mPhotoView.setFilmMode(mStartInFilmstrip || mAppBridge != null);
  }
 else   if (albumPageTransition == MSG_ALBUMPAGE_PICKED) {
    mPhotoView.setFilmMode(false);
  }
  mFadeOutTexture=transitions.get(PreparePageFadeoutTexture.KEY_FADE_TEXTURE);
  if (mFadeOutTexture != null) {
    mBackgroundFade.start();
    BitmapScreenNail.disableDrawPlaceholder();
    mOpenAnimationRect=albumPageTransition == MSG_ALBUMPAGE_NONE ? (Rect)mData.getParcelable(KEY_OPEN_ANIMATION_RECT) : (Rect)transitions.get(KEY_OPEN_ANIMATION_RECT);
    mPhotoView.setOpenAnimationRect(mOpenAnimationRect);
    mBackgroundFade.start();
  }
}

Fixed version (ground truth):
private void transitionFromAlbumPageIfNeeded(){
  TransitionStore transitions=mActivity.getTransitionStore();
  int albumPageTransition=transitions.get(KEY_ALBUMPAGE_TRANSITION,MSG_ALBUMPAGE_NONE);
  if (albumPageTransition == MSG_ALBUMPAGE_NONE && mAppBridge != null && mRecenterCameraOnResume) {
    mCurrentIndex=0;
    mPhotoView.resetToFirstPicture();
  }
 else {
    int resumeIndex=transitions.get(KEY_INDEX_HINT,-1);
    if (resumeIndex >= 0) {
      if (mInCameraRoll) {
        resumeIndex++;
      }
      if (resumeIndex < mMediaSet.getMediaItemCount()) {
        mCurrentIndex=resumeIndex;
        mModel.moveTo(mCurrentIndex);
      }
    }
  }
  if (albumPageTransition == MSG_ALBUMPAGE_RESUMED) {
    mPhotoView.setFilmMode(mStartInFilmstrip || mAppBridge != null);
  }
 else   if (albumPageTransition == MSG_ALBUMPAGE_PICKED) {
    mPhotoView.setFilmMode(false);
  }
  mFadeOutTexture=transitions.get(PreparePageFadeoutTexture.KEY_FADE_TEXTURE);
  if (mFadeOutTexture != null) {
    mBackgroundFade.start();
    TiledScreenNail.disableDrawPlaceholder();
    mOpenAnimationRect=albumPageTransition == MSG_ALBUMPAGE_NONE ? (Rect)mData.getParcelable(KEY_OPEN_ANIMATION_RECT) : (Rect)transitions.get(KEY_OPEN_ANIMATION_RECT);
    mPhotoView.setOpenAnimationRect(mOpenAnimationRect);
    mBackgroundFade.start();
  }
}
Program: 38521
Project: 38521
Buggy source:
@Override protected void renderBackground(GLCanvas view){
  if (mFadeOutTexture != null) {
    if (mBackgroundFade.calculate(AnimationTime.get()))     invalidate();
    if (!mBackgroundFade.isActive()) {
      mFadeOutTexture=null;
      mOpenAnimationRect=null;
      BitmapScreenNail.enableDrawPlaceholder();
    }
 else {
      float fadeAlpha=mBackgroundFade.get();
      if (fadeAlpha < 1f) {
        view.clearBuffer(getBackgroundColor());
        view.setAlpha(fadeAlpha);
      }
      mFadeOutTexture.draw(view,0,0);
      view.setAlpha(1f - fadeAlpha);
      return;
    }
  }
  view.clearBuffer(getBackgroundColor());
}

Fixed version (ground truth):
@Override protected void renderBackground(GLCanvas view){
  if (mFadeOutTexture != null) {
    if (mBackgroundFade.calculate(AnimationTime.get()))     invalidate();
    if (!mBackgroundFade.isActive()) {
      mFadeOutTexture=null;
      mOpenAnimationRect=null;
      TiledScreenNail.enableDrawPlaceholder();
    }
 else {
      float fadeAlpha=mBackgroundFade.get();
      if (fadeAlpha < 1f) {
        view.clearBuffer(getBackgroundColor());
        view.setAlpha(fadeAlpha);
      }
      mFadeOutTexture.draw(view,0,0);
      view.setAlpha(1f - fadeAlpha);
      return;
    }
  }
  view.clearBuffer(getBackgroundColor());
}
Program: 38522
Project: 38522
Buggy source:
@Override public void pause(){
  Future<?> task=mTask;
  task.cancel();
  task.waitDone();
  if (task.get() == null) {
    mTask=null;
  }
}

Fixed version (ground truth):
@Override public void pause(){
  Future<?> task=mTask;
  task.cancel();
  task.waitDone();
  if (task.get() == null) {
    mTask=null;
  }
  if (mBitmapScreenNail != null) {
    mBitmapScreenNail.recycle();
    mBitmapScreenNail=null;
  }
}
Program: 38523
Project: 38523
Buggy source:
public Matrix buildMatrix(Bitmap bitmap,boolean rotated){
  Matrix drawMatrix=new Matrix();
  float dx=bitmap.getWidth() / 2.0f;
  float dy=bitmap.getHeight() / 2.0f;
  Matrix flipper=mGeometry.getFlipMatrix(bitmap.getWidth(),bitmap.getHeight());
  drawMatrix.postConcat(flipper);
  drawMatrix.postTranslate(-dx,-dy);
  drawMatrix.postScale(1.0f / mGeometry.getScaleFactor(),1.0f / mGeometry.getScaleFactor());
  float angle=(mGeometry.getRotation() + mGeometry.getStraightenRotation());
  drawMatrix.postRotate(angle);
  if (rotated) {
    drawMatrix.postTranslate(dy,dx);
  }
 else {
    drawMatrix.postTranslate(dx,dy);
  }
  return drawMatrix;
}

Fixed version (ground truth):
public Matrix buildMatrix(Bitmap bitmap,boolean rotated){
  float dx=bitmap.getWidth() / 2;
  float dy=bitmap.getHeight() / 2;
  if (mGeometry.hasSwitchedWidthHeight()) {
    float temp=dx;
    dx=dy;
    dy=temp;
  }
  Matrix m=mGeometry.buildGeometryMatrix(bitmap.getWidth(),bitmap.getHeight(),1f / mGeometry.getScaleFactor(),dx,dy);
  return m;
}
Program: 38524
Project: 38524
Buggy source:
@Override public int hashCode(){
  int result=23;
  result=31 * result + Float.floatToIntBits(mRotation);
  result=31 * result + Float.floatToIntBits(mStraightenRotation);
  result=31 * result + Float.floatToIntBits(mScaleFactor);
  result=31 * result + mFlip.hashCode();
  result=31 * result + mCropBounds.hashCode();
  result=31 * result + mPhotoBounds.hashCode();
  result=31 * result + (mSafe ? 1 : 0);
  return result;
}

Fixed version (ground truth):
@Override public int hashCode(){
  int result=23;
  result=31 * result + Float.floatToIntBits(mRotation);
  result=31 * result + Float.floatToIntBits(mStraightenRotation);
  result=31 * result + Float.floatToIntBits(mScaleFactor);
  result=31 * result + mFlip.hashCode();
  result=31 * result + mCropBounds.hashCode();
  result=31 * result + mPhotoBounds.hashCode();
  return result;
}
Program: 38525
Project: 38525
Buggy source:
public void setPhotoBounds(RectF newPhotoBounds){
  mPhotoBounds.set(newPhotoBounds);
  mSafe=false;
}

Fixed version (ground truth):
public void setPhotoBounds(RectF newPhotoBounds){
  mPhotoBounds.set(newPhotoBounds);
}
Program: 38526
Project: 38526
Buggy source:
public void set(GeometryMetadata g){
  mScaleFactor=g.mScaleFactor;
  mRotation=g.mRotation;
  mStraightenRotation=g.mStraightenRotation;
  mCropBounds.set(g.mCropBounds);
  mPhotoBounds.set(g.mPhotoBounds);
  mFlip=g.mFlip;
  mSafe=g.mSafe;
  mMatrix=g.mMatrix;
  mBounds=g.mBounds;
}

Fixed version (ground truth):
public void set(GeometryMetadata g){
  mScaleFactor=g.mScaleFactor;
  mRotation=g.mRotation;
  mStraightenRotation=g.mStraightenRotation;
  mCropBounds.set(g.mCropBounds);
  mPhotoBounds.set(g.mPhotoBounds);
  mFlip=g.mFlip;
  mBounds=g.mBounds;
}
Program: 38527
Project: 38527
Buggy source:
public void setCropBounds(RectF newCropBounds){
  mCropBounds.set(newCropBounds);
  mSafe=false;
}

Fixed version (ground truth):
public void setCropBounds(RectF newCropBounds){
  mCropBounds.set(newCropBounds);
}
Program: 38528
Project: 38528
Buggy source:
@Override public boolean equals(Object o){
  if (this == o)   return true;
  if (o == null || getClass() != o.getClass())   return false;
  GeometryMetadata d=(GeometryMetadata)o;
  return (mScaleFactor == d.mScaleFactor && mRotation == d.mRotation && mStraightenRotation == d.mStraightenRotation && mFlip == d.mFlip && mSafe == d.mSafe && mCropBounds.equals(d.mCropBounds) && mPhotoBounds.equals(d.mPhotoBounds));
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  if (this == o)   return true;
  if (o == null || getClass() != o.getClass())   return false;
  GeometryMetadata d=(GeometryMetadata)o;
  return (mScaleFactor == d.mScaleFactor && mRotation == d.mRotation && mStraightenRotation == d.mStraightenRotation && mFlip == d.mFlip && mCropBounds.equals(d.mCropBounds) && mPhotoBounds.equals(d.mPhotoBounds));
}
Program: 38529
Project: 38529
Buggy source:
@Override public String toString(){
  return getClass().getName() + "String_Node_Str" + "String_Node_Str"+ mScaleFactor+ "String_Node_Str"+ mRotation+ "String_Node_Str"+ mFlip+ "String_Node_Str"+ (mSafe ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str"+ mStraightenRotation+ "String_Node_Str"+ mCropBounds.toShortString()+ "String_Node_Str"+ mPhotoBounds.toShortString()+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  return getClass().getName() + "String_Node_Str" + "String_Node_Str"+ mScaleFactor+ "String_Node_Str"+ mRotation+ "String_Node_Str"+ mFlip+ "String_Node_Str"+ mStraightenRotation+ "String_Node_Str"+ mCropBounds.toShortString()+ "String_Node_Str"+ mPhotoBounds.toShortString()+ "String_Node_Str";
}
Program: 38530
Project: 38530
Buggy source:
protected void syncLocalToMasterGeometry(){
  mLocalGeoMetadata=getMaster().getGeometry();
  calculateLocalScalingFactorAndOffset();
  mLocalMatrix=mLocalGeoMetadata.getMatrix();
}

Fixed version (ground truth):
protected void syncLocalToMasterGeometry(){
  mLocalGeoMetadata=getMaster().getGeometry();
  calculateLocalScalingFactorAndOffset();
}
Program: 38531
Project: 38531
Buggy source:
private void calculateLocalScalingFactorAndOffset(){
  if (mLocalGeoMetadata == null || mLocalDisplayBounds == null)   return;
  RectF imageBounds=mLocalGeoMetadata.getPhotoBounds();
  float imageWidth=imageBounds.width();
  float imageHeight=imageBounds.height();
  float displayWidth=mLocalDisplayBounds.width();
  float displayHeight=mLocalDisplayBounds.height();
  mCenterX=displayWidth / 2;
  mCenterY=displayHeight / 2;
  mYOffset=(displayHeight - imageHeight) / 2.0f;
  mXOffset=(displayWidth - imageWidth) / 2.0f;
  float zoom=computeScale(mLocalDisplayBounds.width(),mLocalDisplayBounds.height());
  mLocalGeoMetadata.setScaleFactor(zoom);
}

Fixed version (ground truth):
private void calculateLocalScalingFactorAndOffset(){
  if (mLocalGeoMetadata == null || mLocalDisplayBounds == null)   return;
  RectF imageBounds=mLocalGeoMetadata.getPhotoBounds();
  float imageWidth=imageBounds.width();
  float imageHeight=imageBounds.height();
  float displayWidth=mLocalDisplayBounds.width();
  float displayHeight=mLocalDisplayBounds.height();
  mCenterX=displayWidth / 2;
  mCenterY=displayHeight / 2;
  mYOffset=(displayHeight - imageHeight) / 2.0f;
  mXOffset=(displayWidth - imageWidth) / 2.0f;
}
Program: 38532
Project: 38532
Buggy source:
protected void gainedVisibility(){
  updateMatrix();
}

Fixed version (ground truth):
protected void gainedVisibility(){
  updateScale();
}
Program: 38533
Project: 38533
Buggy source:
@Override public boolean onTouchEvent(MotionEvent event){
switch (event.getActionMasked()) {
case (MotionEvent.ACTION_DOWN):
    setActionDown(event.getX(),event.getY());
  break;
case (MotionEvent.ACTION_UP):
setActionUp();
saveAndSetPreset();
Log.v(LOGTAG,"String_Node_Str");
logMasterGeo();
break;
case (MotionEvent.ACTION_MOVE):
setActionMove(event.getX(),event.getY());
break;
default :
setNoAction();
}
if (getPanelController() != null) {
getPanelController().onNewValue(getLocalValue());
}
invalidate();
return true;
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent event){
switch (event.getActionMasked()) {
case (MotionEvent.ACTION_DOWN):
    setActionDown(event.getX(),event.getY());
  break;
case (MotionEvent.ACTION_UP):
setActionUp();
saveAndSetPreset();
Log.v(LOGTAG,"String_Node_Str");
break;
case (MotionEvent.ACTION_MOVE):
setActionMove(event.getX(),event.getY());
break;
default :
setNoAction();
}
if (getPanelController() != null) {
getPanelController().onNewValue(getLocalValue());
}
invalidate();
return true;
}
Program: 38534
Project: 38534
Buggy source:
public Matrix computeBoundsMatrix(Bitmap bitmap){
  Matrix boundsMatrix=new Matrix();
  boundsMatrix.setTranslate((getWidth() - bitmap.getWidth()) / 2.0f,(getHeight() - bitmap.getHeight()) / 2.0f);
  boundsMatrix.postRotate(getLocalRotation(),getWidth() / 2.0f,getHeight() / 2.0f);
  return boundsMatrix;
}

Fixed version (ground truth):
public Matrix computeBoundsMatrix(Bitmap bitmap){
  float w=getWidth();
  float h=getHeight();
  Matrix boundsMatrix=new Matrix();
  boundsMatrix.setTranslate((getWidth() - bitmap.getWidth()) / 2.0f,(getHeight() - bitmap.getHeight()) / 2.0f);
  boundsMatrix.postRotate(getLocalRotation(),getWidth() / 2.0f,getHeight() / 2.0f);
  float scale=computeScale(w,h);
  boundsMatrix.postScale(scale,scale,getWidth() / 2,getHeight() / 2);
  return boundsMatrix;
}
Program: 38535
Project: 38535
Buggy source:
protected void setLocalFlip(FLIP flip){
  mLocalGeoMetadata.setFlipType(flip);
  updateMatrix();
}

Fixed version (ground truth):
protected void setLocalFlip(FLIP flip){
  mLocalGeoMetadata.setFlipType(flip);
}
Program: 38536
Project: 38536
Buggy source:
protected void setLocalRotation(float r){
  mLocalGeoMetadata.setRotation(r);
  updateMatrix();
}

Fixed version (ground truth):
protected void setLocalRotation(float r){
  mLocalGeoMetadata.setRotation(r);
  updateScale();
}
Program: 38537
Project: 38537
Buggy source:
protected void setLocalStraighten(float r){
  mLocalGeoMetadata.setStraightenRotation(r);
  updateMatrix();
}

Fixed version (ground truth):
protected void setLocalStraighten(float r){
  mLocalGeoMetadata.setStraightenRotation(r);
  updateScale();
}
Program: 38538
Project: 38538
Buggy source:
protected void drawTransformedBitmap(Canvas canvas,Bitmap bitmap,Paint paint,boolean clip){
  Matrix boundsMatrix=computeBoundsMatrix(bitmap);
  RectF bounds=getUntranslatedStraightenCropBounds(getLocalPhotoBounds(),getLocalStraighten());
  RectF transformedBounds=new RectF(bounds);
  boundsMatrix.mapRect(transformedBounds);
  canvas.save();
  Matrix matrix=getLocalMatrix();
  canvas.translate((getWidth() - bitmap.getWidth()) / 2.0f,(getHeight() - bitmap.getHeight()) / 2.0f);
  paint.setARGB(255,0,0,0);
  Matrix drawMatrix=new Matrix();
  float w=bitmap.getWidth();
  drawMatrix.preScale(1.0f / w,1.0f / w);
  drawMatrix.postConcat(matrix);
  drawMatrix.postScale(w,w);
  canvas.drawBitmap(bitmap,drawMatrix,paint);
  canvas.restore();
  canvas.save();
  canvas.setMatrix(boundsMatrix);
  paint.setColor(Color.WHITE);
  paint.setStyle(Style.STROKE);
  paint.setStrokeWidth(2);
  canvas.drawRect(bounds,paint);
  canvas.restore();
  if (!clip) {
    drawShadows(canvas,transformedBounds,new RectF(0,0,getWidth(),getHeight()),paint);
  }
}

Fixed version (ground truth):
protected void drawTransformedBitmap(Canvas canvas,Bitmap bitmap,Paint paint,boolean clip){
  float w=getWidth();
  float h=getHeight();
  Matrix boundsMatrix=computeBoundsMatrix(bitmap);
  RectF bounds=getUntranslatedStraightenCropBounds(getLocalPhotoBounds(),getLocalStraighten());
  RectF transformedBounds=new RectF(bounds);
  boundsMatrix.mapRect(transformedBounds);
  canvas.save();
  paint.setARGB(255,0,0,0);
  drawImage(canvas,bitmap,paint);
  canvas.restore();
  canvas.save();
  canvas.setMatrix(boundsMatrix);
  paint.setColor(Color.WHITE);
  paint.setStyle(Style.STROKE);
  paint.setStrokeWidth(2);
  canvas.drawRect(bounds,paint);
  canvas.restore();
  if (!clip) {
    drawShadows(canvas,transformedBounds,new RectF(0,0,w,h),paint);
  }
}
Program: 38539
Project: 38539
Buggy source:
@Override protected void onVisibilityChanged(View changedView,int visibility){
  super.onVisibilityChanged(changedView,visibility);
  if (visibility == View.VISIBLE) {
    mVisibilityGained=true;
    syncLocalToMasterGeometry();
    gainedVisibility();
    logMasterGeo();
  }
 else {
    if (mVisibilityGained == true && mHasDrawn == true) {
      lostVisibility();
      logMasterGeo();
    }
    mVisibilityGained=false;
    mHasDrawn=false;
  }
}

Fixed version (ground truth):
@Override protected void onVisibilityChanged(View changedView,int visibility){
  super.onVisibilityChanged(changedView,visibility);
  if (visibility == View.VISIBLE) {
    mVisibilityGained=true;
    syncLocalToMasterGeometry();
    gainedVisibility();
  }
 else {
    if (mVisibilityGained == true && mHasDrawn == true) {
      lostVisibility();
    }
    mVisibilityGained=false;
    mHasDrawn=false;
  }
}
Program: 38542
Project: 38542
Buggy source:
public Matrix buildMatrix(Bitmap bitmap,boolean rotated){
  float dx=bitmap.getWidth() / 2;
  float dy=bitmap.getHeight() / 2;
  if (mGeometry.hasSwitchedWidthHeight()) {
    float temp=dx;
    dx=dy;
    dy=temp;
  }
  Matrix m=mGeometry.buildGeometryMatrix(bitmap.getWidth(),bitmap.getHeight(),1f / mGeometry.getScaleFactor(),dx,dy);
  return m;
}

Fixed version (ground truth):
public Matrix buildMatrix(RectF r){
  float dx=r.width() / 2;
  float dy=r.height() / 2;
  if (mGeometry.hasSwitchedWidthHeight()) {
    float temp=dx;
    dx=dy;
    dy=temp;
  }
  float w=r.left * 2 + r.width();
  float h=r.top * 2 + r.height();
  Matrix m=mGeometry.buildGeometryMatrix(w,h,1f,dx,dy,false);
  return m;
}
Program: 38543
Project: 38543
Buggy source:
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Bitmap temp=null;
  float rotation=mGeometry.getRotation();
  boolean rotated=false;
  if (rotation == 0 || rotation % 180 == 0) {
    temp=Bitmap.createBitmap(bitmap.getWidth(),bitmap.getHeight(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(bitmap.getHeight(),bitmap.getWidth(),mConfig);
    rotated=true;
  }
  Matrix drawMatrix=buildMatrix(bitmap,rotated);
  Canvas canvas=new Canvas(temp);
  canvas.drawBitmap(bitmap,drawMatrix,new Paint());
  return temp;
}

Fixed version (ground truth):
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF c=mGeometry.getCropBounds();
  if (c != null && c.width() > 0 && c.height() > 0)   c.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  Matrix drawMatrix=buildMatrix(c);
  Canvas canvas=new Canvas(temp);
  canvas.drawBitmap(bitmap,drawMatrix,new Paint());
  return temp;
}
Program: 38544
Project: 38544
Buggy source:
public Matrix buildGeometryMatrix(float width,float height,float scaling,float dx,float dy){
  float dx0=width / 2;
  float dy0=height / 2;
  Matrix m=getFlipMatrix(width,height);
  m.postTranslate(-dx0,-dy0);
  float rot=mRotation % 360;
  if (rot < 0)   rot+=360;
  m.postRotate(rot + mStraightenRotation);
  m.postScale(scaling,scaling);
  m.postTranslate(dx,dy);
  return m;
}

Fixed version (ground truth):
public Matrix buildGeometryMatrix(float width,float height,float scaling,float dx,float dy,boolean onlyRotate){
  float rot=mRotation;
  if (!onlyRotate) {
    rot+=mStraightenRotation;
  }
  return buildGeometryMatrix(width,height,scaling,dx,dy,rot);
}
Program: 38545
Project: 38545
Buggy source:
public Matrix buildGeometryUIMatrix(float scaling,float dx,float dy){
  float w=mPhotoBounds.width();
  float h=mPhotoBounds.height();
  return buildGeometryMatrix(w,h,scaling,dx,dy);
}

Fixed version (ground truth):
public Matrix buildGeometryUIMatrix(float scaling,float dx,float dy){
  float w=mPhotoBounds.width();
  float h=mPhotoBounds.height();
  return buildGeometryMatrix(w,h,scaling,dx,dy,false);
}
Program: 38548
Project: 38548
Buggy source:
public Matrix buildMatrix(Bitmap bitmap,boolean rotated){
  float dx=bitmap.getWidth() / 2;
  float dy=bitmap.getHeight() / 2;
  if (mGeometry.hasSwitchedWidthHeight()) {
    float temp=dx;
    dx=dy;
    dy=temp;
  }
  Matrix m=mGeometry.buildGeometryMatrix(bitmap.getWidth(),bitmap.getHeight(),1f / mGeometry.getScaleFactor(),dx,dy);
  return m;
}

Fixed version (ground truth):
public Matrix buildMatrix(RectF r){
  float dx=r.width() / 2;
  float dy=r.height() / 2;
  if (mGeometry.hasSwitchedWidthHeight()) {
    float temp=dx;
    dx=dy;
    dy=temp;
  }
  float w=r.left * 2 + r.width();
  float h=r.top * 2 + r.height();
  Matrix m=mGeometry.buildGeometryMatrix(w,h,1f,dx,dy,false);
  return m;
}
Program: 38549
Project: 38549
Buggy source:
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Bitmap temp=null;
  float rotation=mGeometry.getRotation();
  boolean rotated=false;
  if (rotation == 0 || rotation % 180 == 0) {
    temp=Bitmap.createBitmap(bitmap.getWidth(),bitmap.getHeight(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(bitmap.getHeight(),bitmap.getWidth(),mConfig);
    rotated=true;
  }
  Matrix drawMatrix=buildMatrix(bitmap,rotated);
  Canvas canvas=new Canvas(temp);
  canvas.drawBitmap(bitmap,drawMatrix,new Paint());
  return temp;
}

Fixed version (ground truth):
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,boolean highQuality){
  Rect cropBounds=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  RectF c=mGeometry.getCropBounds();
  if (c != null && c.width() > 0 && c.height() > 0)   c.roundOut(cropBounds);
  Bitmap temp=null;
  if (mGeometry.hasSwitchedWidthHeight()) {
    temp=Bitmap.createBitmap(cropBounds.height(),cropBounds.width(),mConfig);
  }
 else {
    temp=Bitmap.createBitmap(cropBounds.width(),cropBounds.height(),mConfig);
  }
  Matrix drawMatrix=buildMatrix(c);
  Canvas canvas=new Canvas(temp);
  canvas.drawBitmap(bitmap,drawMatrix,new Paint());
  return temp;
}
Program: 38550
Project: 38550
Buggy source:
public Matrix buildGeometryMatrix(float width,float height,float scaling,float dx,float dy){
  float dx0=width / 2;
  float dy0=height / 2;
  Matrix m=getFlipMatrix(width,height);
  m.postTranslate(-dx0,-dy0);
  float rot=mRotation % 360;
  if (rot < 0)   rot+=360;
  m.postRotate(rot + mStraightenRotation);
  m.postScale(scaling,scaling);
  m.postTranslate(dx,dy);
  return m;
}

Fixed version (ground truth):
public Matrix buildGeometryMatrix(float width,float height,float scaling,float dx,float dy,boolean onlyRotate){
  float rot=mRotation;
  if (!onlyRotate) {
    rot+=mStraightenRotation;
  }
  return buildGeometryMatrix(width,height,scaling,dx,dy,rot);
}
Program: 38551
Project: 38551
Buggy source:
public Matrix buildGeometryUIMatrix(float scaling,float dx,float dy){
  float w=mPhotoBounds.width();
  float h=mPhotoBounds.height();
  return buildGeometryMatrix(w,h,scaling,dx,dy);
}

Fixed version (ground truth):
public Matrix buildGeometryUIMatrix(float scaling,float dx,float dy){
  float w=mPhotoBounds.width();
  float h=mPhotoBounds.height();
  return buildGeometryMatrix(w,h,scaling,dx,dy,false);
}
Program: 38552
Project: 38552
Buggy source:
public void add(ImageFilter filter){
  if (filter.getFilterType() == ImageFilter.TYPE_BORDER) {
    setHistoryName("String_Node_Str");
    setBorder(filter);
  }
 else   if (filter.getFilterType() == ImageFilter.TYPE_FX) {
    Vector<ImageFilter> fl=mFilters;
    boolean found=false;
    for (int i=0; i < mFilters.size(); i++) {
      byte type=fl.get(i).getFilterType();
      if (found) {
        if (type != ImageFilter.TYPE_VIGNETTE) {
          fl.remove(i);
        }
      }
 else       if (type == ImageFilter.TYPE_FX) {
        fl.remove(i);
        fl.add(i,filter);
        setHistoryName(filter.getName());
        found=true;
      }
    }
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
 else {
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
}

Fixed version (ground truth):
public void add(ImageFilter filter){
  if (filter.getFilterType() == ImageFilter.TYPE_BORDER) {
    setHistoryName("String_Node_Str");
    setBorder(filter);
  }
 else   if (filter.getFilterType() == ImageFilter.TYPE_FX) {
    boolean found=false;
    for (int i=0; i < mFilters.size(); i++) {
      byte type=mFilters.get(i).getFilterType();
      if (found) {
        if (type != ImageFilter.TYPE_VIGNETTE) {
          mFilters.remove(i);
          continue;
        }
      }
      if (type == ImageFilter.TYPE_FX) {
        mFilters.remove(i);
        mFilters.add(i,filter);
        setHistoryName(filter.getName());
        found=true;
      }
    }
    if (!found) {
      mFilters.add(filter);
      setHistoryName(filter.getName());
    }
  }
 else {
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
}
Program: 38553
Project: 38553
Buggy source:
public void add(ImageFilter filter){
  if (filter.getFilterType() == ImageFilter.TYPE_BORDER) {
    setHistoryName("String_Node_Str");
    setBorder(filter);
  }
 else   if (filter.getFilterType() == ImageFilter.TYPE_FX) {
    Vector<ImageFilter> fl=mFilters;
    boolean found=false;
    for (int i=0; i < mFilters.size(); i++) {
      byte type=fl.get(i).getFilterType();
      if (found) {
        if (type != ImageFilter.TYPE_VIGNETTE) {
          fl.remove(i);
        }
      }
 else       if (type == ImageFilter.TYPE_FX) {
        fl.remove(i);
        fl.add(i,filter);
        setHistoryName(filter.getName());
        found=true;
      }
    }
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
 else {
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
}

Fixed version (ground truth):
public void add(ImageFilter filter){
  if (filter.getFilterType() == ImageFilter.TYPE_BORDER) {
    setHistoryName("String_Node_Str");
    setBorder(filter);
  }
 else   if (filter.getFilterType() == ImageFilter.TYPE_FX) {
    boolean found=false;
    for (int i=0; i < mFilters.size(); i++) {
      byte type=mFilters.get(i).getFilterType();
      if (found) {
        if (type != ImageFilter.TYPE_VIGNETTE) {
          mFilters.remove(i);
          continue;
        }
      }
      if (type == ImageFilter.TYPE_FX) {
        mFilters.remove(i);
        mFilters.add(i,filter);
        setHistoryName(filter.getName());
        found=true;
      }
    }
    if (!found) {
      mFilters.add(filter);
      setHistoryName(filter.getName());
    }
  }
 else {
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
}
Program: 38554
Project: 38554
Buggy source:
@Override public void onActivityResult(int requestCode,int resultCode,Intent data){
  Log.v(LOGTAG,"String_Node_Str");
  if (resultCode == RESULT_OK) {
    if (requestCode == SELECT_PICTURE) {
      Uri selectedImageUri=data.getData();
      mImageLoader.loadBitmap(selectedImageUri);
    }
  }
}

Fixed version (ground truth):
@Override public void onActivityResult(int requestCode,int resultCode,Intent data){
  Log.v(LOGTAG,"String_Node_Str");
  if (resultCode == RESULT_OK) {
    if (requestCode == SELECT_PICTURE) {
      Uri selectedImageUri=data.getData();
      mImageLoader.loadBitmap(selectedImageUri,getScreenImageSize());
    }
  }
}
Program: 38556
Project: 38556
Buggy source:
public void loadBitmap(Uri uri){
  mUri=uri;
  mOrientation=getOrientation(uri);
  mOriginalBitmapSmall=loadScaledBitmap(uri,160);
  mOriginalBitmapLarge=loadScaledBitmap(uri,320);
  updateBitmaps();
}

Fixed version (ground truth):
public void loadBitmap(Uri uri,int size){
  mUri=uri;
  mOrientation=getOrientation(uri);
  mOriginalBitmapSmall=loadScaledBitmap(uri,160);
  mOriginalBitmapLarge=loadScaledBitmap(uri,size);
  updateBitmaps();
}
Program: 38557
Project: 38557
Buggy source:
public ImageFilterVignette(){
  mName="String_Node_Str";
}

Fixed version (ground truth):
public ImageFilterVignette(){
  setFilterType(TYPE_VIGNETTE);
  mName="String_Node_Str";
}
Program: 38558
Project: 38558
Buggy source:
public void add(ImageFilter filter){
  if (filter.getFilterType() == ImageFilter.TYPE_BORDER) {
    setHistoryName("String_Node_Str");
    setBorder(filter);
  }
 else   if (filter.getFilterType() == ImageFilter.TYPE_FX) {
    Vector<ImageFilter> fl=mFilters;
    boolean found=false;
    for (int i=0; i < mFilters.size(); i++) {
      byte type=fl.get(i).getFilterType();
      if (found) {
        if (type != ImageFilter.TYPE_VIGNETTE) {
          fl.remove(i);
        }
      }
 else       if (type == ImageFilter.TYPE_FX) {
        fl.remove(i);
        fl.add(i,filter);
        setHistoryName(filter.getName());
        found=true;
      }
    }
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
 else {
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
}

Fixed version (ground truth):
public void add(ImageFilter filter){
  if (filter.getFilterType() == ImageFilter.TYPE_BORDER) {
    setHistoryName("String_Node_Str");
    setBorder(filter);
  }
 else   if (filter.getFilterType() == ImageFilter.TYPE_FX) {
    boolean found=false;
    for (int i=0; i < mFilters.size(); i++) {
      byte type=mFilters.get(i).getFilterType();
      if (found) {
        if (type != ImageFilter.TYPE_VIGNETTE) {
          mFilters.remove(i);
          continue;
        }
      }
      if (type == ImageFilter.TYPE_FX) {
        mFilters.remove(i);
        mFilters.add(i,filter);
        setHistoryName(filter.getName());
        found=true;
      }
    }
    if (!found) {
      mFilters.add(filter);
      setHistoryName(filter.getName());
    }
  }
 else {
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
}
Program: 38559
Project: 38559
Buggy source:
@Override public void onActivityResult(int requestCode,int resultCode,Intent data){
  Log.v(LOGTAG,"String_Node_Str");
  if (resultCode == RESULT_OK) {
    if (requestCode == SELECT_PICTURE) {
      Uri selectedImageUri=data.getData();
      mImageLoader.loadBitmap(selectedImageUri);
    }
  }
}

Fixed version (ground truth):
@Override public void onActivityResult(int requestCode,int resultCode,Intent data){
  Log.v(LOGTAG,"String_Node_Str");
  if (resultCode == RESULT_OK) {
    if (requestCode == SELECT_PICTURE) {
      Uri selectedImageUri=data.getData();
      mImageLoader.loadBitmap(selectedImageUri,getScreenImageSize());
    }
  }
}
Program: 38561
Project: 38561
Buggy source:
public void loadBitmap(Uri uri){
  mUri=uri;
  mOrientation=getOrientation(uri);
  mOriginalBitmapSmall=loadScaledBitmap(uri,160);
  mOriginalBitmapLarge=loadScaledBitmap(uri,320);
  updateBitmaps();
}

Fixed version (ground truth):
public void loadBitmap(Uri uri,int size){
  mUri=uri;
  mOrientation=getOrientation(uri);
  mOriginalBitmapSmall=loadScaledBitmap(uri,160);
  mOriginalBitmapLarge=loadScaledBitmap(uri,size);
  updateBitmaps();
}
Program: 38562
Project: 38562
Buggy source:
public ImageFilterVignette(){
  mName="String_Node_Str";
}

Fixed version (ground truth):
public ImageFilterVignette(){
  setFilterType(TYPE_VIGNETTE);
  mName="String_Node_Str";
}
Program: 38563
Project: 38563
Buggy source:
public void add(ImageFilter filter){
  if (filter.getFilterType() == ImageFilter.TYPE_BORDER) {
    setHistoryName("String_Node_Str");
    setBorder(filter);
  }
 else   if (filter.getFilterType() == ImageFilter.TYPE_FX) {
    Vector<ImageFilter> fl=mFilters;
    boolean found=false;
    for (int i=0; i < mFilters.size(); i++) {
      byte type=fl.get(i).getFilterType();
      if (found) {
        if (type != ImageFilter.TYPE_VIGNETTE) {
          fl.remove(i);
        }
      }
 else       if (type == ImageFilter.TYPE_FX) {
        fl.remove(i);
        fl.add(i,filter);
        setHistoryName(filter.getName());
        found=true;
      }
    }
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
 else {
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
}

Fixed version (ground truth):
public void add(ImageFilter filter){
  if (filter.getFilterType() == ImageFilter.TYPE_BORDER) {
    setHistoryName("String_Node_Str");
    setBorder(filter);
  }
 else   if (filter.getFilterType() == ImageFilter.TYPE_FX) {
    boolean found=false;
    for (int i=0; i < mFilters.size(); i++) {
      byte type=mFilters.get(i).getFilterType();
      if (found) {
        if (type != ImageFilter.TYPE_VIGNETTE) {
          mFilters.remove(i);
          continue;
        }
      }
      if (type == ImageFilter.TYPE_FX) {
        mFilters.remove(i);
        mFilters.add(i,filter);
        setHistoryName(filter.getName());
        found=true;
      }
    }
    if (!found) {
      mFilters.add(filter);
      setHistoryName(filter.getName());
    }
  }
 else {
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
}
Program: 38564
Project: 38564
Buggy source:
public void add(ImageFilter filter){
  if (filter.getFilterType() == ImageFilter.TYPE_BORDER) {
    setHistoryName("String_Node_Str");
    setBorder(filter);
  }
 else   if (filter.getFilterType() == ImageFilter.TYPE_FX) {
    Vector<ImageFilter> fl=mFilters;
    boolean found=false;
    for (int i=0; i < mFilters.size(); i++) {
      byte type=fl.get(i).getFilterType();
      if (found) {
        if (type != ImageFilter.TYPE_VIGNETTE) {
          fl.remove(i);
        }
      }
 else       if (type == ImageFilter.TYPE_FX) {
        fl.remove(i);
        fl.add(i,filter);
        setHistoryName(filter.getName());
        found=true;
      }
    }
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
 else {
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
}

Fixed version (ground truth):
public void add(ImageFilter filter){
  if (filter.getFilterType() == ImageFilter.TYPE_BORDER) {
    setHistoryName("String_Node_Str");
    setBorder(filter);
  }
 else   if (filter.getFilterType() == ImageFilter.TYPE_FX) {
    boolean found=false;
    for (int i=0; i < mFilters.size(); i++) {
      byte type=mFilters.get(i).getFilterType();
      if (found) {
        if (type != ImageFilter.TYPE_VIGNETTE) {
          mFilters.remove(i);
          continue;
        }
      }
      if (type == ImageFilter.TYPE_FX) {
        mFilters.remove(i);
        mFilters.add(i,filter);
        setHistoryName(filter.getName());
        found=true;
      }
    }
    if (!found) {
      mFilters.add(filter);
      setHistoryName(filter.getName());
    }
  }
 else {
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
}
Program: 38565
Project: 38565
Buggy source:
@Override public void onActivityResult(int requestCode,int resultCode,Intent data){
  Log.v(LOGTAG,"String_Node_Str");
  if (resultCode == RESULT_OK) {
    if (requestCode == SELECT_PICTURE) {
      Uri selectedImageUri=data.getData();
      mImageLoader.loadBitmap(selectedImageUri);
    }
  }
}

Fixed version (ground truth):
@Override public void onActivityResult(int requestCode,int resultCode,Intent data){
  Log.v(LOGTAG,"String_Node_Str");
  if (resultCode == RESULT_OK) {
    if (requestCode == SELECT_PICTURE) {
      Uri selectedImageUri=data.getData();
      mImageLoader.loadBitmap(selectedImageUri,getScreenImageSize());
    }
  }
}
Program: 38567
Project: 38567
Buggy source:
public void loadBitmap(Uri uri){
  mUri=uri;
  mOrientation=getOrientation(uri);
  mOriginalBitmapSmall=loadScaledBitmap(uri,160);
  mOriginalBitmapLarge=loadScaledBitmap(uri,320);
  updateBitmaps();
}

Fixed version (ground truth):
public void loadBitmap(Uri uri,int size){
  mUri=uri;
  mOrientation=getOrientation(uri);
  mOriginalBitmapSmall=loadScaledBitmap(uri,160);
  mOriginalBitmapLarge=loadScaledBitmap(uri,size);
  updateBitmaps();
}
Program: 38568
Project: 38568
Buggy source:
public ImageFilterVignette(){
  mName="String_Node_Str";
}

Fixed version (ground truth):
public ImageFilterVignette(){
  setFilterType(TYPE_VIGNETTE);
  mName="String_Node_Str";
}
Program: 38569
Project: 38569
Buggy source:
public void add(ImageFilter filter){
  if (filter.getFilterType() == ImageFilter.TYPE_BORDER) {
    setHistoryName("String_Node_Str");
    setBorder(filter);
  }
 else   if (filter.getFilterType() == ImageFilter.TYPE_FX) {
    Vector<ImageFilter> fl=mFilters;
    boolean found=false;
    for (int i=0; i < mFilters.size(); i++) {
      byte type=fl.get(i).getFilterType();
      if (found) {
        if (type != ImageFilter.TYPE_VIGNETTE) {
          fl.remove(i);
        }
      }
 else       if (type == ImageFilter.TYPE_FX) {
        fl.remove(i);
        fl.add(i,filter);
        setHistoryName(filter.getName());
        found=true;
      }
    }
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
 else {
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
}

Fixed version (ground truth):
public void add(ImageFilter filter){
  if (filter.getFilterType() == ImageFilter.TYPE_BORDER) {
    setHistoryName("String_Node_Str");
    setBorder(filter);
  }
 else   if (filter.getFilterType() == ImageFilter.TYPE_FX) {
    boolean found=false;
    for (int i=0; i < mFilters.size(); i++) {
      byte type=mFilters.get(i).getFilterType();
      if (found) {
        if (type != ImageFilter.TYPE_VIGNETTE) {
          mFilters.remove(i);
          continue;
        }
      }
      if (type == ImageFilter.TYPE_FX) {
        mFilters.remove(i);
        mFilters.add(i,filter);
        setHistoryName(filter.getName());
        found=true;
      }
    }
    if (!found) {
      mFilters.add(filter);
      setHistoryName(filter.getName());
    }
  }
 else {
    mFilters.add(filter);
    setHistoryName(filter.getName());
  }
}
Program: 38570
Project: 38570
Buggy source:
@Override public void onPhotoChanged(int index,Path item){
  int oldIndex=mCurrentIndex;
  mCurrentIndex=index;
  if (mAppBridge != null) {
    if (mCurrentIndex > 0) {
      mSkipUpdateCurrentPhoto=false;
    }
    if (oldIndex == 0 && mCurrentIndex > 0 && !mPhotoView.getFilmMode()) {
      mPhotoView.setFilmMode(true);
    }
 else     if (oldIndex == 2 && mCurrentIndex == 1) {
      mCameraSwitchCutoff=SystemClock.uptimeMillis() + CAMERA_SWITCH_CUTOFF_THRESHOLD_MS;
      mPhotoView.stopScrolling();
    }
 else     if (oldIndex == 1 && mCurrentIndex == 0) {
      mPhotoView.setWantPictureCenterCallbacks(true);
      mSkipUpdateCurrentPhoto=true;
    }
  }
  if (!mSkipUpdateCurrentPhoto) {
    if (item != null) {
      MediaItem photo=mModel.getMediaItem(0);
      if (photo != null)       updateCurrentPhoto(photo);
    }
    updateBars();
  }
  refreshHidingMessage();
}

Fixed version (ground truth):
@Override public void onPhotoChanged(int index,Path item){
  int oldIndex=mCurrentIndex;
  mCurrentIndex=index;
  if (mAppBridge != null) {
    if (mCurrentIndex > 0) {
      mSkipUpdateCurrentPhoto=false;
    }
    if (oldIndex == 0 && mCurrentIndex > 0 && !mPhotoView.getFilmMode()) {
      mPhotoView.setFilmMode(true);
    }
 else     if (oldIndex == 2 && mCurrentIndex == 1) {
      mCameraSwitchCutoff=SystemClock.uptimeMillis() + CAMERA_SWITCH_CUTOFF_THRESHOLD_MS;
      mPhotoView.stopScrolling();
    }
 else     if (oldIndex >= 1 && mCurrentIndex == 0) {
      mPhotoView.setWantPictureCenterCallbacks(true);
      mSkipUpdateCurrentPhoto=true;
    }
  }
  if (!mSkipUpdateCurrentPhoto) {
    if (item != null) {
      MediaItem photo=mModel.getMediaItem(0);
      if (photo != null)       updateCurrentPhoto(photo);
    }
    updateBars();
  }
  refreshHidingMessage();
}
Program: 38572
Project: 38572
Buggy source:
@Override public void handleMessage(Message message){
switch (message.what) {
case MSG_HIDE_BARS:
{
      hideBars();
      break;
    }
case MSG_REFRESH_BOTTOM_CONTROLS:
{
    if (mBottomControls != null)     mBottomControls.refresh();
    break;
  }
case MSG_LOCK_ORIENTATION:
{
  mOrientationManager.lockOrientation();
  break;
}
case MSG_UNLOCK_ORIENTATION:
{
mOrientationManager.unlockOrientation();
break;
}
case MSG_ON_FULL_SCREEN_CHANGED:
{
mAppBridge.onFullScreenChanged(message.arg1 == 1);
break;
}
case MSG_UPDATE_ACTION_BAR:
{
updateBars();
break;
}
case MSG_WANT_BARS:
{
wantBars();
break;
}
case MSG_UNFREEZE_GLROOT:
{
mActivity.getGLRoot().unfreeze();
break;
}
case MSG_ON_CAMERA_CENTER:
{
mSkipUpdateCurrentPhoto=false;
boolean updateNeeded=false;
if (!mPhotoView.getFilmMode()) {
lockOrientation();
updateNeeded=true;
}
 else if (SystemClock.uptimeMillis() < mCameraSwitchCutoff && mMediaSet.getMediaItemCount() > 1) {
mPhotoView.switchToImage(1);
}
 else {
mPhotoView.setFilmMode(false);
updateNeeded=true;
}
if (updateNeeded) {
updateBars();
updateCurrentPhoto(mModel.getMediaItem(0));
}
break;
}
case MSG_ON_PICTURE_CENTER:
{
if (mCurrentPhoto != null && (mCurrentPhoto.getSupportedOperations() & MediaObject.SUPPORT_ACTION) != 0) {
mPhotoView.setFilmMode(true);
}
break;
}
default :
throw new AssertionError(message.what);
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message message){
switch (message.what) {
case MSG_HIDE_BARS:
{
      hideBars();
      break;
    }
case MSG_REFRESH_BOTTOM_CONTROLS:
{
    if (mBottomControls != null)     mBottomControls.refresh();
    break;
  }
case MSG_LOCK_ORIENTATION:
{
  mOrientationManager.lockOrientation();
  break;
}
case MSG_UNLOCK_ORIENTATION:
{
mOrientationManager.unlockOrientation();
break;
}
case MSG_ON_FULL_SCREEN_CHANGED:
{
mAppBridge.onFullScreenChanged(message.arg1 == 1);
break;
}
case MSG_UPDATE_ACTION_BAR:
{
updateBars();
break;
}
case MSG_WANT_BARS:
{
wantBars();
break;
}
case MSG_UNFREEZE_GLROOT:
{
mActivity.getGLRoot().unfreeze();
break;
}
case MSG_ON_CAMERA_CENTER:
{
mSkipUpdateCurrentPhoto=false;
boolean stayedOnCamera=false;
if (!mPhotoView.getFilmMode()) {
stayedOnCamera=true;
}
 else if (SystemClock.uptimeMillis() < mCameraSwitchCutoff && mMediaSet.getMediaItemCount() > 1) {
mPhotoView.switchToImage(1);
}
 else {
mPhotoView.setFilmMode(false);
stayedOnCamera=true;
}
if (stayedOnCamera) {
lockOrientation();
updateBars();
updateCurrentPhoto(mModel.getMediaItem(0));
}
break;
}
case MSG_ON_PICTURE_CENTER:
{
if (mCurrentPhoto != null && (mCurrentPhoto.getSupportedOperations() & MediaObject.SUPPORT_ACTION) != 0) {
mPhotoView.setFilmMode(true);
}
break;
}
default :
throw new AssertionError(message.what);
}
}
Program: 38573
Project: 38573
Buggy source:
@Override public void onPhotoChanged(int index,Path item){
  int oldIndex=mCurrentIndex;
  mCurrentIndex=index;
  if (mAppBridge != null) {
    if (mCurrentIndex > 0) {
      mSkipUpdateCurrentPhoto=false;
    }
    if (oldIndex == 0 && mCurrentIndex > 0 && !mPhotoView.getFilmMode()) {
      mPhotoView.setFilmMode(true);
    }
 else     if (oldIndex == 2 && mCurrentIndex == 1) {
      mCameraSwitchCutoff=SystemClock.uptimeMillis() + CAMERA_SWITCH_CUTOFF_THRESHOLD_MS;
      mPhotoView.stopScrolling();
    }
 else     if (oldIndex == 1 && mCurrentIndex == 0) {
      mPhotoView.setWantPictureCenterCallbacks(true);
      mSkipUpdateCurrentPhoto=true;
    }
  }
  if (!mSkipUpdateCurrentPhoto) {
    if (item != null) {
      MediaItem photo=mModel.getMediaItem(0);
      if (photo != null)       updateCurrentPhoto(photo);
    }
    updateBars();
  }
  refreshHidingMessage();
}

Fixed version (ground truth):
@Override public void onPhotoChanged(int index,Path item){
  int oldIndex=mCurrentIndex;
  mCurrentIndex=index;
  if (mAppBridge != null) {
    if (mCurrentIndex > 0) {
      mSkipUpdateCurrentPhoto=false;
    }
    if (oldIndex == 0 && mCurrentIndex > 0 && !mPhotoView.getFilmMode()) {
      mPhotoView.setFilmMode(true);
    }
 else     if (oldIndex == 2 && mCurrentIndex == 1) {
      mCameraSwitchCutoff=SystemClock.uptimeMillis() + CAMERA_SWITCH_CUTOFF_THRESHOLD_MS;
      mPhotoView.stopScrolling();
    }
 else     if (oldIndex >= 1 && mCurrentIndex == 0) {
      mPhotoView.setWantPictureCenterCallbacks(true);
      mSkipUpdateCurrentPhoto=true;
    }
  }
  if (!mSkipUpdateCurrentPhoto) {
    if (item != null) {
      MediaItem photo=mModel.getMediaItem(0);
      if (photo != null)       updateCurrentPhoto(photo);
    }
    updateBars();
  }
  refreshHidingMessage();
}