package com.scwang.smartrefresh.header;

import IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.IFxWkV_5.PGPF6hQ_2;
import IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.X6FRs_4.IMuAHx_6;
import IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.X6FRs_4.Xgtqvk_8;
import IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.X6FRs_4.XnFJ5_9;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import com.google.android.material.bottomappbar.BottomAppBarTopEdgeTreatment;
/* loaded from: classes.dex */
public class BezierCircleHeader extends IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.FSaI4_7.QxJ9d_1 implements IMuAHx_6 {

    /* renamed from: IFxWkV_5  reason: collision with root package name */
    public float f3615IFxWkV_5;

    /* renamed from: IFxWkV_5  reason: collision with other field name */
    public boolean f2677IFxWkV_5;
    public float KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public int f2678KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public Xgtqvk_8 f2679KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public Paint f2680KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public Path f2681KQgRr5e_0;

    /* renamed from: Mqv2r_3  reason: collision with root package name */
    public float f3616Mqv2r_3;

    /* renamed from: Mqv2r_3  reason: collision with other field name */
    public boolean f2682Mqv2r_3;
    public float PGPF6hQ_2;

    /* renamed from: PGPF6hQ_2  reason: collision with other field name */
    public int f2683PGPF6hQ_2;

    /* renamed from: PGPF6hQ_2  reason: collision with other field name */
    public Paint f2684PGPF6hQ_2;

    /* renamed from: PGPF6hQ_2  reason: collision with other field name */
    public boolean f2685PGPF6hQ_2;
    public float QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public int f2686QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public Paint f2687QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public boolean f2688QxJ9d_1;

    /* renamed from: X6FRs_4  reason: collision with root package name */
    public float f3617X6FRs_4;

    /* renamed from: X6FRs_4  reason: collision with other field name */
    public boolean f2689X6FRs_4;

    /* loaded from: classes.dex */
    public class KQgRr5e_0 implements ValueAnimator.AnimatorUpdateListener {

        /* renamed from: Mqv2r_3  reason: collision with root package name */
        public final /* synthetic */ float f3618Mqv2r_3;
        public float QxJ9d_1;
        public float KQgRr5e_0 = 0.0f;
        public float PGPF6hQ_2 = 0.0f;

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public int f2690KQgRr5e_0 = 0;

        public KQgRr5e_0(float f) {
            this.f3618Mqv2r_3 = f;
        }

        @Override // android.animation.ValueAnimator.AnimatorUpdateListener
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            if (this.f2690KQgRr5e_0 == 0 && floatValue <= 0.0f) {
                this.f2690KQgRr5e_0 = 1;
                this.KQgRr5e_0 = Math.abs(floatValue - BezierCircleHeader.this.KQgRr5e_0);
            }
            if (this.f2690KQgRr5e_0 == 1) {
                float f = (-floatValue) / this.f3618Mqv2r_3;
                this.PGPF6hQ_2 = f;
                BezierCircleHeader bezierCircleHeader = BezierCircleHeader.this;
                if (f >= bezierCircleHeader.PGPF6hQ_2) {
                    bezierCircleHeader.PGPF6hQ_2 = f;
                    bezierCircleHeader.f3617X6FRs_4 = bezierCircleHeader.QxJ9d_1 + floatValue;
                    this.KQgRr5e_0 = Math.abs(floatValue - bezierCircleHeader.KQgRr5e_0);
                } else {
                    this.f2690KQgRr5e_0 = 2;
                    bezierCircleHeader.PGPF6hQ_2 = 0.0f;
                    bezierCircleHeader.f2685PGPF6hQ_2 = true;
                    bezierCircleHeader.f2682Mqv2r_3 = true;
                    this.QxJ9d_1 = bezierCircleHeader.f3617X6FRs_4;
                }
            }
            if (this.f2690KQgRr5e_0 == 2) {
                BezierCircleHeader bezierCircleHeader2 = BezierCircleHeader.this;
                float f2 = bezierCircleHeader2.f3617X6FRs_4;
                float f3 = bezierCircleHeader2.QxJ9d_1;
                if (f2 > f3 / 2.0f) {
                    bezierCircleHeader2.f3617X6FRs_4 = Math.max(f3 / 2.0f, f2 - this.KQgRr5e_0);
                    float animatedFraction = valueAnimator.getAnimatedFraction();
                    BezierCircleHeader bezierCircleHeader3 = BezierCircleHeader.this;
                    float f4 = this.QxJ9d_1;
                    float f5 = (animatedFraction * ((bezierCircleHeader3.QxJ9d_1 / 2.0f) - f4)) + f4;
                    if (bezierCircleHeader3.f3617X6FRs_4 > f5) {
                        bezierCircleHeader3.f3617X6FRs_4 = f5;
                    }
                }
            }
            BezierCircleHeader bezierCircleHeader4 = BezierCircleHeader.this;
            if (bezierCircleHeader4.f2682Mqv2r_3 && floatValue < bezierCircleHeader4.KQgRr5e_0) {
                bezierCircleHeader4.f2688QxJ9d_1 = true;
                bezierCircleHeader4.f2682Mqv2r_3 = false;
                bezierCircleHeader4.f2689X6FRs_4 = true;
                bezierCircleHeader4.f2683PGPF6hQ_2 = 90;
                bezierCircleHeader4.f2686QxJ9d_1 = 90;
            }
            BezierCircleHeader bezierCircleHeader5 = BezierCircleHeader.this;
            if (bezierCircleHeader5.f2677IFxWkV_5) {
                return;
            }
            bezierCircleHeader5.KQgRr5e_0 = floatValue;
            bezierCircleHeader5.invalidate();
        }
    }

    /* loaded from: classes.dex */
    public class QxJ9d_1 implements ValueAnimator.AnimatorUpdateListener {
        public QxJ9d_1() {
        }

        @Override // android.animation.ValueAnimator.AnimatorUpdateListener
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            BezierCircleHeader bezierCircleHeader = BezierCircleHeader.this;
            bezierCircleHeader.f3616Mqv2r_3 = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            bezierCircleHeader.invalidate();
        }
    }

    public BezierCircleHeader(Context context, AttributeSet attributeSet) {
        super(context, attributeSet, 0);
        this.f2686QxJ9d_1 = 90;
        this.f2683PGPF6hQ_2 = 90;
        this.f2689X6FRs_4 = true;
        this.f2677IFxWkV_5 = false;
        ((IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.FSaI4_7.QxJ9d_1) this).KQgRr5e_0 = PGPF6hQ_2.PGPF6hQ_2;
        setMinimumHeight(IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.XnFJ5_9.QxJ9d_1.m124KQgRr5e_0(100.0f));
        Paint paint = new Paint();
        this.f2680KQgRr5e_0 = paint;
        paint.setColor(-15614977);
        this.f2680KQgRr5e_0.setAntiAlias(true);
        Paint paint2 = new Paint();
        this.f2687QxJ9d_1 = paint2;
        paint2.setColor(-1);
        this.f2687QxJ9d_1.setAntiAlias(true);
        Paint paint3 = new Paint();
        this.f2684PGPF6hQ_2 = paint3;
        paint3.setAntiAlias(true);
        this.f2684PGPF6hQ_2.setColor(-1);
        this.f2684PGPF6hQ_2.setStyle(Paint.Style.STROKE);
        this.f2684PGPF6hQ_2.setStrokeWidth(IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.XnFJ5_9.QxJ9d_1.m124KQgRr5e_0(2.0f));
        this.f2681KQgRr5e_0 = new Path();
    }

    public final void KQgRr5e_0(Canvas canvas, int i, int i2) {
        float min = Math.min(this.QxJ9d_1, i2);
        if (this.KQgRr5e_0 != 0.0f) {
            this.f2681KQgRr5e_0.reset();
            float f = i;
            this.f2681KQgRr5e_0.lineTo(f, 0.0f);
            this.f2681KQgRr5e_0.lineTo(f, min);
            this.f2681KQgRr5e_0.quadTo(f / 2.0f, (this.KQgRr5e_0 * 2.0f) + min, 0.0f, min);
            this.f2681KQgRr5e_0.close();
            canvas.drawPath(this.f2681KQgRr5e_0, this.f2680KQgRr5e_0);
            return;
        }
        canvas.drawRect(0.0f, 0.0f, i, min, this.f2680KQgRr5e_0);
    }

    public final void Mqv2r_3(Canvas canvas, int i) {
        float f = this.PGPF6hQ_2;
        if (f > 0.0f) {
            float f2 = i;
            float f3 = f2 / 2.0f;
            float f4 = this.f3615IFxWkV_5;
            float f5 = (f3 - (4.0f * f4)) + (3.0f * f * f4);
            if (f < 0.9d) {
                this.f2681KQgRr5e_0.reset();
                this.f2681KQgRr5e_0.moveTo(f5, this.f3617X6FRs_4);
                Path path = this.f2681KQgRr5e_0;
                float f6 = this.f3617X6FRs_4;
                path.quadTo(f3, f6 - ((this.f3615IFxWkV_5 * this.PGPF6hQ_2) * 2.0f), f2 - f5, f6);
                canvas.drawPath(this.f2681KQgRr5e_0, this.f2687QxJ9d_1);
                return;
            }
            canvas.drawCircle(f3, this.f3617X6FRs_4, f4, this.f2687QxJ9d_1);
        }
    }

    public final void PGPF6hQ_2(Canvas canvas, int i) {
        if (this.f2688QxJ9d_1) {
            float strokeWidth = this.f3615IFxWkV_5 + (this.f2684PGPF6hQ_2.getStrokeWidth() * 2.0f);
            this.f2683PGPF6hQ_2 += this.f2689X6FRs_4 ? 3 : 10;
            int i2 = this.f2686QxJ9d_1 + (this.f2689X6FRs_4 ? 10 : 3);
            this.f2686QxJ9d_1 = i2;
            int i3 = this.f2683PGPF6hQ_2 % 360;
            this.f2683PGPF6hQ_2 = i3;
            int i4 = i2 % 360;
            this.f2686QxJ9d_1 = i4;
            int i5 = i4 - i3;
            if (i5 < 0) {
                i5 += 360;
            }
            float f = i / 2.0f;
            float f2 = this.f3617X6FRs_4;
            canvas.drawArc(new RectF(f - strokeWidth, f2 - strokeWidth, f + strokeWidth, f2 + strokeWidth), this.f2683PGPF6hQ_2, i5, false, this.f2684PGPF6hQ_2);
            if (i5 >= 270) {
                this.f2689X6FRs_4 = false;
            } else if (i5 <= 10) {
                this.f2689X6FRs_4 = true;
            }
            invalidate();
        }
    }

    public final void QxJ9d_1(Canvas canvas, int i) {
        int i2;
        if (this.f3616Mqv2r_3 > 0.0f) {
            int color = this.f2684PGPF6hQ_2.getColor();
            if (this.f3616Mqv2r_3 < 0.3d) {
                float f = i / 2.0f;
                canvas.drawCircle(f, this.f3617X6FRs_4, this.f3615IFxWkV_5, this.f2687QxJ9d_1);
                float f2 = this.f3615IFxWkV_5;
                float f3 = this.f3616Mqv2r_3;
                this.f2684PGPF6hQ_2.setColor(X6FRs_4.IMuAHx_6.IFxWkV_5.KQgRr5e_0.PGPF6hQ_2(color, (int) ((1.0f - (f3 / 0.3f)) * 255.0f)));
                float strokeWidth = (int) (f2 + (this.f2684PGPF6hQ_2.getStrokeWidth() * 2.0f * ((f3 / 0.3f) + 1.0f)));
                float f4 = this.f3617X6FRs_4;
                canvas.drawArc(new RectF(f - strokeWidth, f4 - strokeWidth, f + strokeWidth, f4 + strokeWidth), 0.0f, 360.0f, false, this.f2684PGPF6hQ_2);
            }
            this.f2684PGPF6hQ_2.setColor(color);
            float f5 = this.f3616Mqv2r_3;
            if (f5 >= 0.3d && f5 < 0.7d) {
                float f6 = (f5 - 0.3f) / 0.4f;
                float f7 = this.QxJ9d_1;
                float f8 = (int) ((f7 / 2.0f) + ((f7 - (f7 / 2.0f)) * f6));
                this.f3617X6FRs_4 = f8;
                canvas.drawCircle(i / 2.0f, f8, this.f3615IFxWkV_5, this.f2687QxJ9d_1);
                if (this.f3617X6FRs_4 >= this.QxJ9d_1 - (this.f3615IFxWkV_5 * 2.0f)) {
                    this.f2682Mqv2r_3 = true;
                    KQgRr5e_0(canvas, i, f6);
                }
                this.f2682Mqv2r_3 = false;
            }
            float f9 = this.f3616Mqv2r_3;
            if (f9 < 0.7d || f9 > 1.0f) {
                return;
            }
            float f10 = (f9 - 0.7f) / 0.3f;
            float f11 = i / 2.0f;
            float f12 = this.f3615IFxWkV_5;
            this.f2681KQgRr5e_0.reset();
            this.f2681KQgRr5e_0.moveTo((int) ((f11 - f12) - ((f12 * 2.0f) * f10)), this.QxJ9d_1);
            Path path = this.f2681KQgRr5e_0;
            float f13 = this.QxJ9d_1;
            path.quadTo(f11, f13 - (this.f3615IFxWkV_5 * (1.0f - f10)), i - i2, f13);
            canvas.drawPath(this.f2681KQgRr5e_0, this.f2687QxJ9d_1);
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    public void dispatchDraw(Canvas canvas) {
        int width = getWidth();
        int i = this.f2678KQgRr5e_0;
        Xgtqvk_8 xgtqvk_8 = this.f2679KQgRr5e_0;
        boolean z = xgtqvk_8 != null && equals(xgtqvk_8.m122KQgRr5e_0().getRefreshFooter());
        if (z) {
            canvas.save();
            canvas.translate(0.0f, getHeight());
            canvas.scale(1.0f, -1.0f);
        }
        if (isInEditMode()) {
            this.f2685PGPF6hQ_2 = true;
            this.f2688QxJ9d_1 = true;
            float f = i;
            this.QxJ9d_1 = f;
            this.f2686QxJ9d_1 = BottomAppBarTopEdgeTreatment.ANGLE_UP;
            this.f3617X6FRs_4 = f / 2.0f;
            this.f3615IFxWkV_5 = f / 6.0f;
        }
        KQgRr5e_0(canvas, width, i);
        Mqv2r_3(canvas, width);
        KQgRr5e_0(canvas, width);
        PGPF6hQ_2(canvas, width);
        QxJ9d_1(canvas, width);
        if (z) {
            canvas.restore();
        }
        super.dispatchDraw(canvas);
    }

    @Override // IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.FSaI4_7.QxJ9d_1, IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.X6FRs_4.FSaI4_7
    @Deprecated
    public void setPrimaryColors(int... iArr) {
        if (iArr.length > 0) {
            this.f2680KQgRr5e_0.setColor(iArr[0]);
            if (iArr.length > 1) {
                this.f2687QxJ9d_1.setColor(iArr[1]);
                this.f2684PGPF6hQ_2.setColor(iArr[1]);
            }
        }
    }

    public final void KQgRr5e_0(Canvas canvas, int i) {
        if (this.f2685PGPF6hQ_2) {
            canvas.drawCircle(i / 2.0f, this.f3617X6FRs_4, this.f3615IFxWkV_5, this.f2687QxJ9d_1);
            float f = this.QxJ9d_1;
            KQgRr5e_0(canvas, i, (this.KQgRr5e_0 + f) / f);
        }
    }

    public final void KQgRr5e_0(Canvas canvas, int i, float f) {
        float f2;
        if (this.f2682Mqv2r_3) {
            float f3 = this.QxJ9d_1 + this.KQgRr5e_0;
            float f4 = this.f3617X6FRs_4 + ((this.f3615IFxWkV_5 * f) / 2.0f);
            float f5 = i;
            float f6 = f5 / 2.0f;
            float sqrt = ((float) Math.sqrt(f2 * f2 * (1.0f - ((f * f) / 4.0f)))) + f6;
            float f7 = this.f3615IFxWkV_5;
            float f8 = f6 + (((3.0f * f7) / 4.0f) * (1.0f - f));
            float f9 = f7 + f8;
            this.f2681KQgRr5e_0.reset();
            this.f2681KQgRr5e_0.moveTo(sqrt, f4);
            this.f2681KQgRr5e_0.quadTo(f8, f3, f9, f3);
            this.f2681KQgRr5e_0.lineTo(f5 - f9, f3);
            this.f2681KQgRr5e_0.quadTo(f5 - f8, f3, f5 - sqrt, f4);
            canvas.drawPath(this.f2681KQgRr5e_0, this.f2687QxJ9d_1);
        }
    }

    @Override // IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.FSaI4_7.QxJ9d_1, IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.X6FRs_4.FSaI4_7
    public void QxJ9d_1(XnFJ5_9 xnFJ5_9, int i, int i2) {
        this.f2677IFxWkV_5 = false;
        float f = i;
        this.QxJ9d_1 = f;
        this.f3615IFxWkV_5 = f / 6.0f;
        DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator();
        float min = Math.min(this.KQgRr5e_0 * 0.8f, this.QxJ9d_1 / 2.0f);
        ValueAnimator ofFloat = ValueAnimator.ofFloat(this.KQgRr5e_0, 0.0f, -(1.0f * min), 0.0f, -(0.4f * min), 0.0f);
        ofFloat.addUpdateListener(new KQgRr5e_0(min));
        ofFloat.setInterpolator(decelerateInterpolator);
        ofFloat.setDuration(1000L);
        ofFloat.start();
    }

    @Override // IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.FSaI4_7.QxJ9d_1, IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.X6FRs_4.FSaI4_7
    public void KQgRr5e_0(Xgtqvk_8 xgtqvk_8, int i, int i2) {
        this.f2679KQgRr5e_0 = xgtqvk_8;
    }

    @Override // IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.FSaI4_7.QxJ9d_1, IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.X6FRs_4.FSaI4_7
    public void KQgRr5e_0(boolean z, float f, int i, int i2, int i3) {
        this.f2678KQgRr5e_0 = i;
        if (z || this.f2677IFxWkV_5) {
            this.f2677IFxWkV_5 = true;
            this.QxJ9d_1 = i2;
            this.KQgRr5e_0 = Math.max(i - i2, 0) * 0.8f;
        }
        invalidate();
    }

    @Override // IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.FSaI4_7.QxJ9d_1, IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.X6FRs_4.FSaI4_7
    public int KQgRr5e_0(XnFJ5_9 xnFJ5_9, boolean z) {
        this.f2685PGPF6hQ_2 = false;
        this.f2688QxJ9d_1 = false;
        ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
        ofFloat.addUpdateListener(new QxJ9d_1());
        ofFloat.setInterpolator(new AccelerateInterpolator());
        ofFloat.setDuration(800L);
        ofFloat.start();
        return 800;
    }
}
