private void adjustTopBottomByAspectRatio(RectF rect, RectF bounds, float aspectRatio) {
    rect.inset(0, (rect.height() - rect.width() / aspectRatio) / 2);
    if (rect.top < bounds.top) {
      rect.offset(0, bounds.top - rect.top);
    }
    if (rect.bottom > bounds.bottom) {
      rect.offset(0, bounds.bottom - rect.bottom);
    }
  }
Adjust top and bottom edges by current crop window width and the given aspect ratio, both top
and bottom edges adjusts equally relative to center to keep aspect ratio to the width.
core/src/main/java/com/theartofdev/edmodo/cropper/CropWindowMoveHandler.java