package com.scwang.smartrefresh.header;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import com.scwang.smartrefresh.header.flyrefresh.FlyView;
import com.scwang.smartrefresh.header.flyrefresh.MountanScenceView;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.header.FalsifyHeader;
import ඓ.㿎.K.ῲ.Ԕ.AbstractC1391;
import ඓ.㿎.K.ῲ.Ԕ.AbstractC1393;
import ඓ.㿎.K.ῲ.Ԕ.AbstractC1396;
import ඓ.㿎.K.ῲ.Ԕ.AbstractC1401;
import ඓ.㿎.K.ῲ.ᓣ.AbstractC1418;
import ඓ.㿎.K.ῲ.䀟.C1436;
import ඓ.㿎.K.K.C1439;
import K.K.K.ʬ.C2369;

public class FlyRefreshHeader extends FalsifyHeader implements AbstractC1391 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public AnimatorSet f2999;

    /* renamed from: ඓ  reason: contains not printable characters */
    public AbstractC1401 f3000;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public int f3001 = 0;

    /* renamed from: ῲ  reason: contains not printable characters */
    public FlyView f3002;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public float f3003;

    /* renamed from: 㴹  reason: contains not printable characters */
    public AbstractC1396 f3004;

    /* renamed from: 㸾  reason: contains not printable characters */
    public MountanScenceView f3005;

    /* renamed from: 㿎  reason: contains not printable characters */
    public boolean f3006 = false;

    /* renamed from: com.scwang.smartrefresh.header.FlyRefreshHeader$ʬ  reason: contains not printable characters */
    public class C0544 extends AnimatorListenerAdapter {

        /* renamed from: K  reason: contains not printable characters */
        public final /* synthetic */ AnimatorListenerAdapter f3008;

        public C0544(AnimatorListenerAdapter animatorListenerAdapter) {
            this.f3008 = animatorListenerAdapter;
        }

        public void onAnimationEnd(Animator animator) {
            super.onAnimationEnd(animator);
            FlyRefreshHeader.this.f3000.m3610(true);
            AnimatorListenerAdapter animatorListenerAdapter = this.f3008;
            if (animatorListenerAdapter != null) {
                animatorListenerAdapter.onAnimationEnd(animator);
            }
        }

        public void onAnimationStart(Animator animator) {
            FlyRefreshHeader.this.f3002.setRotationY(0.0f);
        }
    }

    /* renamed from: com.scwang.smartrefresh.header.FlyRefreshHeader$ῲ  reason: contains not printable characters */
    public class C0545 extends AnimatorListenerAdapter {
        public C0545() {
        }

        public void onAnimationStart(Animator animator) {
            FlyRefreshHeader.this.f3002.setRotationY(180.0f);
        }
    }

    /* renamed from: com.scwang.smartrefresh.header.FlyRefreshHeader$K  reason: contains not printable characters */
    public class C0546 extends AbstractC1418 {
        public C0546() {
        }

        @Override // ඓ.㿎.K.ῲ.Ԕ.AbstractC1392
        /* renamed from: K  reason: contains not printable characters */
        public void m1700(AbstractC1393.AbstractC1394 k, AbstractC1401 r3) {
            FlyRefreshHeader flyRefreshHeader = FlyRefreshHeader.this;
            if (flyRefreshHeader.f3006) {
                flyRefreshHeader.m1697((AnimatorListenerAdapter) null);
            } else {
                k.m3603(new Object[0]);
            }
        }
    }

    public FlyRefreshHeader(Context context) {
        super(context);
    }

    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        this.f3000 = null;
        this.f3004 = null;
    }

    @Override // com.scwang.smartrefresh.layout.header.FalsifyHeader, ඓ.㿎.K.ῲ.Ԕ.AbstractC1399
    public void setPrimaryColors(int... iArr) {
        MountanScenceView mountanScenceView;
        if (iArr.length > 0 && (mountanScenceView = this.f3005) != null) {
            mountanScenceView.setPrimaryColor(iArr[0]);
        }
    }

    public void setUpFlyView(FlyView flyView) {
        this.f3002 = flyView;
    }

    public void setUpMountanScenceView(MountanScenceView mountanScenceView) {
        this.f3005 = mountanScenceView;
    }

    @Override // com.scwang.smartrefresh.layout.header.FalsifyHeader, ඓ.㿎.K.ῲ.Ԕ.AbstractC1391
    /* renamed from: ῲ  reason: contains not printable characters */
    public void m1695(float f, int i, int i2, int i3) {
        if (!this.f3006) {
            m1696(f, i, i2, i3);
        }
    }

    @Override // com.scwang.smartrefresh.layout.header.FalsifyHeader, ඓ.㿎.K.ῲ.Ԕ.AbstractC1391
    /* renamed from: K  reason: contains not printable characters */
    public void m1696(float f, int i, int i2, int i3) {
        if (i < 0) {
            if (this.f3001 > 0) {
                i = 0;
                f = 0.0f;
            } else {
                return;
            }
        }
        this.f3001 = i;
        this.f3003 = f;
        MountanScenceView mountanScenceView = this.f3005;
        if (mountanScenceView != null) {
            mountanScenceView.m1767(f);
            this.f3005.postInvalidate();
        }
        FlyView flyView = this.f3002;
        if (flyView != null) {
            int i4 = i2 + i3;
            if (i4 > 0) {
                flyView.setRotation((((float) i) * -45.0f) / ((float) i4));
            } else {
                flyView.setRotation(f * -45.0f);
            }
        }
    }

    public FlyRefreshHeader(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public FlyRefreshHeader(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }

    @Override // com.scwang.smartrefresh.layout.header.FalsifyHeader, ඓ.㿎.K.ῲ.Ԕ.AbstractC1399
    /* renamed from: K  reason: contains not printable characters */
    public void m1699(AbstractC1401 r9, int i, int i2) {
        SmartRefreshLayout.this.m1830(0);
        float f = this.f3003;
        if (f > 0.0f) {
            ValueAnimator ofFloat = ValueAnimator.ofFloat(f, 0.0f);
            ofFloat.setDuration(300L);
            ofFloat.addUpdateListener(new C1439(this));
            ofFloat.start();
            this.f3003 = 0.0f;
        }
        if (this.f3002 != null && !this.f3006) {
            AnimatorSet animatorSet = this.f2999;
            if (animatorSet != null) {
                animatorSet.end();
                this.f3002.clearAnimation();
            }
            this.f3006 = true;
            r9.m3610(false);
            int width = ((View) this.f3000).getWidth() - this.f3002.getLeft();
            ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(this.f3002, "translationX", 0.0f, (float) width);
            ObjectAnimator ofFloat3 = ObjectAnimator.ofFloat(this.f3002, "translationY", 0.0f, (float) (((-(this.f3002.getTop() - this.f3001)) * 2) / 3));
            ofFloat3.setInterpolator(C2369.m6309(0.7f, 1.0f));
            FlyView flyView = this.f3002;
            ObjectAnimator ofFloat4 = ObjectAnimator.ofFloat(flyView, "rotation", flyView.getRotation(), 0.0f);
            ofFloat4.setInterpolator(new DecelerateInterpolator());
            FlyView flyView2 = this.f3002;
            ObjectAnimator ofFloat5 = ObjectAnimator.ofFloat(flyView2, "rotationX", flyView2.getRotationX(), 50.0f);
            ofFloat5.setInterpolator(new DecelerateInterpolator());
            AnimatorSet animatorSet2 = new AnimatorSet();
            animatorSet2.setDuration(800L);
            FlyView flyView3 = this.f3002;
            float[] fArr = {flyView3.getScaleX(), 0.5f};
            FlyView flyView4 = this.f3002;
            animatorSet2.playTogether(ofFloat2, ofFloat3, ofFloat4, ofFloat5, ObjectAnimator.ofFloat(flyView3, "scaleX", fArr), ObjectAnimator.ofFloat(flyView4, "scaleY", flyView4.getScaleY(), 0.5f));
            this.f2999 = animatorSet2;
            this.f2999.start();
        }
    }

    @Override // com.scwang.smartrefresh.layout.header.FalsifyHeader, ඓ.㿎.K.ῲ.Ԕ.AbstractC1399
    /* renamed from: K  reason: contains not printable characters */
    public void m1698(AbstractC1396 r1, int i, int i2) {
        this.f3004 = r1;
        this.f3000 = SmartRefreshLayout.this;
        ((SmartRefreshLayout.C0559) this.f3004).m1854(new C0546());
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1697(AnimatorListenerAdapter animatorListenerAdapter) {
        if (this.f3002 != null && this.f3006 && this.f3000 != null) {
            AnimatorSet animatorSet = this.f2999;
            if (animatorSet != null) {
                animatorSet.end();
                this.f3002.clearAnimation();
            }
            this.f3006 = false;
            this.f3000.m3609(0);
            AnimatorSet animatorSet2 = new AnimatorSet();
            animatorSet2.setDuration(800L);
            FlyView flyView = this.f3002;
            float f = (float) (-this.f3002.getRight());
            ObjectAnimator ofFloat = ObjectAnimator.ofFloat(flyView, "translationX", flyView.getTranslationX(), f);
            FlyView flyView2 = this.f3002;
            float f2 = (float) (-C1436.m3649(10.0f));
            ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(flyView2, "translationY", flyView2.getTranslationY(), f2);
            ofFloat2.setInterpolator(C2369.m6309(0.1f, 1.0f));
            FlyView flyView3 = this.f3002;
            ObjectAnimator ofFloat3 = ObjectAnimator.ofFloat(flyView3, "rotation", flyView3.getRotation(), 0.0f);
            FlyView flyView4 = this.f3002;
            ObjectAnimator ofFloat4 = ObjectAnimator.ofFloat(flyView4, "rotationX", flyView4.getRotationX(), 30.0f);
            ofFloat3.setInterpolator(new AccelerateInterpolator());
            FlyView flyView5 = this.f3002;
            float[] fArr = {flyView5.getScaleX(), 0.9f};
            FlyView flyView6 = this.f3002;
            animatorSet2.playTogether(ofFloat, ofFloat2, ofFloat3, ofFloat4, ObjectAnimator.ofFloat(flyView5, "scaleX", fArr), ObjectAnimator.ofFloat(flyView6, "scaleY", flyView6.getScaleY(), 0.9f));
            animatorSet2.addListener(new C0545());
            AnimatorSet animatorSet3 = new AnimatorSet();
            animatorSet3.setDuration(800L);
            animatorSet3.setInterpolator(new DecelerateInterpolator());
            animatorSet3.playTogether(ObjectAnimator.ofFloat(this.f3002, "translationX", f, 0.0f), ObjectAnimator.ofFloat(this.f3002, "translationY", f2, 0.0f), ObjectAnimator.ofFloat(this.f3002, "rotationX", 30.0f, 0.0f), ObjectAnimator.ofFloat(this.f3002, "scaleX", 0.9f, 1.0f), ObjectAnimator.ofFloat(this.f3002, "scaleY", 0.9f, 1.0f));
            animatorSet3.setStartDelay(100);
            animatorSet3.addListener(new C0544(animatorListenerAdapter));
            this.f2999 = new AnimatorSet();
            this.f2999.playSequentially(animatorSet2, animatorSet3);
            this.f2999.start();
        }
    }
}
