diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/library/build.gradle b/library/build.gradle index 1570a208..7a819061 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -18,7 +18,7 @@ android targetSdkVersion 27 versionCode 21 - versionName "2.6.0" + versionName "2.6.1" } buildTypes diff --git a/library/src/main/java/com/smartnsoft/droid4me/support/v7/widget/SmartAppCompatImageView.java b/library/src/main/java/com/smartnsoft/droid4me/support/v7/widget/SmartAppCompatImageView.java index c1529792..3c5cc767 100644 --- a/library/src/main/java/com/smartnsoft/droid4me/support/v7/widget/SmartAppCompatImageView.java +++ b/library/src/main/java/com/smartnsoft/droid4me/support/v7/widget/SmartAppCompatImageView.java @@ -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 @@ -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; @@ -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; @@ -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; diff --git a/library/src/main/java/com/smartnsoft/droid4me/widget/SmartViewExtension.java b/library/src/main/java/com/smartnsoft/droid4me/widget/SmartViewExtension.java index f864248b..5fefebc5 100644 --- a/library/src/main/java/com/smartnsoft/droid4me/widget/SmartViewExtension.java +++ b/library/src/main/java/com/smartnsoft/droid4me/widget/SmartViewExtension.java @@ -55,7 +55,7 @@ final class ViewExtensionDelegate private OnSizeChangedListener onSizeChangedListener; /** - * Holds the widget current vertical/horizontal dimensions ratio; + * Holds the widget current horizontal/vertical dimensions ratio; */ private float ratio = 0f; @@ -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; @@ -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; @@ -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 @@ -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}. *

*

*