package com.scwang.smartrefresh.layout.header;

import IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.IFxWkV_5.PGPF6hQ_2;
import IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.Mqv2r_3;
import IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.X6FRs_4.IMuAHx_6;
import IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.X6FRs_4.XnFJ5_9;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.animation.AccelerateDecelerateInterpolator;
import com.google.android.material.bottomappbar.BottomAppBarTopEdgeTreatment;
/* loaded from: classes.dex */
public class BezierRadarHeader 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 f3690IFxWkV_5;

    /* renamed from: IFxWkV_5  reason: collision with other field name */
    public int f2914IFxWkV_5;

    /* renamed from: IMuAHx_6  reason: collision with root package name */
    public float f3691IMuAHx_6;

    /* renamed from: IMuAHx_6  reason: collision with other field name */
    public int f2915IMuAHx_6;
    public float KQgRr5e_0;

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

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public Animator f2917KQgRr5e_0;

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

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

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public RectF f2920KQgRr5e_0;

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

    /* renamed from: Mqv2r_3  reason: collision with other field name */
    public int f2921Mqv2r_3;

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

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

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

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

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

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

    /* renamed from: X6FRs_4  reason: collision with other field name */
    public int f2927X6FRs_4;

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

    /* loaded from: classes.dex */
    public static /* synthetic */ class KQgRr5e_0 {
        public static final /* synthetic */ int[] KQgRr5e_0;

        static {
            int[] iArr = new int[IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.IFxWkV_5.QxJ9d_1.values().length];
            KQgRr5e_0 = iArr;
            try {
                iArr[IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.IFxWkV_5.QxJ9d_1.None.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                KQgRr5e_0[IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.IFxWkV_5.QxJ9d_1.PullDownToRefresh.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
        }
    }

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

        public QxJ9d_1(byte b) {
            this.KQgRr5e_0 = b;
        }

        @Override // android.animation.ValueAnimator.AnimatorUpdateListener
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            byte b = this.KQgRr5e_0;
            if (b == 0) {
                BezierRadarHeader.this.f3691IMuAHx_6 = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            } else if (1 == b) {
                BezierRadarHeader bezierRadarHeader = BezierRadarHeader.this;
                if (bezierRadarHeader.f2922Mqv2r_3) {
                    valueAnimator.cancel();
                    return;
                }
                bezierRadarHeader.f2921Mqv2r_3 = ((Integer) valueAnimator.getAnimatedValue()).intValue() / 2;
            } else if (2 == b) {
                BezierRadarHeader.this.KQgRr5e_0 = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            } else if (3 == b) {
                BezierRadarHeader.this.f3692Mqv2r_3 = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            } else if (4 == b) {
                BezierRadarHeader.this.f2915IMuAHx_6 = ((Integer) valueAnimator.getAnimatedValue()).intValue();
            }
            BezierRadarHeader.this.invalidate();
        }
    }

    public BezierRadarHeader(Context context) {
        this(context, null);
    }

    public void KQgRr5e_0(Canvas canvas, int i) {
        int i2;
        this.f2919KQgRr5e_0.reset();
        this.f2919KQgRr5e_0.lineTo(0.0f, this.f2923PGPF6hQ_2);
        Path path = this.f2919KQgRr5e_0;
        int i3 = this.f2927X6FRs_4;
        float f = i3 >= 0 ? i3 : i / 2.0f;
        float f2 = i;
        path.quadTo(f, this.f2921Mqv2r_3 + i2, f2, this.f2923PGPF6hQ_2);
        this.f2919KQgRr5e_0.lineTo(f2, 0.0f);
        this.f2918KQgRr5e_0.setColor(this.f2925QxJ9d_1);
        canvas.drawPath(this.f2919KQgRr5e_0, this.f2918KQgRr5e_0);
    }

    public void PGPF6hQ_2(Canvas canvas, int i, int i2) {
        if (this.f3692Mqv2r_3 > 0.0f) {
            this.f2918KQgRr5e_0.setColor(this.f2916KQgRr5e_0);
            canvas.drawCircle(i / 2.0f, i2 / 2.0f, this.f3692Mqv2r_3, this.f2918KQgRr5e_0);
        }
    }

    public void QxJ9d_1(Canvas canvas, int i, int i2) {
        if (this.f2917KQgRr5e_0 != null || isInEditMode()) {
            float f = this.f3693X6FRs_4;
            float f2 = this.f3691IMuAHx_6;
            float f3 = f * f2;
            float f4 = this.f3690IFxWkV_5 * f2;
            this.f2918KQgRr5e_0.setColor(this.f2916KQgRr5e_0);
            this.f2918KQgRr5e_0.setStyle(Paint.Style.FILL);
            float f5 = i / 2.0f;
            float f6 = i2 / 2.0f;
            canvas.drawCircle(f5, f6, f3, this.f2918KQgRr5e_0);
            this.f2918KQgRr5e_0.setStyle(Paint.Style.STROKE);
            float f7 = f4 + f3;
            canvas.drawCircle(f5, f6, f7, this.f2918KQgRr5e_0);
            this.f2918KQgRr5e_0.setColor((this.f2925QxJ9d_1 & 16777215) | 1426063360);
            this.f2918KQgRr5e_0.setStyle(Paint.Style.FILL);
            this.f2920KQgRr5e_0.set(f5 - f3, f6 - f3, f5 + f3, f3 + f6);
            canvas.drawArc(this.f2920KQgRr5e_0, 270.0f, this.f2915IMuAHx_6, true, this.f2918KQgRr5e_0);
            this.f2918KQgRr5e_0.setStyle(Paint.Style.STROKE);
            this.f2920KQgRr5e_0.set(f5 - f7, f6 - f7, f5 + f7, f6 + f7);
            canvas.drawArc(this.f2920KQgRr5e_0, 270.0f, this.f2915IMuAHx_6, false, this.f2918KQgRr5e_0);
            this.f2918KQgRr5e_0.setStyle(Paint.Style.FILL);
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    public void dispatchDraw(Canvas canvas) {
        int width = getWidth();
        int height = isInEditMode() ? getHeight() : this.f2914IFxWkV_5;
        KQgRr5e_0(canvas, width);
        KQgRr5e_0(canvas, width, height);
        QxJ9d_1(canvas, width, height);
        PGPF6hQ_2(canvas, width, height);
        super.dispatchDraw(canvas);
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        Animator animator = this.f2917KQgRr5e_0;
        if (animator != null) {
            animator.removeAllListeners();
            this.f2917KQgRr5e_0.end();
            this.f2917KQgRr5e_0 = null;
        }
    }

    @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.f2926QxJ9d_1) {
            QxJ9d_1(iArr[0]);
            this.f2926QxJ9d_1 = false;
        }
        if (iArr.length <= 1 || this.f2924PGPF6hQ_2) {
            return;
        }
        KQgRr5e_0(iArr[1]);
        this.f2924PGPF6hQ_2 = false;
    }

    public BezierRadarHeader(Context context, AttributeSet attributeSet) {
        super(context, attributeSet, 0);
        this.f2928X6FRs_4 = false;
        this.f2927X6FRs_4 = -1;
        this.f2914IFxWkV_5 = 0;
        this.f2915IMuAHx_6 = 0;
        this.f3693X6FRs_4 = 0.0f;
        this.f3690IFxWkV_5 = 0.0f;
        this.f3691IMuAHx_6 = 0.0f;
        this.f2920KQgRr5e_0 = new RectF(0.0f, 0.0f, 0.0f, 0.0f);
        ((IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.FSaI4_7.QxJ9d_1) this).KQgRr5e_0 = PGPF6hQ_2.PGPF6hQ_2;
        this.f2919KQgRr5e_0 = new Path();
        Paint paint = new Paint();
        this.f2918KQgRr5e_0 = paint;
        paint.setAntiAlias(true);
        this.PGPF6hQ_2 = IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.XnFJ5_9.QxJ9d_1.m124KQgRr5e_0(7.0f);
        this.f3693X6FRs_4 = IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.XnFJ5_9.QxJ9d_1.m124KQgRr5e_0(20.0f);
        this.f3690IFxWkV_5 = IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.XnFJ5_9.QxJ9d_1.m124KQgRr5e_0(7.0f);
        this.f2918KQgRr5e_0.setStrokeWidth(IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.XnFJ5_9.QxJ9d_1.m124KQgRr5e_0(3.0f));
        setMinimumHeight(IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.XnFJ5_9.QxJ9d_1.m124KQgRr5e_0(100.0f));
        if (isInEditMode()) {
            this.f2923PGPF6hQ_2 = 1000;
            this.f3691IMuAHx_6 = 1.0f;
            this.f2915IMuAHx_6 = BottomAppBarTopEdgeTreatment.ANGLE_UP;
        } else {
            this.f3691IMuAHx_6 = 0.0f;
        }
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, Mqv2r_3.BezierRadarHeader);
        this.f2928X6FRs_4 = obtainStyledAttributes.getBoolean(Mqv2r_3.BezierRadarHeader_srlEnableHorizontalDrag, this.f2928X6FRs_4);
        KQgRr5e_0(obtainStyledAttributes.getColor(Mqv2r_3.BezierRadarHeader_srlAccentColor, -1));
        QxJ9d_1(obtainStyledAttributes.getColor(Mqv2r_3.BezierRadarHeader_srlPrimaryColor, -14540254));
        this.f2924PGPF6hQ_2 = obtainStyledAttributes.hasValue(Mqv2r_3.BezierRadarHeader_srlAccentColor);
        this.f2926QxJ9d_1 = obtainStyledAttributes.hasValue(Mqv2r_3.BezierRadarHeader_srlPrimaryColor);
        obtainStyledAttributes.recycle();
    }

    public void KQgRr5e_0(Canvas canvas, int i, int i2) {
        if (this.KQgRr5e_0 > 0.0f) {
            this.f2918KQgRr5e_0.setColor(this.f2916KQgRr5e_0);
            float KQgRr5e_02 = IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.XnFJ5_9.QxJ9d_1.KQgRr5e_0(i2);
            float f = i;
            float f2 = 7.0f;
            float f3 = (f * 1.0f) / 7.0f;
            float f4 = this.QxJ9d_1;
            float f5 = (f3 * f4) - (f4 > 1.0f ? ((f4 - 1.0f) * f3) / f4 : 0.0f);
            float f6 = i2;
            float f7 = this.QxJ9d_1;
            float f8 = f6 - (f7 > 1.0f ? (((f7 - 1.0f) * f6) / 2.0f) / f7 : 0.0f);
            int i3 = 0;
            while (i3 < 7) {
                float f9 = (i3 + 1.0f) - 4.0f;
                Paint paint = this.f2918KQgRr5e_0;
                double abs = this.KQgRr5e_0 * (1.0f - ((Math.abs(f9) / f2) * 2.0f)) * 255.0f;
                double d = KQgRr5e_02;
                Double.isNaN(d);
                Double.isNaN(abs);
                paint.setAlpha((int) (abs * (1.0d - (1.0d / Math.pow((d / 800.0d) + 1.0d, 15.0d)))));
                float f10 = this.PGPF6hQ_2 * (1.0f - (1.0f / ((KQgRr5e_02 / 10.0f) + 1.0f)));
                canvas.drawCircle(((f / 2.0f) - (f10 / 2.0f)) + (f5 * f9), f8 / 2.0f, f10, this.f2918KQgRr5e_0);
                i3++;
                f2 = 7.0f;
            }
            this.f2918KQgRr5e_0.setAlpha(255);
        }
    }

    @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.f2914IFxWkV_5 = i;
        if (z || this.f2922Mqv2r_3) {
            this.f2922Mqv2r_3 = true;
            this.f2923PGPF6hQ_2 = Math.min(i2, i);
            this.f2921Mqv2r_3 = (int) (Math.max(0, i - i2) * 1.9f);
            this.QxJ9d_1 = f;
            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 void QxJ9d_1(XnFJ5_9 xnFJ5_9, int i, int i2) {
        this.f2923PGPF6hQ_2 = i - 1;
        this.f2922Mqv2r_3 = false;
        IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.XnFJ5_9.QxJ9d_1 qxJ9d_1 = new IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.XnFJ5_9.QxJ9d_1(IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.XnFJ5_9.QxJ9d_1.f278PGPF6hQ_2);
        ValueAnimator ofFloat = ValueAnimator.ofFloat(1.0f, 0.0f);
        ofFloat.setInterpolator(qxJ9d_1);
        ofFloat.addUpdateListener(new QxJ9d_1((byte) 2));
        ValueAnimator ofFloat2 = ValueAnimator.ofFloat(0.0f, 1.0f);
        ofFloat.setInterpolator(qxJ9d_1);
        ofFloat2.addUpdateListener(new QxJ9d_1((byte) 0));
        ValueAnimator ofInt = ValueAnimator.ofInt(0, 360);
        ofInt.setDuration(720L);
        ofInt.setRepeatCount(-1);
        ofInt.setInterpolator(new AccelerateDecelerateInterpolator());
        ofInt.addUpdateListener(new QxJ9d_1((byte) 4));
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playSequentially(ofFloat, ofFloat2, ofInt);
        animatorSet.start();
        int i3 = this.f2921Mqv2r_3;
        ValueAnimator ofInt2 = ValueAnimator.ofInt(i3, 0, -((int) (i3 * 0.8f)), 0, -((int) (i3 * 0.4f)), 0);
        ofInt2.addUpdateListener(new QxJ9d_1((byte) 1));
        ofInt2.setInterpolator(new IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.XnFJ5_9.QxJ9d_1(IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.XnFJ5_9.QxJ9d_1.f278PGPF6hQ_2));
        ofInt2.setDuration(800L);
        ofInt2.start();
        this.f2917KQgRr5e_0 = animatorSet;
    }

    @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) {
        Animator animator = this.f2917KQgRr5e_0;
        if (animator != null) {
            animator.removeAllListeners();
            this.f2917KQgRr5e_0.end();
            this.f2917KQgRr5e_0 = null;
        }
        int width = getWidth();
        int i = this.f2914IFxWkV_5;
        ValueAnimator ofFloat = ValueAnimator.ofFloat(this.f3693X6FRs_4, (float) Math.sqrt((width * width) + (i * i)));
        ofFloat.setDuration(400L);
        ofFloat.addUpdateListener(new QxJ9d_1((byte) 3));
        ofFloat.start();
        return 400;
    }

    @Override // IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.FSaI4_7.QxJ9d_1, IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.Xgtqvk_8.IFxWkV_5
    public void KQgRr5e_0(XnFJ5_9 xnFJ5_9, IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.IFxWkV_5.QxJ9d_1 qxJ9d_1, IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.IFxWkV_5.QxJ9d_1 qxJ9d_12) {
        int i = KQgRr5e_0.KQgRr5e_0[qxJ9d_12.ordinal()];
        if (i == 1 || i == 2) {
            this.KQgRr5e_0 = 1.0f;
            this.f3691IMuAHx_6 = 0.0f;
            this.f3692Mqv2r_3 = 0.0f;
        }
    }

    @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 boolean KQgRr5e_0() {
        return this.f2928X6FRs_4;
    }

    @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(float f, int i, int i2) {
        this.f2927X6FRs_4 = i;
        invalidate();
    }

    public BezierRadarHeader QxJ9d_1(int i) {
        this.f2925QxJ9d_1 = i;
        this.f2926QxJ9d_1 = true;
        return this;
    }

    public BezierRadarHeader KQgRr5e_0(int i) {
        this.f2916KQgRr5e_0 = i;
        this.f2924PGPF6hQ_2 = true;
        return this;
    }
}
