package com.scwang.smartrefresh.header.fungame;

import IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.FSaI4_7.QxJ9d_1;
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.X6FRs_4;
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.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.material.shadow.ShadowDrawableWrapper;
@SuppressLint({"RestrictedApi"})
/* loaded from: classes.dex */
public abstract class FunGameBase extends QxJ9d_1 implements IMuAHx_6 {
    public float KQgRr5e_0;

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

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.IFxWkV_5.QxJ9d_1 f2816KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public X6FRs_4 f2817KQgRr5e_0;

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

    /* renamed from: Mqv2r_3  reason: collision with root package name */
    public boolean f3662Mqv2r_3;
    public int PGPF6hQ_2;

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

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

    public FunGameBase(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        setMinimumHeight(IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.XnFJ5_9.QxJ9d_1.m124KQgRr5e_0(100.0f));
        this.PGPF6hQ_2 = getResources().getDisplayMetrics().heightPixels;
        ((QxJ9d_1) this).KQgRr5e_0 = PGPF6hQ_2.f3087X6FRs_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() {
        if (this.f2820QxJ9d_1) {
            this.f3662Mqv2r_3 = false;
            if (this.KQgRr5e_0 != -1.0f) {
                KQgRr5e_0(this.f2818KQgRr5e_0.m122KQgRr5e_0(), this.f2819PGPF6hQ_2);
                this.f2818KQgRr5e_0.KQgRr5e_0(IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.IFxWkV_5.QxJ9d_1.RefreshFinish);
                this.f2818KQgRr5e_0.m123KQgRr5e_0(0);
            } else {
                this.f2818KQgRr5e_0.KQgRr5e_0(this.QxJ9d_1, true);
            }
            View view = this.f2817KQgRr5e_0.getView();
            ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
            marginLayoutParams.topMargin -= this.QxJ9d_1;
            view.setLayoutParams(marginLayoutParams);
            return;
        }
        this.f2818KQgRr5e_0.KQgRr5e_0(0, true);
    }

    public abstract void KQgRr5e_0(float f, int i, int i2, int i3);

    public void QxJ9d_1() {
        if (this.f3662Mqv2r_3) {
            return;
        }
        this.f3662Mqv2r_3 = true;
        X6FRs_4 KQgRr5e_0 = this.f2818KQgRr5e_0.KQgRr5e_0();
        this.f2817KQgRr5e_0 = KQgRr5e_0;
        View view = KQgRr5e_0.getView();
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        marginLayoutParams.topMargin += this.QxJ9d_1;
        view.setLayoutParams(marginLayoutParams);
    }

    @Override // android.view.ViewGroup
    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        return this.f2816KQgRr5e_0 == IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.IFxWkV_5.QxJ9d_1.Refreshing || super.onInterceptTouchEvent(motionEvent);
    }

    @Override // android.view.View
    public boolean onTouchEvent(MotionEvent motionEvent) {
        IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.IFxWkV_5.QxJ9d_1 qxJ9d_1 = this.f2816KQgRr5e_0;
        if (qxJ9d_1 != IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.IFxWkV_5.QxJ9d_1.Refreshing && qxJ9d_1 != IMuAHx_6.Mqv2r_3.KQgRr5e_0.QxJ9d_1.IFxWkV_5.QxJ9d_1.RefreshFinish) {
            return super.onTouchEvent(motionEvent);
        }
        if (!this.f3662Mqv2r_3) {
            QxJ9d_1();
        }
        int action = motionEvent.getAction() & 255;
        if (action != 0) {
            if (action != 1) {
                if (action == 2) {
                    float rawY = motionEvent.getRawY() - this.KQgRr5e_0;
                    if (rawY >= 0.0f) {
                        double d = this.QxJ9d_1 * 2;
                        double d2 = (this.PGPF6hQ_2 * 2) / 3.0f;
                        double d3 = rawY;
                        Double.isNaN(d3);
                        double max = Math.max((double) ShadowDrawableWrapper.COS_45, d3 * 0.5d);
                        Double.isNaN(d2);
                        Double.isNaN(d);
                        this.f2818KQgRr5e_0.KQgRr5e_0(Math.max(1, (int) Math.min(d * (1.0d - Math.pow(100.0d, (-max) / d2)), max)), false);
                        return true;
                    }
                    this.f2818KQgRr5e_0.KQgRr5e_0(1, false);
                    return true;
                } else if (action != 3) {
                    return true;
                }
            }
            KQgRr5e_0();
            this.KQgRr5e_0 = -1.0f;
            if (this.f2820QxJ9d_1) {
                this.f2818KQgRr5e_0.KQgRr5e_0(this.QxJ9d_1, true);
                return true;
            }
            return true;
        }
        this.KQgRr5e_0 = motionEvent.getRawY();
        this.f2818KQgRr5e_0.KQgRr5e_0(0, true);
        return true;
    }

    @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) {
        if (this.f3662Mqv2r_3) {
            KQgRr5e_0(f, i, i2, i3);
            return;
        }
        this.f2815KQgRr5e_0 = i;
        setTranslationY(i - this.QxJ9d_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 KQgRr5e_0(XnFJ5_9 xnFJ5_9, int i, int i2) {
        this.f2820QxJ9d_1 = false;
        setTranslationY(0.0f);
    }

    @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) {
        this.f2816KQgRr5e_0 = qxJ9d_12;
    }

    @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.f2818KQgRr5e_0 = xgtqvk_8;
        this.QxJ9d_1 = i;
        if (isInEditMode()) {
            return;
        }
        setTranslationY(this.f2815KQgRr5e_0 - this.QxJ9d_1);
        xgtqvk_8.QxJ9d_1(this, true);
    }

    @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.f2819PGPF6hQ_2 = z;
        if (!this.f2820QxJ9d_1) {
            this.f2820QxJ9d_1 = true;
            if (this.f3662Mqv2r_3) {
                if (this.KQgRr5e_0 == -1.0f) {
                    KQgRr5e_0();
                    KQgRr5e_0(xnFJ5_9, z);
                    return 0;
                }
                return Integer.MAX_VALUE;
            }
        }
        return 0;
    }
}
