Program: 85182
Project: 85182
Buggy source:
@Override protected void onLayout(boolean changed,int left,int top,int right,int bottom){
  if (LOG_ENABLED) {
    Log.i(LOG_TAG,"String_Node_Str" + changed + "String_Node_Str"+ mBitmapChanged+ "String_Node_Str"+ mScaleTypeChanged);
  }
  super.onLayout(changed,left,top,right,bottom);
  int deltaX=0;
  int deltaY=0;
  if (changed) {
    int oldw=mThisWidth;
    int oldh=mThisHeight;
    mThisWidth=right - left;
    mThisHeight=bottom - top;
    deltaX=mThisWidth - oldw;
    deltaY=mThisHeight - oldh;
    mCenter.x=mThisWidth / 2f;
    mCenter.y=mThisHeight / 2f;
  }
  Runnable r=mLayoutRunnable;
  if (r != null) {
    mLayoutRunnable=null;
    r.run();
  }
  final Drawable drawable=getDrawable();
  if (drawable != null) {
    if (changed || mScaleTypeChanged || mBitmapChanged) {
      float scale=1;
      getProperBaseMatrix(drawable,mBaseMatrix);
      if (mBitmapChanged || mScaleTypeChanged) {
        Log.d(LOG_TAG,"String_Node_Str" + mScaleType);
        if (mNextMatrix != null) {
          mSuppMatrix.set(mNextMatrix);
          mNextMatrix=null;
          scale=getScale();
        }
 else {
          mSuppMatrix.reset();
          if (mScaleType == DisplayType.FIT_TO_SCREEN) {
            scale=1f;
          }
 else {
            scale=Math.min(1f,1f / getScale(mBaseMatrix));
          }
        }
        setImageMatrix(getImageViewMatrix());
        if (scale != getScale()) {
          zoomTo(scale);
        }
      }
 else       if (changed) {
        if (!mMinZoomDefined)         mMinZoom=ZOOM_INVALID;
        if (!mMaxZoomDefined)         mMaxZoom=ZOOM_INVALID;
        setImageMatrix(getImageViewMatrix());
        postTranslate(-deltaX,-deltaY);
        scale=getScale();
      }
      if (LOG_ENABLED) {
        Log.d(LOG_TAG,"String_Node_Str" + scale);
      }
      if (scale > getMaxScale() || scale < getMinScale()) {
        zoomTo(scale);
      }
      center(true,true);
      if (mBitmapChanged)       onDrawableChanged(drawable);
      if (changed || mBitmapChanged || mScaleTypeChanged)       onLayoutChanged(left,top,right,bottom);
      if (mScaleTypeChanged)       mScaleTypeChanged=false;
      if (mBitmapChanged)       mBitmapChanged=false;
    }
  }
 else {
    if (mBitmapChanged)     onDrawableChanged(drawable);
    if (changed || mBitmapChanged || mScaleTypeChanged)     onLayoutChanged(left,top,right,bottom);
    if (mBitmapChanged)     mBitmapChanged=false;
    if (mScaleTypeChanged)     mScaleTypeChanged=false;
  }
}

Fixed version (ground truth):
@Override protected void onLayout(boolean changed,int left,int top,int right,int bottom){
  if (LOG_ENABLED) {
    Log.e(LOG_TAG,"String_Node_Str" + changed + "String_Node_Str"+ mBitmapChanged+ "String_Node_Str"+ mScaleTypeChanged);
  }
  super.onLayout(changed,left,top,right,bottom);
  int deltaX=0;
  int deltaY=0;
  if (changed) {
    int oldw=mThisWidth;
    int oldh=mThisHeight;
    mThisWidth=right - left;
    mThisHeight=bottom - top;
    deltaX=mThisWidth - oldw;
    deltaY=mThisHeight - oldh;
    mCenter.x=mThisWidth / 2f;
    mCenter.y=mThisHeight / 2f;
  }
  Runnable r=mLayoutRunnable;
  if (r != null) {
    mLayoutRunnable=null;
    r.run();
  }
  final Drawable drawable=getDrawable();
  if (drawable != null) {
    if (changed || mScaleTypeChanged || mBitmapChanged) {
      float scale=1;
      float old_default_scale=getDefaultScale(mScaleType);
      getProperBaseMatrix(drawable,mBaseMatrix);
      if (mBitmapChanged || mScaleTypeChanged) {
        if (LOG_ENABLED) {
          Log.d(LOG_TAG,"String_Node_Str" + mScaleType);
        }
        if (mNextMatrix != null) {
          mSuppMatrix.set(mNextMatrix);
          mNextMatrix=null;
          scale=getScale();
        }
 else {
          mSuppMatrix.reset();
          scale=getDefaultScale(mScaleType);
        }
        setImageMatrix(getImageViewMatrix());
        if (scale != getScale()) {
          zoomTo(scale);
        }
      }
 else       if (changed) {
        if (!mMinZoomDefined)         mMinZoom=ZOOM_INVALID;
        if (!mMaxZoomDefined)         mMaxZoom=ZOOM_INVALID;
        setImageMatrix(getImageViewMatrix());
        postTranslate(-deltaX,-deltaY);
        scale=getScale();
        if (LOG_ENABLED) {
          Log.d(LOG_TAG,"String_Node_Str" + old_default_scale);
          Log.d(LOG_TAG,"String_Node_Str" + scale);
        }
        if (Math.abs(scale - old_default_scale) < 0.01) {
          scale=getDefaultScale(mScaleType);
          zoomTo(scale);
        }
      }
      if (scale > getMaxScale() || scale < getMinScale()) {
        zoomTo(scale);
      }
      center(true,true);
      if (mBitmapChanged)       onDrawableChanged(drawable);
      if (changed || mBitmapChanged || mScaleTypeChanged)       onLayoutChanged(left,top,right,bottom);
      if (mScaleTypeChanged)       mScaleTypeChanged=false;
      if (mBitmapChanged)       mBitmapChanged=false;
    }
  }
 else {
    if (mBitmapChanged)     onDrawableChanged(drawable);
    if (changed || mBitmapChanged || mScaleTypeChanged)     onLayoutChanged(left,top,right,bottom);
    if (mBitmapChanged)     mBitmapChanged=false;
    if (mScaleTypeChanged)     mScaleTypeChanged=false;
  }
}