We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As it shows here https://bintray.com/bintray/jcenter/com.pkmmte.view%3Acircularimageview/1.1/view#files, the aar file is 12 months old and when I decompiled the class in Android Studio, I get old stuff.
// // Source code recreated from a .class file by IntelliJ IDEA // (powered by Fernflower decompiler) // package com.pkmmte.view; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.BitmapShader; import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.graphics.Bitmap.Config; import android.graphics.PorterDuff.Mode; import android.graphics.Shader.TileMode; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View.MeasureSpec; import android.widget.ImageView; import com.pkmmte.view.R.attr; import com.pkmmte.view.R.styleable; public class CircularImageView extends ImageView { private boolean hasBorder; private boolean hasSelector; private boolean isSelected; private int borderWidth; private int canvasSize; private int selectorStrokeWidth; private BitmapShader shader; private Bitmap image; private Paint paint; private Paint paintBorder; private Paint paintSelectorBorder; private ColorFilter selectorFilter; public CircularImageView(Context context) { this(context, (AttributeSet)null); } public CircularImageView(Context context, AttributeSet attrs) { this(context, attrs, attr.circularImageViewStyle); } public CircularImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); this.init(context, attrs, defStyle); } private void init(Context context, AttributeSet attrs, int defStyle) { this.paint = new Paint(); this.paint.setAntiAlias(true); this.paintBorder = new Paint(); this.paintBorder.setAntiAlias(true); this.paintSelectorBorder = new Paint(); this.paintSelectorBorder.setAntiAlias(true); TypedArray attributes = context.obtainStyledAttributes(attrs, styleable.CircularImageView, defStyle, 0); this.hasBorder = attributes.getBoolean(0, false); this.hasSelector = attributes.getBoolean(3, false); int defaultSelectorSize; if(this.hasBorder) { defaultSelectorSize = (int)(2.0F * context.getResources().getDisplayMetrics().density + 0.5F); this.setBorderWidth(attributes.getDimensionPixelOffset(2, defaultSelectorSize)); this.setBorderColor(attributes.getColor(1, -1)); } if(this.hasSelector) { defaultSelectorSize = (int)(2.0F * context.getResources().getDisplayMetrics().density + 0.5F); this.setSelectorColor(attributes.getColor(4, 0)); this.setSelectorStrokeWidth(attributes.getDimensionPixelOffset(6, defaultSelectorSize)); this.setSelectorStrokeColor(attributes.getColor(5, -16776961)); } if(attributes.getBoolean(7, false)) { this.addShadow(); } attributes.recycle(); } public void setBorderWidth(int borderWidth) { this.borderWidth = borderWidth; this.requestLayout(); this.invalidate(); } public void setBorderColor(int borderColor) { if(this.paintBorder != null) { this.paintBorder.setColor(borderColor); } this.invalidate(); } public void setSelectorColor(int selectorColor) { this.selectorFilter = new PorterDuffColorFilter(selectorColor, Mode.SRC_ATOP); this.invalidate(); } public void setSelectorStrokeWidth(int selectorStrokeWidth) { this.selectorStrokeWidth = selectorStrokeWidth; this.requestLayout(); this.invalidate(); } public void setSelectorStrokeColor(int selectorStrokeColor) { if(this.paintSelectorBorder != null) { this.paintSelectorBorder.setColor(selectorStrokeColor); } this.invalidate(); } public void addShadow() { this.setLayerType(1, this.paintBorder); this.paintBorder.setShadowLayer(4.0F, 0.0F, 2.0F, -16777216); } public void onDraw(Canvas canvas) { if(this.image != null) { if(this.image.getHeight() != 0 && this.image.getWidth() != 0) { int oldCanvasSize = this.canvasSize; this.canvasSize = canvas.getWidth(); if(canvas.getHeight() < this.canvasSize) { this.canvasSize = canvas.getHeight(); } if(oldCanvasSize != this.canvasSize) { this.refreshBitmapShader(); } this.paint.setShader(this.shader); int outerWidth = 0; int center = this.canvasSize / 2; if(this.hasSelector && this.isSelected) { outerWidth = this.selectorStrokeWidth; center = (this.canvasSize - outerWidth * 2) / 2; this.paint.setColorFilter(this.selectorFilter); canvas.drawCircle((float)(center + outerWidth), (float)(center + outerWidth), (float)((this.canvasSize - outerWidth * 2) / 2 + outerWidth) - 4.0F, this.paintSelectorBorder); } else if(this.hasBorder) { outerWidth = this.borderWidth; center = (this.canvasSize - outerWidth * 2) / 2; this.paint.setColorFilter((ColorFilter)null); canvas.drawCircle((float)(center + outerWidth), (float)(center + outerWidth), (float)((this.canvasSize - outerWidth * 2) / 2 + outerWidth) - 4.0F, this.paintBorder); } else { this.paint.setColorFilter((ColorFilter)null); } canvas.drawCircle((float)(center + outerWidth), (float)(center + outerWidth), (float)((this.canvasSize - outerWidth * 2) / 2) - 4.0F, this.paint); } } } public boolean dispatchTouchEvent(MotionEvent event) { if(!this.isClickable()) { this.isSelected = false; return super.onTouchEvent(event); } else { switch(event.getAction()) { case 0: this.isSelected = true; break; case 1: case 3: case 4: case 8: this.isSelected = false; case 2: case 5: case 6: case 7: } this.invalidate(); return super.dispatchTouchEvent(event); } } public void invalidate(Rect dirty) { super.invalidate(dirty); this.image = this.drawableToBitmap(this.getDrawable()); if(this.shader != null || this.canvasSize > 0) { this.refreshBitmapShader(); } } public void invalidate(int l, int t, int r, int b) { super.invalidate(l, t, r, b); this.image = this.drawableToBitmap(this.getDrawable()); if(this.shader != null || this.canvasSize > 0) { this.refreshBitmapShader(); } } public void invalidate() { super.invalidate(); this.image = this.drawableToBitmap(this.getDrawable()); if(this.shader != null || this.canvasSize > 0) { this.refreshBitmapShader(); } } protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int width = this.measureWidth(widthMeasureSpec); int height = this.measureHeight(heightMeasureSpec); this.setMeasuredDimension(width, height); } private int measureWidth(int measureSpec) { int specMode = MeasureSpec.getMode(measureSpec); int specSize = MeasureSpec.getSize(measureSpec); int result; if(specMode == 1073741824) { result = specSize; } else if(specMode == -2147483648) { result = specSize; } else { result = this.canvasSize; } return result; } private int measureHeight(int measureSpecHeight) { boolean result = false; int specMode = MeasureSpec.getMode(measureSpecHeight); int specSize = MeasureSpec.getSize(measureSpecHeight); int result1; if(specMode == 1073741824) { result1 = specSize; } else if(specMode == -2147483648) { result1 = specSize; } else { result1 = this.canvasSize; } return result1 + 2; } public Bitmap drawableToBitmap(Drawable drawable) { if(drawable == null) { return null; } else if(drawable instanceof BitmapDrawable) { return ((BitmapDrawable)drawable).getBitmap(); } else { Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return bitmap; } } public void refreshBitmapShader() { this.shader = new BitmapShader(Bitmap.createScaledBitmap(this.image, this.canvasSize, this.canvasSize, false), TileMode.CLAMP, TileMode.CLAMP); } public boolean isSelected() { return this.isSelected; } }
The text was updated successfully, but these errors were encountered:
Yeah. Same issue here. For now, I just copied the library into my project but would be cool if it was updated.
Sorry, something went wrong.
No branches or pull requests
As it shows here https://bintray.com/bintray/jcenter/com.pkmmte.view%3Acircularimageview/1.1/view#files, the aar file is 12 months old and when I decompiled the class in Android Studio, I get old stuff.
The text was updated successfully, but these errors were encountered: