private void snap(){
  mTranslateRect.set(mTempSrc);
  mMatrix.mapRect(mTranslateRect);
  float maxLeft=mAllowCrop ? mCropRect.left : 0.0f;
  float maxRight=mAllowCrop ? mCropRect.right : getWidth();
  float l=mTranslateRect.left;
  float r=mTranslateRect.right;
  final float translateX;
  if (r - l < maxRight - maxLeft) {
    translateX=maxLeft + ((maxRight - maxLeft) - (r + l)) / 2;
  }
 else   if (l > maxLeft) {
    translateX=maxLeft - l;
  }
 else   if (r < maxRight) {
    translateX=maxRight - r;
  }
 else {
    translateX=0.0f;
  }
  float maxTop=mAllowCrop ? mCropRect.top : 0.0f;
  float maxBottom=mAllowCrop ? mCropRect.bottom : getHeight();
  float t=mTranslateRect.top;
  float b=mTranslateRect.bottom;
  final float translateY;
  if (b - t < maxBottom - maxTop) {
    translateY=maxTop + ((maxBottom - maxTop) - (b + t)) / 2;
  }
 else   if (t > maxTop) {
    translateY=maxTop - t;
  }
 else   if (b < maxBottom) {
    translateY=maxBottom - b;
  }
 else {
    translateY=0.0f;
  }
  if (Math.abs(translateX) > SNAP_THRESHOLD || Math.abs(translateY) > SNAP_THRESHOLD) {
    mSnapRunnable.start(translateX,translateY);
  }
 else {
    mMatrix.postTranslate(translateX,translateY);
    invalidate();
  }
}

private void snap ( ) { mTranslateRect . set ( mTempSrc ) ; mMatrix . mapRect ( mTranslateRect ) ; float maxLeft = mAllowCrop ? mCropRect . left : 0.0f ; float maxRight = mAllowCrop ? mCropRect . right : getWidth ( ) ; float l = mTranslateRect . left ; float r = mTranslateRect . right ; final float translateX ; if ( r - l < maxRight - maxLeft ) { translateX = maxLeft + ( ( maxRight - maxLeft ) - ( r + l ) ) / 2 ; } else if ( l > maxLeft ) { translateX = maxLeft - l ; } else if ( r < maxRight ) { translateX = maxRight - r ; } else { translateX = 0.0f ; } float maxTop = mAllowCrop ? mCropRect . top : 0.0f ; float maxBottom = mAllowCrop ? mCropRect . bottom : getHeight ( ) ; float t = mTranslateRect . top ; float b = mTranslateRect . bottom ; final float translateY ; if ( b - t < maxBottom - maxTop ) { translateY = maxTop + ( ( maxBottom - maxTop ) - ( b + t ) ) / 2 ; } else if ( t > maxTop ) { translateY = maxTop - t ; } else if ( b < maxBottom ) { translateY = maxBottom - b ; } else { translateY = 0.0f ; } if ( Math . abs ( translateX ) > SNAP_THRESHOLD || Math . abs ( translateY ) > SNAP_THRESHOLD ) { mSnapRunnable . start ( translateX , translateY ) ; } else { mMatrix . postTranslate ( translateX , translateY ) ; invalidate ( ) ; } }
snaps the image so it touches all edges of the view .
