private void adjustRight(RectF rect,float right,RectF bounds,int viewWidth,float snapMargin,float aspectRatio,boolean topMoves,boolean bottomMoves){
  float newRight=right;
  if (newRight > viewWidth) {
    newRight=viewWidth + (newRight - viewWidth) / 1.05f;
    mTouchOffset.x-=(newRight - viewWidth) / 1.1f;
  }
  if (newRight > bounds.right) {
    mTouchOffset.x-=(newRight - bounds.right) / 2f;
  }
  if (bounds.right - newRight < snapMargin) {
    newRight=bounds.right;
  }
  if (newRight - rect.left < mMinCropWidth) {
    newRight=rect.left + mMinCropWidth;
  }
  if (newRight - rect.left > mMaxCropWidth) {
    newRight=rect.left + mMaxCropWidth;
  }
  if (bounds.right - newRight < snapMargin) {
    newRight=bounds.right;
  }
  if (aspectRatio > 0) {
    float newHeight=(newRight - rect.left) / aspectRatio;
    if (newHeight < mMinCropHeight) {
      newRight=Math.min(bounds.right,rect.left + mMinCropHeight * aspectRatio);
      newHeight=(newRight - rect.left) / aspectRatio;
    }
    if (newHeight > mMaxCropHeight) {
      newRight=Math.min(bounds.right,rect.left + mMaxCropHeight * aspectRatio);
      newHeight=(newRight - rect.left) / aspectRatio;
    }
    if (topMoves && bottomMoves) {
      newRight=Math.min(newRight,Math.min(bounds.right,rect.left + bounds.height() * aspectRatio));
    }
 else {
      if (topMoves && rect.bottom - newHeight < bounds.top) {
        newRight=Math.min(bounds.right,rect.left + (rect.bottom - bounds.top) * aspectRatio);
        newHeight=(newRight - rect.left) / aspectRatio;
      }
      if (bottomMoves && rect.top + newHeight > bounds.bottom) {
        newRight=Math.min(newRight,Math.min(bounds.right,rect.left + (bounds.bottom - rect.top) * aspectRatio));
      }
    }
  }
  rect.right=newRight;
}

private void adjustRight ( RectF rect , float right , RectF bounds , int viewWidth , float snapMargin , float aspectRatio , boolean topMoves , boolean bottomMoves ) { float newRight = right ; if ( newRight > viewWidth ) { newRight = viewWidth + ( newRight - viewWidth ) / 1.05f ; mTouchOffset . x -= ( newRight - viewWidth ) / 1.1f ; } if ( newRight > bounds . right ) { mTouchOffset . x -= ( newRight - bounds . right ) / 2f ; } if ( bounds . right - newRight < snapMargin ) { newRight = bounds . right ; } if ( newRight - rect . left < mMinCropWidth ) { newRight = rect . left + mMinCropWidth ; } if ( newRight - rect . left > mMaxCropWidth ) { newRight = rect . left + mMaxCropWidth ; } if ( bounds . right - newRight < snapMargin ) { newRight = bounds . right ; } if ( aspectRatio > 0 ) { float newHeight = ( newRight - rect . left ) / aspectRatio ; if ( newHeight < mMinCropHeight ) { newRight = Math . min ( bounds . right , rect . left + mMinCropHeight * aspectRatio ) ; newHeight = ( newRight - rect . left ) / aspectRatio ; } if ( newHeight > mMaxCropHeight ) { newRight = Math . min ( bounds . right , rect . left + mMaxCropHeight * aspectRatio ) ; newHeight = ( newRight - rect . left ) / aspectRatio ; } if ( topMoves && bottomMoves ) { newRight = Math . min ( newRight , Math . min ( bounds . right , rect . left + bounds . height ( ) * aspectRatio ) ) ; } else { if ( topMoves && rect . bottom - newHeight < bounds . top ) { newRight = Math . min ( bounds . right , rect . left + ( rect . bottom - bounds . top ) * aspectRatio ) ; newHeight = ( newRight - rect . left ) / aspectRatio ; } if ( bottomMoves && rect . top + newHeight > bounds . bottom ) { newRight = Math . min ( newRight , Math . min ( bounds . right , rect . left + ( bounds . bottom - rect . top ) * aspectRatio ) ) ; } } } rect . right = newRight ; }
get the resulting x - position of the right edge of the crop window given the handle ' s position and the image ' s bounding box and snap radius .
