package androidx.swiperefreshlayout.widget; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.RadialGradient; import android.graphics.Shader; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.OvalShape; import android.view.animation.Animation; import android.widget.ImageView; import androidx.core.content.ContextCompat; import androidx.core.view.ViewCompat; /* loaded from: classes.dex */ class CircleImageView extends ImageView { private static final int FILL_SHADOW_COLOR = 1023410176; private static final int KEY_SHADOW_COLOR = 503316480; private static final int SHADOW_ELEVATION = 4; private static final float SHADOW_RADIUS = 3.5f; private static final float X_OFFSET = 0.0f; private static final float Y_OFFSET = 1.75f; private Animation.AnimationListener mListener; int mShadowRadius; private boolean elevationSupported() { return true; } public void setAnimationListener(Animation.AnimationListener animationListener) { this.mListener = animationListener; } public CircleImageView(Context context, int i) { super(context); ShapeDrawable shapeDrawable; float f = getContext().getResources().getDisplayMetrics().density; int i2 = (int) (Y_OFFSET * f); int i3 = (int) (0.0f * f); this.mShadowRadius = (int) (SHADOW_RADIUS * f); if (elevationSupported()) { shapeDrawable = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, f * 4.0f); } else { ShapeDrawable shapeDrawable2 = new ShapeDrawable(new OvalShadow(this.mShadowRadius)); setLayerType(1, shapeDrawable2.getPaint()); shapeDrawable2.getPaint().setShadowLayer(this.mShadowRadius, i3, i2, KEY_SHADOW_COLOR); int i4 = this.mShadowRadius; setPadding(i4, i4, i4, i4); shapeDrawable = shapeDrawable2; } shapeDrawable.getPaint().setColor(i); ViewCompat.setBackground(this, shapeDrawable); } @Override // android.widget.ImageView, android.view.View public void onMeasure(int i, int i2) { super.onMeasure(i, i2); if (elevationSupported()) { return; } setMeasuredDimension(getMeasuredWidth() + (this.mShadowRadius * 2), getMeasuredHeight() + (this.mShadowRadius * 2)); } @Override // android.view.View public void onAnimationStart() { super.onAnimationStart(); Animation.AnimationListener animationListener = this.mListener; if (animationListener != null) { animationListener.onAnimationStart(getAnimation()); } } @Override // android.view.View public void onAnimationEnd() { super.onAnimationEnd(); Animation.AnimationListener animationListener = this.mListener; if (animationListener != null) { animationListener.onAnimationEnd(getAnimation()); } } public void setBackgroundColorRes(int i) { setBackgroundColor(ContextCompat.getColor(getContext(), i)); } @Override // android.view.View public void setBackgroundColor(int i) { if (getBackground() instanceof ShapeDrawable) { ((ShapeDrawable) getBackground()).getPaint().setColor(i); } } public class OvalShadow extends OvalShape { private RadialGradient mRadialGradient; private Paint mShadowPaint = new Paint(); public OvalShadow(int i) { CircleImageView.this.mShadowRadius = i; updateRadialGradient((int) rect().width()); } @Override // android.graphics.drawable.shapes.RectShape, android.graphics.drawable.shapes.Shape public void onResize(float f, float f2) { super.onResize(f, f2); updateRadialGradient((int) f); } @Override // android.graphics.drawable.shapes.OvalShape, android.graphics.drawable.shapes.RectShape, android.graphics.drawable.shapes.Shape public void draw(Canvas canvas, Paint paint) { float width = CircleImageView.this.getWidth() / 2; float height = CircleImageView.this.getHeight() / 2; canvas.drawCircle(width, height, width, this.mShadowPaint); canvas.drawCircle(width, height, r0 - CircleImageView.this.mShadowRadius, paint); } private void updateRadialGradient(int i) { float f = i / 2; RadialGradient radialGradient = new RadialGradient(f, f, CircleImageView.this.mShadowRadius, new int[]{CircleImageView.FILL_SHADOW_COLOR, 0}, (float[]) null, Shader.TileMode.CLAMP); this.mRadialGradient = radialGradient; this.mShadowPaint.setShader(radialGradient); } } }