Fix: No need for density

This commit is contained in:
vakrilov
2017-02-22 17:47:35 +02:00
parent 1e399800b1
commit 909bc357de

View File

@@ -12,7 +12,6 @@ import org.nativescript.widgets.image.Worker;
/**
* @author hhristov
*
*/
public class ImageView extends android.widget.ImageView {
private static final double EPSILON = 1E-05;
@@ -190,8 +189,8 @@ public class ImageView extends android.widget.ImageView {
@Override
protected void onDraw(Canvas canvas) {
BorderDrawable background = this.getBackground() instanceof BorderDrawable ? (BorderDrawable) this.getBackground() : null;
float uniformBorderWidth = background != null ? background.getUniformBorderWidth() * background.getDensity() : 0;
float uniformBorderRadius = background != null ? background.getUniformBorderRadius() * background.getDensity() : 0;
float uniformBorderWidth = background != null ? background.getUniformBorderWidth() : 0;
float uniformBorderRadius = background != null ? background.getUniformBorderRadius() : 0;
// floor the border width to avoid gaps between the border and the image
float roundedBorderWidth = (float) Math.floor(uniformBorderWidth);
@@ -241,8 +240,7 @@ public class ImageView extends android.widget.ImageView {
if (scaleType == ScaleType.FIT_CENTER || scaleType == ScaleType.MATRIX) {
scale = (scaleX < scaleY) ? scaleX : scaleY;
}
else if (scaleType == ScaleType.CENTER_CROP) {
} else if (scaleType == ScaleType.CENTER_CROP) {
scale = (scaleX < scaleY) ? scaleY : scaleX;
}
@@ -252,8 +250,7 @@ public class ImageView extends android.widget.ImageView {
if (scaleType == ScaleType.CENTER_CROP || scaleType == ScaleType.FIT_CENTER || scaleType == ScaleType.MATRIX) {
matrix.postScale(scale, scale);
matrix.postTranslate(-(bitmapWidth * scale) / 2, -(bitmapHeight * scale) / 2);
}
else if (scaleType == ScaleType.FIT_XY) {
} else if (scaleType == ScaleType.FIT_XY) {
matrix.postScale(scaleX, scaleY);
matrix.postTranslate(-((bitmapWidth * scaleX) + roundedBorderWidth) / 2, -((bitmapHeight * scaleY) + roundedBorderWidth) / 2);
}
@@ -262,8 +259,7 @@ public class ImageView extends android.widget.ImageView {
matrix.postTranslate(viewWidth / 2 + roundedBorderWidth, viewHeight / 2 + roundedBorderWidth);
canvas.drawBitmap(this.mBitmap, matrix, null);
}
else {
} else {
super.onDraw(canvas);
}
}