Skip to content

Commit

Permalink
Merge pull request #4 from SimonStefan/master
Browse files Browse the repository at this point in the history
minimize round-off error
  • Loading branch information
jesperborgstrup committed Aug 14, 2015
2 parents b9df2d5 + 7e1b6dc commit a0b63e7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/com/buzzingandroid/ui/ViewAspectRatioMeasurer.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ public void measure(int widthMeasureSpec, int heightMeasureSpec, double aspectRa
/*
* Possibility 2: Width dynamic, height fixed
*/
measuredWidth = (int) Math.min( widthSize, heightSize * aspectRatio );
measuredHeight = (int) (measuredWidth / aspectRatio);
measuredHeight = (int) Math.min( heightSize, widthSize / aspectRatio );
measuredWidth = (int) (measuredHeight * aspectRatio);

} else if ( widthMode == MeasureSpec.EXACTLY ) {
/*
* Possibility 3: Width fixed, height dynamic
*/
measuredHeight = (int) Math.min( heightSize, widthSize / aspectRatio );
measuredWidth = (int) (measuredHeight * aspectRatio);
measuredWidth = (int) Math.min( widthSize, heightSize * aspectRatio );
measuredHeight = (int) (measuredWidth / aspectRatio);

} else {
/*
Expand Down

0 comments on commit a0b63e7

Please sign in to comment.