Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Maltyz committed Jan 5, 2018
2 parents d1270f0 + 36811dd commit a6cae7d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Empty file modified gradlew
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android
targetSdkVersion 27

versionCode 21
versionName "2.6.0"
versionName "2.6.1"
}

buildTypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public SmartAppCompatImageView(Context context, AttributeSet attrs, int defStyle
{
super(context, attrs, defStyle);
initializeViewExtensionDelegateIfNecessary();
viewExtensionDelegate.setRatio(9f / 16f);
viewExtensionDelegate.setRatio(16f / 9f);
}

@Override
Expand Down Expand Up @@ -172,7 +172,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
else if (widthMode == MeasureSpec.EXACTLY)
{
finalWidth = originalWidth;
final float idealHeight = finalWidth * actualRatio;
final float idealHeight = finalWidth / actualRatio;
if (heightMode == MeasureSpec.UNSPECIFIED)
{
finalHeight = (int) idealHeight;
Expand All @@ -185,7 +185,7 @@ else if (widthMode == MeasureSpec.EXACTLY)
else if (heightMode == MeasureSpec.EXACTLY)
{
finalHeight = originalHeight;
final float idealWidth = finalHeight / actualRatio;
final float idealWidth = finalHeight * actualRatio;
if (widthMode == MeasureSpec.UNSPECIFIED)
{
finalWidth = (int) idealWidth;
Expand All @@ -206,13 +206,13 @@ else if (heightMode == MeasureSpec.EXACTLY)
else
{
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (ratio > 0f)
if (ratio < 0f)
{
final int measuredWidth = getMeasuredWidth();
final int newHeight = (int) ((float) getMeasuredWidth() * ratio);
setMeasuredDimension(measuredWidth, newHeight);
}
else if (ratio < 0f)
else if (ratio > 0f)
{
final int measuredHeight = getMeasuredHeight();
final int newWidth = (int) ((float) getMeasuredHeight() * ratio) * -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ final class ViewExtensionDelegate<ViewClass extends View>
private OnSizeChangedListener<ViewClass> onSizeChangedListener;

/**
* Holds the widget current vertical/horizontal dimensions ratio;
* Holds the widget current horizontal/vertical dimensions ratio;
*/
private float ratio = 0f;

Expand Down Expand Up @@ -211,7 +211,7 @@ public void onSuperMeasure(int widthMeasureSpec, int heightMeasureSpec)
else if (originalWidthMode == MeasureSpec.EXACTLY)
{
finalWidth = originalWidth;
final float idealHeight = finalWidth * actualRatio;
final float idealHeight = finalWidth / actualRatio;
if (originalHeightMode == MeasureSpec.UNSPECIFIED)
{
finalHeight = (int) idealHeight;
Expand All @@ -224,7 +224,7 @@ else if (originalWidthMode == MeasureSpec.EXACTLY)
else if (originalHeightMode == MeasureSpec.EXACTLY)
{
finalHeight = originalHeight;
final float idealWidth = finalHeight / actualRatio;
final float idealWidth = finalHeight * actualRatio;
if (originalWidthMode == MeasureSpec.UNSPECIFIED)
{
finalWidth = (int) idealWidth;
Expand Down Expand Up @@ -256,11 +256,11 @@ else if (originalHeightMode == MeasureSpec.EXACTLY)
final float actualRatio = ratio > 0 ? ratio : -1f / ratio;
final int originalWidth = MeasureSpec.getSize(widthMeasureSpec);
final int originalHeight = MeasureSpec.getSize(heightMeasureSpec);
final int calculatedHeight = (int) ((float) originalWidth * actualRatio);
final int calculatedHeight = (int) ((float) originalWidth / actualRatio);
final int finalWidth, finalHeight;
if (originalHeight > 0 && calculatedHeight > originalHeight)
{
finalWidth = (int) ((float) originalHeight / actualRatio);
finalWidth = (int) ((float) originalHeight * actualRatio);
finalHeight = originalHeight;
}
else
Expand Down Expand Up @@ -295,18 +295,18 @@ public void onSizeChanged(ViewClass view, int newWidth, int newHeight, int oldWi
}

/**
* @return the vertical/horizontal ratio ; when set to {@code 0}, no ratio is applied {@link #setRatio(float)}
* @return the horizontal/vertical ratio ; when set to {@code 0}, no ratio is applied {@link #setRatio(float)}
* @see #setRatio(float)
*/
float getRatio();

/**
* Sets the ratio between the width and the height of the image.
* More formally, the value of the ratio is equal to the height divided by the width. The default value is {@code 9 / 16}.
* More formally, the value of the ratio is equal to the width divided by the height. The default value is {@code 16 / 9}.
* <p>
* <ul>
* <li>When set to a positive value, the image width is taken as a reference to force the height.</li>
* <li>When set to a negative value, the image height is taken as a reference to force the width, and the {@code ratio} argument absolute value is
* <li>When set to a positive value, the image height is taken as a reference to force the width.</li>
* <li>When set to a negative value, the image width is taken as a reference to force the height, and the {@code ratio} argument absolute value is
* taken.</li>
* </ul>
*
Expand Down

0 comments on commit a6cae7d

Please sign in to comment.