private void adjustTop(RectF rect,float top,RectF bounds,float snapMargin,float aspectRatio,boolean leftMoves,boolean rightMoves){
  float newTop=top;
  if (newTop < 0) {
    newTop/=1.05f;
    mTouchOffset.y-=newTop / 1.1f;
  }
  if (newTop < bounds.top) {
    mTouchOffset.y-=(newTop - bounds.top) / 2f;
  }
  if (newTop - bounds.top < snapMargin) {
    newTop=bounds.top;
  }
  if (rect.bottom - newTop < mMinCropHeight) {
    newTop=rect.bottom - mMinCropHeight;
  }
  if (rect.bottom - newTop > mMaxCropHeight) {
    newTop=rect.bottom - mMaxCropHeight;
  }
  if (newTop - bounds.top < snapMargin) {
    newTop=bounds.top;
  }
  if (aspectRatio > 0) {
    float newWidth=(rect.bottom - newTop) * aspectRatio;
    if (newWidth < mMinCropWidth) {
      newTop=Math.max(bounds.top,rect.bottom - (mMinCropWidth / aspectRatio));
      newWidth=(rect.bottom - newTop) * aspectRatio;
    }
    if (newWidth > mMaxCropWidth) {
      newTop=Math.max(bounds.top,rect.bottom - (mMaxCropWidth / aspectRatio));
      newWidth=(rect.bottom - newTop) * aspectRatio;
    }
    if (leftMoves && rightMoves) {
      newTop=Math.max(newTop,Math.max(bounds.top,rect.bottom - bounds.width() / aspectRatio));
    }
 else {
      if (leftMoves && rect.right - newWidth < bounds.left) {
        newTop=Math.max(bounds.top,rect.bottom - (rect.right - bounds.left) / aspectRatio);
        newWidth=(rect.bottom - newTop) * aspectRatio;
      }
      if (rightMoves && rect.left + newWidth > bounds.right) {
        newTop=Math.max(newTop,Math.max(bounds.top,rect.bottom - (bounds.right - rect.left) / aspectRatio));
      }
    }
  }
  rect.top=newTop;
}

private void adjustTop ( RectF rect , float top , RectF bounds , float snapMargin , float aspectRatio , boolean leftMoves , boolean rightMoves ) { float newTop = top ; if ( newTop < 0 ) { newTop /= 1.05f ; mTouchOffset . y -= newTop / 1.1f ; } if ( newTop < bounds . top ) { mTouchOffset . y -= ( newTop - bounds . top ) / 2f ; } if ( newTop - bounds . top < snapMargin ) { newTop = bounds . top ; } if ( rect . bottom - newTop < mMinCropHeight ) { newTop = rect . bottom - mMinCropHeight ; } if ( rect . bottom - newTop > mMaxCropHeight ) { newTop = rect . bottom - mMaxCropHeight ; } if ( newTop - bounds . top < snapMargin ) { newTop = bounds . top ; } if ( aspectRatio > 0 ) { float newWidth = ( rect . bottom - newTop ) * aspectRatio ; if ( newWidth < mMinCropWidth ) { newTop = Math . max ( bounds . top , rect . bottom - ( mMinCropWidth / aspectRatio ) ) ; newWidth = ( rect . bottom - newTop ) * aspectRatio ; } if ( newWidth > mMaxCropWidth ) { newTop = Math . max ( bounds . top , rect . bottom - ( mMaxCropWidth / aspectRatio ) ) ; newWidth = ( rect . bottom - newTop ) * aspectRatio ; } if ( leftMoves && rightMoves ) { newTop = Math . max ( newTop , Math . max ( bounds . top , rect . bottom - bounds . width ( ) / aspectRatio ) ) ; } else { if ( leftMoves && rect . right - newWidth < bounds . left ) { newTop = Math . max ( bounds . top , rect . bottom - ( rect . right - bounds . left ) / aspectRatio ) ; newWidth = ( rect . bottom - newTop ) * aspectRatio ; } if ( rightMoves && rect . left + newWidth > bounds . right ) { newTop = Math . max ( newTop , Math . max ( bounds . top , rect . bottom - ( bounds . right - rect . left ) / aspectRatio ) ) ; } } } rect . top = newTop ; }
get the resulting y - position of the top edge of the crop window given the handle ' s position and the image ' s bounding box and snap radius .
