private static int getOnMeasureSpec(int measureSpecMode, int measureSpecSize, int desiredSize) {

    // Measure Width
    int spec;
    if (measureSpecMode == MeasureSpec.EXACTLY) {
      // Must be this size
      spec = measureSpecSize;
    } else if (measureSpecMode == MeasureSpec.AT_MOST) {
      // Can't be bigger than...; match_parent value
      spec = Math.min(desiredSize, measureSpecSize);
    } else {
      // Be whatever you want; wrap_content
      spec = desiredSize;
    }

    return spec;
  }
Determines the specs for the onMeasure function. Calculates the width or height depending on
the mode.

@param measureSpecMode The mode of the measured width or height.
@param measureSpecSize The size of the measured width or height.
@param desiredSize The desired size of the measured width or height.
@return The final size of the width or height.
core/src/main/java/com/theartofdev/edmodo/cropper/CropImageView.java