package com.scwang.smartrefresh.header.waveswipe;

import android.animation.Animator;
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.Log;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.BounceInterpolator;
import ඓ.K.K.K.C1293;
import ඓ.㿎.K.K.䁗.C1457;
import ඓ.㿎.K.K.䁗.animation.InterpolatorC1458;
import ῲ.ᨨ.ᨨ.C1729;

public class WaveView extends View implements ViewTreeObserver.OnPreDrawListener {

    /* renamed from: ᓆ  reason: contains not printable characters */
    public static final float[][] f3198 = {new float[]{0.1655f, 0.0f}, new float[]{0.5237f, 0.0553f}, new float[]{0.4557f, 0.0936f}, new float[]{0.3908f, 0.1302f}, new float[]{0.4303f, 0.2173f}, new float[]{0.5f, 0.2173f}};

    /* renamed from: 㴪  reason: contains not printable characters */
    public static final float[][] f3199 = {new float[]{0.1655f, 0.0f}, new float[]{0.5909f, 0.0f}, new float[]{0.4557f, 0.1642f}, new float[]{0.3941f, 0.2061f}, new float[]{0.4303f, 0.2889f}, new float[]{0.5f, 0.2889f}};

    /* renamed from: 㶋  reason: contains not printable characters */
    public static final float[][] f3200 = {new float[]{0.1655f, 0.0f}, new float[]{0.4188f, -0.0109f}, new float[]{0.4606f, -0.0049f}, new float[]{0.4893f, 0.0f}, new float[]{0.4893f, 0.0f}, new float[]{0.5f, 0.0f}};

    /* renamed from: ʬ  reason: contains not printable characters */
    public Paint f3201;

    /* renamed from: Ԕ  reason: contains not printable characters */
    public int f3202;

    /* renamed from: Ԛ  reason: contains not printable characters */
    public ValueAnimator.AnimatorUpdateListener f3203 = new C1457(this);

    /* renamed from: ؿ  reason: contains not printable characters */
    public ValueAnimator f3204;

    /* renamed from: ݜ  reason: contains not printable characters */
    public ValueAnimator f3205;

    /* renamed from: ඓ  reason: contains not printable characters */
    public Path f3206;

    /* renamed from: ᓣ  reason: contains not printable characters */
    public ValueAnimator f3207;

    /* renamed from: ᕣ  reason: contains not printable characters */
    public int f3208;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public int f3209;

    /* renamed from: ῲ  reason: contains not printable characters */
    public float f3210 = 100.0f;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public Path f3211;

    /* renamed from: 㑃  reason: contains not printable characters */
    public boolean f3212 = false;

    /* renamed from: 㗗  reason: contains not printable characters */
    public ValueAnimator f3213;

    /* renamed from: 㗽  reason: contains not printable characters */
    public ValueAnimator f3214;

    /* renamed from: 㳳  reason: contains not printable characters */
    public float f3215;

    /* renamed from: 㴹  reason: contains not printable characters */
    public Path f3216;

    /* renamed from: 㸾  reason: contains not printable characters */
    public Path f3217;

    /* renamed from: 㿎  reason: contains not printable characters */
    public RectF f3218;

    /* renamed from: 䀟  reason: contains not printable characters */
    public ValueAnimator f3219;

    /* renamed from: 䁗  reason: contains not printable characters */
    public boolean f3220 = false;

    /* renamed from: com.scwang.smartrefresh.header.waveswipe.WaveView$ʬ  reason: contains not printable characters */
    public class C0556 implements ValueAnimator.AnimatorUpdateListener {
        public C0556() {
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            WaveView.this.f3217.moveTo(0.0f, 0.0f);
            WaveView waveView = WaveView.this;
            Path path = waveView.f3217;
            int i = waveView.f3209;
            float f = floatValue * 0.5f;
            path.quadTo(((float) i) * 0.25f, 0.0f, ((float) i) * 0.333f, f);
            WaveView waveView2 = WaveView.this;
            Path path2 = waveView2.f3217;
            int i2 = waveView2.f3209;
            path2.quadTo(((float) i2) * 0.5f, floatValue * 1.4f, ((float) i2) * 0.666f, f);
            WaveView waveView3 = WaveView.this;
            Path path3 = waveView3.f3217;
            int i3 = waveView3.f3209;
            path3.quadTo(((float) i3) * 0.75f, 0.0f, (float) i3, 0.0f);
            WaveView.this.postInvalidate();
        }
    }

    /* renamed from: com.scwang.smartrefresh.header.waveswipe.WaveView$ῲ  reason: contains not printable characters */
    public class C0557 implements Animator.AnimatorListener {
        public C0557() {
        }

        public void onAnimationCancel(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
            WaveView.this.m1821();
            WaveView.this.f3212 = false;
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
        }
    }

    /* renamed from: com.scwang.smartrefresh.header.waveswipe.WaveView$K  reason: contains not printable characters */
    public class C0558 implements ValueAnimator.AnimatorUpdateListener {
        public C0558() {
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            WaveView.this.f3215 = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            C1729.m4449(WaveView.this);
        }
    }

    public WaveView(Context context) {
        super(context);
        getViewTreeObserver().addOnPreDrawListener(this);
        float f = getResources().getDisplayMetrics().density;
        this.f3201 = new Paint();
        this.f3201.setColor(-14575885);
        this.f3201.setAntiAlias(true);
        this.f3201.setStyle(Paint.Style.FILL);
        this.f3201.setShadowLayer((float) ((int) ((f * 2.0f) + 0.5f)), 0.0f, 0.0f, -1728053248);
        this.f3217 = new Path();
        this.f3206 = new Path();
        this.f3216 = new Path();
        this.f3211 = new Path();
        m1821();
        this.f3218 = new RectF();
        setLayerType(1, null);
    }

    public float getCurrentCircleCenterY() {
        return this.f3215;
    }

    public void onDetachedFromWindow() {
        ValueAnimator valueAnimator = this.f3205;
        if (valueAnimator != null) {
            valueAnimator.end();
            this.f3205.removeAllUpdateListeners();
        }
        ValueAnimator valueAnimator2 = this.f3214;
        if (valueAnimator2 != null) {
            valueAnimator2.end();
            this.f3214.removeAllUpdateListeners();
        }
        ValueAnimator valueAnimator3 = this.f3213;
        if (valueAnimator3 != null) {
            valueAnimator3.end();
            this.f3213.removeAllUpdateListeners();
        }
        ValueAnimator valueAnimator4 = this.f3219;
        if (valueAnimator4 != null) {
            valueAnimator4.end();
            this.f3219.removeAllUpdateListeners();
        }
        ValueAnimator valueAnimator5 = this.f3207;
        if (valueAnimator5 != null) {
            valueAnimator5.end();
            this.f3207.removeAllUpdateListeners();
        }
        ValueAnimator valueAnimator6 = this.f3204;
        if (valueAnimator6 != null) {
            valueAnimator6.end();
            this.f3204.removeAllUpdateListeners();
        }
        super.onDetachedFromWindow();
    }

    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawPath(this.f3217, this.f3201);
        if (!isInEditMode()) {
            this.f3217.rewind();
            this.f3206.rewind();
            this.f3216.rewind();
        }
        float floatValue = ((Float) this.f3214.getAnimatedValue()).floatValue();
        float f = ((float) this.f3209) / 2.0f;
        this.f3218.setEmpty();
        float floatValue2 = ((Float) this.f3205.getAnimatedValue()).floatValue();
        float floatValue3 = ((Float) this.f3204.getAnimatedValue()).floatValue();
        float floatValue4 = ((Float) this.f3207.getAnimatedValue()).floatValue();
        RectF rectF = this.f3218;
        float f2 = this.f3210;
        float f3 = floatValue3 + 1.0f;
        float f4 = 1.0f + floatValue4;
        rectF.set(((f2 * floatValue4) / 2.0f) + (f - ((f2 * f3) * floatValue2)), (((f2 * f4) * floatValue2) + floatValue) - ((f2 * floatValue3) / 2.0f), (((f3 * f2) * floatValue2) + f) - ((floatValue4 * f2) / 2.0f), ((f2 * floatValue3) / 2.0f) + (floatValue - ((f4 * f2) * floatValue2)));
        float floatValue5 = ((Float) this.f3213.getAnimatedValue()).floatValue();
        this.f3206.moveTo(f, floatValue5);
        double d = (double) floatValue;
        double pow = ((Math.pow((double) this.f3210, 2.0d) + ((double) (floatValue * floatValue5))) - Math.pow(d, 2.0d)) / ((double) (floatValue5 - floatValue));
        double d2 = (((double) this.f3209) * -2.0d) / 2.0d;
        double pow2 = (Math.pow((double) f, 2.0d) + Math.pow(pow - d, 2.0d)) - Math.pow((double) this.f3210, 2.0d);
        double d3 = -d2;
        double d4 = (d2 * d2) - (pow2 * 4.0d);
        float f5 = (float) pow;
        this.f3206.lineTo((float) ((Math.sqrt(d4) + d3) / 2.0d), f5);
        this.f3206.lineTo((float) ((d3 - Math.sqrt(d4)) / 2.0d), f5);
        this.f3206.close();
        this.f3211.set(this.f3206);
        this.f3211.addOval(this.f3218, Path.Direction.CCW);
        this.f3216.addOval(this.f3218, Path.Direction.CCW);
        this.f3213.isRunning();
        canvas.drawPath(this.f3206, this.f3201);
        canvas.drawPath(this.f3216, this.f3201);
    }

    public boolean onPreDraw() {
        getViewTreeObserver().removeOnPreDrawListener(this);
        if (!this.f3220) {
            return false;
        }
        m1818(this.f3202);
        return false;
    }

    public void onSizeChanged(int i, int i2, int i3, int i4) {
        this.f3209 = i;
        this.f3210 = ((float) i) / 14.4f;
        m1818((int) Math.min((float) Math.min(i, i2), ((float) getHeight()) - this.f3210));
        super.onSizeChanged(i, i2, i3, i4);
    }

    public void setMaxDropHeight(int i) {
        if (this.f3220) {
            m1818(i);
            return;
        }
        this.f3202 = i;
        this.f3220 = true;
        if (getViewTreeObserver().isAlive()) {
            getViewTreeObserver().removeOnPreDrawListener(this);
            getViewTreeObserver().addOnPreDrawListener(this);
        }
    }

    public void setShadowRadius(int i) {
        this.f3201.setShadowLayer((float) i, 0.0f, 0.0f, -1728053248);
    }

    public void setWaveColor(int i) {
        this.f3201.setColor(i);
        invalidate();
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public final void m1810() {
        ValueAnimator valueAnimator = this.f3219;
        if (valueAnimator != null && valueAnimator.isRunning()) {
            this.f3219.cancel();
        }
    }

    /* renamed from: ඓ  reason: contains not printable characters */
    public void m1811() {
        this.f3205 = ValueAnimator.ofFloat(1.0f, 0.0f);
        this.f3205.addUpdateListener(this.f3203);
        this.f3205.setDuration(200L);
        this.f3205.addListener(new C0557());
        this.f3205.start();
    }

    /* renamed from: 㴹  reason: contains not printable characters */
    public void m1820() {
        this.f3205 = ValueAnimator.ofFloat(1.0f, 1.0f);
        this.f3205.setDuration(1L);
        this.f3205.start();
        this.f3214 = ValueAnimator.ofFloat((((float) this.f3209) / 1440.0f) * 500.0f, (float) this.f3208);
        this.f3214.setDuration(500L);
        this.f3214.addUpdateListener(new C0558());
        this.f3214.setInterpolator(new AccelerateDecelerateInterpolator());
        this.f3214.start();
        this.f3213 = ValueAnimator.ofFloat(0.0f, ((float) this.f3208) - this.f3210);
        this.f3213.setDuration(500L);
        this.f3213.addUpdateListener(this.f3203);
        this.f3213.start();
        this.f3204 = ValueAnimator.ofFloat(0.0f, 1.0f);
        this.f3204.setDuration(500L);
        this.f3204.addUpdateListener(this.f3203);
        this.f3204.setInterpolator(new animation.InterpolatorC1458());
        this.f3204.setStartDelay(500);
        this.f3204.start();
        this.f3207 = ValueAnimator.ofFloat(0.0f, 1.0f);
        this.f3207.setDuration(500L);
        this.f3207.addUpdateListener(this.f3203);
        this.f3207.setInterpolator(new animation.InterpolatorC1458());
        this.f3207.setStartDelay(625);
        this.f3207.start();
    }

    /* renamed from: 㸾  reason: contains not printable characters */
    public final void m1821() {
        this.f3213 = ValueAnimator.ofFloat(0.0f, 0.0f);
        this.f3204 = ValueAnimator.ofFloat(0.0f, 0.0f);
        this.f3207 = ValueAnimator.ofFloat(0.0f, 0.0f);
        this.f3214 = ValueAnimator.ofFloat(-1000.0f, -1000.0f);
        this.f3214.start();
        this.f3205 = ValueAnimator.ofFloat(1.0f, 1.0f);
        this.f3205.setDuration(1L);
        this.f3205.start();
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public void m1812() {
        if (!this.f3212) {
            this.f3212 = true;
            int i = this.f3208;
            this.f3214 = ValueAnimator.ofFloat((float) i, (float) i);
            this.f3214.start();
            int i2 = this.f3208;
            float f = this.f3210;
            this.f3213 = ValueAnimator.ofFloat(((float) i2) - f, ((float) i2) - f);
            this.f3213.start();
            this.f3215 = (float) this.f3208;
            postInvalidate();
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1815(float f) {
        m1810();
        this.f3217.moveTo(0.0f, 0.0f);
        Path path = this.f3217;
        int i = this.f3209;
        float[][] fArr = f3200;
        path.cubicTo(((float) i) * fArr[0][0], fArr[0][1], ((float) i) * fArr[1][0], ((float) i) * (fArr[1][1] + f), ((float) i) * fArr[2][0], (fArr[2][1] + f) * ((float) i));
        Path path2 = this.f3217;
        int i2 = this.f3209;
        float[][] fArr2 = f3200;
        path2.cubicTo(((float) i2) * fArr2[3][0], (fArr2[3][1] + f) * ((float) i2), ((float) i2) * fArr2[4][0], (fArr2[4][1] + f) * ((float) i2), ((float) i2) * fArr2[5][0], (fArr2[5][1] + f) * ((float) i2));
        Path path3 = this.f3217;
        int i3 = this.f3209;
        float[][] fArr3 = f3200;
        path3.cubicTo(((float) i3) - (((float) i3) * fArr3[4][0]), (fArr3[4][1] + f) * ((float) i3), ((float) i3) - (((float) i3) * fArr3[3][0]), (fArr3[3][1] + f) * ((float) i3), ((float) i3) - (((float) i3) * fArr3[2][0]), (fArr3[2][1] + f) * ((float) i3));
        Path path4 = this.f3217;
        int i4 = this.f3209;
        float[][] fArr4 = f3200;
        path4.cubicTo(((float) i4) - (((float) i4) * fArr4[1][0]), ((float) i4) * (fArr4[1][1] + f), ((float) i4) - (((float) i4) * fArr4[0][0]), fArr4[0][1], (float) i4, 0.0f);
        C1729.m4449(this);
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1816(float f, float f2) {
        m1810();
        this.f3217.moveTo(0.0f, 0.0f);
        Path path = this.f3217;
        int i = this.f3209;
        float[][] fArr = f3198;
        path.cubicTo(((float) i) * fArr[0][0], ((float) i) * fArr[0][1], Math.min(f3200[1][0] + f2, fArr[1][0]) * ((float) i), Math.max((f3200[1][1] + f) - f2, f3198[1][1]) * ((float) this.f3209), Math.max(f3200[2][0] - f2, f3198[2][0]) * ((float) this.f3209), Math.max((f3200[2][1] + f) - f2, f3198[2][1]) * ((float) this.f3209));
        Path path2 = this.f3217;
        float max = Math.max(f3200[3][0] - f2, f3198[3][0]) * ((float) this.f3209);
        float min = Math.min(f3200[3][1] + f + f2, f3198[3][1]) * ((float) this.f3209);
        float max2 = Math.max(f3200[4][0] - f2, f3198[4][0]) * ((float) this.f3209);
        float min2 = Math.min(f3200[4][1] + f + f2, f3198[4][1]) * ((float) this.f3209);
        int i2 = this.f3209;
        float[][] fArr2 = f3198;
        path2.cubicTo(max, min, max2, min2, ((float) i2) * fArr2[5][0], Math.min(f3200[0][1] + f + f2, fArr2[5][1]) * ((float) i2));
        Path path3 = this.f3217;
        int i3 = this.f3209;
        float max3 = ((float) i3) - (Math.max(f3200[4][0] - f2, f3198[4][0]) * ((float) i3));
        float min3 = Math.min(f3200[4][1] + f + f2, f3198[4][1]) * ((float) this.f3209);
        int i4 = this.f3209;
        float max4 = ((float) i4) - (Math.max(f3200[3][0] - f2, f3198[3][0]) * ((float) i4));
        float min4 = Math.min(f3200[3][1] + f + f2, f3198[3][1]) * ((float) this.f3209);
        int i5 = this.f3209;
        path3.cubicTo(max3, min3, max4, min4, ((float) i5) - (Math.max(f3200[2][0] - f2, f3198[2][0]) * ((float) i5)), Math.max((f3200[2][1] + f) - f2, f3198[2][1]) * ((float) this.f3209));
        Path path4 = this.f3217;
        int i6 = this.f3209;
        float min5 = ((float) i6) - (Math.min(f3200[1][0] + f2, f3198[1][0]) * ((float) i6));
        float max5 = Math.max((f3200[1][1] + f) - f2, f3198[1][1]) * ((float) this.f3209);
        int i7 = this.f3209;
        float[][] fArr3 = f3198;
        path4.cubicTo(min5, max5, ((float) i7) - (((float) i7) * fArr3[0][0]), ((float) i7) * fArr3[0][1], (float) i7, 0.0f);
        this.f3215 = (Math.min(f3200[3][1] + f + f2, f3198[3][1]) * ((float) this.f3209)) + this.f3210;
        C1729.m4449(this);
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public void m1813(float f) {
        this.f3219 = ValueAnimator.ofFloat(Math.min(f, 0.2f) * ((float) this.f3209), 0.0f);
        this.f3219.setDuration(1000L);
        this.f3219.addUpdateListener(new C0556());
        this.f3219.setInterpolator(new BounceInterpolator());
        this.f3219.start();
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1817(float f, float f2, float f3) {
        m1810();
        this.f3217.moveTo(0.0f, 0.0f);
        Path path = this.f3217;
        int i = this.f3209;
        float[][] fArr = f3199;
        path.cubicTo(((float) i) * fArr[0][0], ((float) i) * fArr[0][1], Math.min(Math.min(f3200[1][0] + f2, f3198[1][0]) + f3, f3199[1][0]) * ((float) i), Math.max(Math.max((f3200[1][1] + f) - f2, f3198[1][1]) - f3, f3199[1][1]) * ((float) this.f3209), Math.max(f3200[2][0] - f2, f3199[2][0]) * ((float) this.f3209), Math.min(Math.max((f3200[2][1] + f) - f2, f3198[2][1]) + f3, f3199[2][1]) * ((float) this.f3209));
        Path path2 = this.f3217;
        float min = Math.min(Math.max(f3200[3][0] - f2, f3198[3][0]) + f3, f3199[3][0]) * ((float) this.f3209);
        float min2 = Math.min(Math.min(f3200[3][1] + f + f2, f3198[3][1]) + f3, f3199[3][1]) * ((float) this.f3209);
        float max = Math.max(f3200[4][0] - f2, f3199[4][0]) * ((float) this.f3209);
        float min3 = Math.min(Math.min(f3200[4][1] + f + f2, f3198[4][1]) + f3, f3199[4][1]) * ((float) this.f3209);
        int i2 = this.f3209;
        path2.cubicTo(min, min2, max, min3, ((float) i2) * f3199[5][0], Math.min(Math.min(f3200[0][1] + f + f2, f3198[5][1]) + f3, f3199[5][1]) * ((float) i2));
        Path path3 = this.f3217;
        int i3 = this.f3209;
        float max2 = ((float) i3) - (Math.max(f3200[4][0] - f2, f3199[4][0]) * ((float) i3));
        float min4 = Math.min(Math.min(f3200[4][1] + f + f2, f3198[4][1]) + f3, f3199[4][1]) * ((float) this.f3209);
        int i4 = this.f3209;
        float min5 = ((float) i4) - (Math.min(Math.max(f3200[3][0] - f2, f3198[3][0]) + f3, f3199[3][0]) * ((float) i4));
        float min6 = Math.min(Math.min(f3200[3][1] + f + f2, f3198[3][1]) + f3, f3199[3][1]) * ((float) this.f3209);
        int i5 = this.f3209;
        path3.cubicTo(max2, min4, min5, min6, ((float) i5) - (Math.max(f3200[2][0] - f2, f3199[2][0]) * ((float) i5)), Math.min(Math.max((f3200[2][1] + f) - f2, f3198[2][1]) + f3, f3199[2][1]) * ((float) this.f3209));
        Path path4 = this.f3217;
        int i6 = this.f3209;
        float min7 = ((float) i6) - (Math.min(Math.min(f3200[1][0] + f2, f3198[1][0]) + f3, f3199[1][0]) * ((float) i6));
        float max3 = Math.max(Math.max((f3200[1][1] + f) - f2, f3198[1][1]) - f3, f3199[1][1]) * ((float) this.f3209);
        int i7 = this.f3209;
        float[][] fArr2 = f3199;
        path4.cubicTo(min7, max3, ((float) i7) - (((float) i7) * fArr2[0][0]), ((float) i7) * fArr2[0][1], (float) i7, 0.0f);
        this.f3215 = (Math.min(Math.min(f3200[3][1] + f + f2, f3198[3][1]) + f3, f3199[3][1]) * ((float) this.f3209)) + this.f3210;
        C1729.m4449(this);
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m1818(int i) {
        float f = (float) i;
        if ((((float) this.f3209) / 1440.0f) * 500.0f > f) {
            StringBuilder r4 = C1293.m3416("DropHeight is more than ");
            r4.append((((float) this.f3209) / 1440.0f) * 500.0f);
            Log.w("WaveView", r4.toString());
            return;
        }
        this.f3208 = (int) Math.min(f, ((float) getHeight()) - this.f3210);
        if (this.f3212) {
            this.f3212 = false;
            m1812();
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1814() {
        if (!this.f3205.isRunning()) {
            m1820();
            m1813(0.1f);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1819(int i, int i2) {
        this.f3201.setShadowLayer((float) i, 0.0f, 0.0f, i2);
    }
}
