Skip to content

Commit f2aec97

Browse files
committed
Fixed checkstyle warnings and errors.
1 parent e1f73f7 commit f2aec97

File tree

4 files changed

+31
-10
lines changed

4 files changed

+31
-10
lines changed

superimageview-imagecrop/src/main/java/com/codeforvictory/android/superimageview/crop/ImageTransformation.java

+17-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.os.Build;
66

77
import com.codeforvictory.android.superimageview.Crop;
8+
import com.codeforvictory.android.superimageview.crop.error.IllegalTransformationType;
89

910
import androidx.annotation.Nullable;
1011

@@ -41,10 +42,18 @@ void compute(@CropType int cropType) {
4142

4243
boolean verticalImageMode = scaleX > scaleY;
4344

44-
float postDrawableWidth = drawableWidth * scale;
45-
float xTranslation = getXTranslation(cropType, viewWidth, postDrawableWidth, verticalImageMode);
46-
float postDrawabeHeigth = drawableHeight * scale;
47-
float yTranslation = getYTranslation(cropType, viewHeight, postDrawabeHeigth, verticalImageMode);
45+
float xTranslation = getXTranslation(
46+
cropType,
47+
viewWidth,
48+
drawableWidth * scale,
49+
verticalImageMode
50+
);
51+
float yTranslation = getYTranslation(
52+
cropType,
53+
viewHeight,
54+
drawableHeight * scale,
55+
verticalImageMode
56+
);
4857

4958
matrix.postTranslate(xTranslation, yTranslation);
5059
view.setImageMatrix(matrix);
@@ -67,6 +76,8 @@ private float getYTranslation(
6776
case CropType.RIGHT_CENTER:
6877
// View in the middle of the screen
6978
return (viewHeight - postDrawableHeight) / 2f;
79+
default:
80+
throw new IllegalTransformationType("Transformation not supported. Check if the transformation you want to do should be handled by the method getXTranslation()");
7081
}
7182
}
7283

@@ -90,6 +101,8 @@ private float getXTranslation(
90101
case CropType.CENTER_BOTTOM:
91102
// View in the middle of the screen
92103
return (viewWidth - postDrawableWidth) / 2f;
104+
default:
105+
throw new IllegalTransformationType("Transformation not supported. Check if the transformation you want to do should be handled by the method getYTranslation()");
93106
}
94107
}
95108
// All other cases we don't need to translate
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.codeforvictory.android.superimageview.crop.error;
2+
3+
public final class IllegalTransformationType extends IllegalStateException {
4+
5+
public IllegalTransformationType(String s) {
6+
super(s);
7+
}
8+
}

superimageview-roundedcorners/src/main/java/com/codeforvictory/android/superimageview/roundedcorners/RoundedCornersImage.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public void onDraw(Canvas canvas) {
7878
clipPath.close();
7979
}
8080

81-
if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.O_MR1){
82-
canvas.drawPath(clipPath, clipPaint);
81+
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O_MR1) {
82+
canvas.drawPath(clipPath, clipPaint);
8383
} else {
8484
// canvas.drawPath(rectView, clipPaint);
8585
}

superimageview/src/main/java/com/codeforvictory/android/superimageview/SuperImageView.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private void setupCrop(String cropImplementation, Context context, AttributeSet
122122
// Class<?> cl = Class.forName(cropImplementation);
123123
cropImpl = Class.forName(cropImplementation);
124124
Constructor<?> constructor = cropImpl.getConstructor(Crop.View.class);
125-
Object[] constructorArgs = new Object[]{new Crop.View() {
125+
Object[] constructorArgs = new Object[]{ new Crop.View() {
126126
@Override
127127
public Drawable getDrawable() {
128128
return SuperImageView.super.getDrawable();
@@ -193,7 +193,7 @@ public void requestLayout() {
193193
public void invalidate() {
194194
SuperImageView.super.invalidate();
195195
}
196-
}};
196+
} };
197197
crop = (Crop) constructor.newInstance(constructorArgs);
198198
// Object o = constructor.newInstance(constructorArgs);
199199
crop.setup(context, attributeSet);
@@ -228,7 +228,7 @@ private void setupRoundedCorners(String roundedCornersImplementation, Context co
228228
try {
229229
Class<?> cl = Class.forName(roundedCornersImplementation);
230230
Constructor<?> constructor = cl.getConstructor(RoundedCorners.View.class);
231-
Object[] constructorArgs = new Object[]{new RoundedCorners.View() {
231+
Object[] constructorArgs = new Object[]{ new RoundedCorners.View() {
232232
@NonNull
233233
@Override
234234
public Context getContext() {
@@ -244,7 +244,7 @@ public void setLayerType(int layerType, @Nullable Paint paint) {
244244
public void setWillNotDraw(boolean willNotDraw) {
245245
SuperImageView.super.setWillNotDraw(willNotDraw);
246246
}
247-
}};
247+
} };
248248
roundedCorners = (RoundedCorners) constructor.newInstance(constructorArgs);
249249
roundedCorners.setup(context, attributeSet);
250250
} catch (ClassNotFoundException e) {

0 commit comments

Comments
 (0)