package androidx.swiperefreshlayout.widget;

import android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Transformation;
import android.widget.ListView;
import androidx.swiperefreshlayout.widget.d;
import defpackage.bk6;
import defpackage.ck6;
import defpackage.cm7;
import defpackage.dk6;
import defpackage.e61;
import defpackage.ek6;
import defpackage.fk6;
import defpackage.gk6;
import defpackage.hk6;
import defpackage.ik6;
import defpackage.rq6;
import defpackage.sf1;
import defpackage.sia;
import defpackage.tp7;
import defpackage.vo6;
import defpackage.w51;
import java.util.WeakHashMap;

/* JADX INFO: loaded from: classes.dex */
public class SwipeRefreshLayout extends ViewGroup implements gk6, fk6, ck6, bk6, hk6, dk6 {
    public static final int[] an = {R.attr.enabled};
    public View a;
    public int aa;
    public final androidx.swiperefreshlayout.widget.d ab;
    public Animation ac;
    public Animation ad;
    public Animation ae;
    public Animation af;
    public boolean ag;
    public int ah;
    public d ai;
    public boolean aj;
    public final Animation.AnimationListener ak;
    public final Animation al;
    public final Animation am;
    public e b;
    public boolean c;
    public final int d;
    public float e;
    public float f;
    public final ik6 i;
    public final ek6 j;
    public final int[] k;
    public final int[] l;
    public final int[] m;
    public boolean n;
    public final int o;
    public int p;
    public float q;
    public float r;
    public boolean s;
    public int t;
    public final DecelerateInterpolator u;
    public final androidx.swiperefreshlayout.widget.a v;
    public int w;
    public int x;
    public final int y;
    public final int z;

    public class a implements Animation.AnimationListener {
        public a() {
        }

        @Override // android.view.animation.Animation.AnimationListener
        public final void onAnimationEnd(Animation animation) {
            e eVar;
            SwipeRefreshLayout swipeRefreshLayout = SwipeRefreshLayout.this;
            if (!swipeRefreshLayout.c) {
                swipeRefreshLayout.f();
                return;
            }
            swipeRefreshLayout.ab.setAlpha(255);
            swipeRefreshLayout.ab.start();
            if (swipeRefreshLayout.ag && (eVar = swipeRefreshLayout.b) != null) {
                eVar.b();
            }
            swipeRefreshLayout.p = swipeRefreshLayout.v.getTop();
        }

        @Override // android.view.animation.Animation.AnimationListener
        public final void onAnimationRepeat(Animation animation) {
        }

        @Override // android.view.animation.Animation.AnimationListener
        public final void onAnimationStart(Animation animation) {
        }
    }

    public class b extends Animation {
        public b() {
        }

        @Override // android.view.animation.Animation
        public final void applyTransformation(float f, Transformation transformation) {
            SwipeRefreshLayout swipeRefreshLayout = SwipeRefreshLayout.this;
            int iAbs = swipeRefreshLayout.z - Math.abs(swipeRefreshLayout.y);
            swipeRefreshLayout.setTargetOffsetTopAndBottom((swipeRefreshLayout.x + ((int) ((iAbs - r1) * f))) - swipeRefreshLayout.v.getTop());
            androidx.swiperefreshlayout.widget.d dVar = swipeRefreshLayout.ab;
            float f2 = 1.0f - f;
            d.b bVar = dVar.a;
            if (f2 != bVar.p) {
                bVar.p = f2;
            }
            dVar.invalidateSelf();
        }
    }

    public class c extends Animation {
        public c() {
        }

        @Override // android.view.animation.Animation
        public final void applyTransformation(float f, Transformation transformation) {
            SwipeRefreshLayout.this.e(f);
        }
    }

    public interface d {
        boolean a();
    }

    public interface e {
        void b();
    }

    public SwipeRefreshLayout(@vo6 Context context, @rq6 AttributeSet attributeSet) {
        super(context, attributeSet);
        this.c = false;
        this.e = -1.0f;
        this.k = new int[2];
        this.l = new int[2];
        this.m = new int[2];
        this.t = -1;
        this.w = -1;
        this.ak = new a();
        this.al = new b();
        this.am = new c();
        this.d = ViewConfiguration.get(context).getScaledTouchSlop();
        this.o = getResources().getInteger(R.integer.config_mediumAnimTime);
        setWillNotDraw(false);
        this.u = new DecelerateInterpolator(2.0f);
        DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        this.ah = (int) (displayMetrics.density * 40.0f);
        androidx.swiperefreshlayout.widget.a aVar = new androidx.swiperefreshlayout.widget.a(getContext());
        float f2 = aVar.getContext().getResources().getDisplayMetrics().density;
        TypedArray typedArrayObtainStyledAttributes = aVar.getContext().obtainStyledAttributes(tp7.j.a);
        aVar.b = typedArrayObtainStyledAttributes.getColor(0, -328966);
        typedArrayObtainStyledAttributes.recycle();
        ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());
        sia.ad(aVar, f2 * 4.0f);
        shapeDrawable.getPaint().setColor(aVar.b);
        aVar.setBackground(shapeDrawable);
        this.v = aVar;
        androidx.swiperefreshlayout.widget.d dVar = new androidx.swiperefreshlayout.widget.d(getContext());
        this.ab = dVar;
        dVar.c(1);
        this.v.setImageDrawable(this.ab);
        this.v.setVisibility(8);
        addView(this.v);
        setChildrenDrawingOrderEnabled(true);
        int i = (int) (displayMetrics.density * 64.0f);
        this.z = i;
        this.e = i;
        this.i = new ik6();
        this.j = new ek6(this);
        setNestedScrollingEnabled(true);
        int i2 = -this.ah;
        this.p = i2;
        this.y = i2;
        e(1.0f);
        TypedArray typedArrayObtainStyledAttributes2 = context.obtainStyledAttributes(attributeSet, an);
        setEnabled(typedArrayObtainStyledAttributes2.getBoolean(0, true));
        typedArrayObtainStyledAttributes2.recycle();
    }

    private void setColorViewAlpha(int i) {
        this.v.getBackground().setAlpha(i);
        this.ab.setAlpha(i);
    }

    public final boolean a() {
        d dVar = this.ai;
        if (dVar != null) {
            return dVar.a();
        }
        View view = this.a;
        return view instanceof ListView ? ((ListView) view).canScrollList(-1) : view.canScrollVertically(-1);
    }

    public final void b() {
        if (this.a == null) {
            for (int i = 0; i < getChildCount(); i++) {
                View childAt = getChildAt(i);
                if (!childAt.equals(this.v)) {
                    this.a = childAt;
                    return;
                }
            }
        }
    }

    public final void c(float f2) {
        if (f2 > this.e) {
            g(true, true);
            return;
        }
        this.c = false;
        androidx.swiperefreshlayout.widget.d dVar = this.ab;
        d.b bVar = dVar.a;
        bVar.e = 0.0f;
        bVar.f = 0.0f;
        dVar.invalidateSelf();
        h hVar = new h(this);
        this.x = this.p;
        Animation animation = this.am;
        animation.reset();
        animation.setDuration(200L);
        animation.setInterpolator(this.u);
        androidx.swiperefreshlayout.widget.a aVar = this.v;
        aVar.a = hVar;
        aVar.clearAnimation();
        this.v.startAnimation(animation);
        androidx.swiperefreshlayout.widget.d dVar2 = this.ab;
        d.b bVar2 = dVar2.a;
        if (bVar2.n) {
            bVar2.n = false;
        }
        dVar2.invalidateSelf();
    }

    public final void d(float f2) {
        Animation animation;
        Animation animation2;
        androidx.swiperefreshlayout.widget.d dVar = this.ab;
        d.b bVar = dVar.a;
        if (!bVar.n) {
            bVar.n = true;
        }
        dVar.invalidateSelf();
        float fMin = Math.min(1.0f, Math.abs(f2 / this.e));
        float fMax = (((float) Math.max(((double) fMin) - 0.4d, 0.0d)) * 5.0f) / 3.0f;
        float fAbs = Math.abs(f2) - this.e;
        int i = this.aa;
        if (i <= 0) {
            i = this.z;
        }
        float f3 = i;
        double dMax = Math.max(0.0f, Math.min(fAbs, f3 * 2.0f) / f3) / 4.0f;
        float fPow = ((float) (dMax - Math.pow(dMax, 2.0d))) * 2.0f;
        int i2 = this.y + ((int) ((f3 * fMin) + (f3 * fPow * 2.0f)));
        if (this.v.getVisibility() != 0) {
            this.v.setVisibility(0);
        }
        this.v.setScaleX(1.0f);
        this.v.setScaleY(1.0f);
        if (f2 < this.e) {
            if (this.ab.a.t > 76 && ((animation2 = this.ae) == null || !animation2.hasStarted() || animation2.hasEnded())) {
                g gVar = new g(this, this.ab.a.t, 76);
                gVar.setDuration(300L);
                androidx.swiperefreshlayout.widget.a aVar = this.v;
                aVar.a = null;
                aVar.clearAnimation();
                this.v.startAnimation(gVar);
                this.ae = gVar;
            }
        } else if (this.ab.a.t < 255 && ((animation = this.af) == null || !animation.hasStarted() || animation.hasEnded())) {
            g gVar2 = new g(this, this.ab.a.t, 255);
            gVar2.setDuration(300L);
            androidx.swiperefreshlayout.widget.a aVar2 = this.v;
            aVar2.a = null;
            aVar2.clearAnimation();
            this.v.startAnimation(gVar2);
            this.af = gVar2;
        }
        float fMin2 = Math.min(0.8f, fMax * 0.8f);
        androidx.swiperefreshlayout.widget.d dVar2 = this.ab;
        d.b bVar2 = dVar2.a;
        bVar2.e = 0.0f;
        bVar2.f = fMin2;
        dVar2.invalidateSelf();
        float fMin3 = Math.min(1.0f, fMax);
        androidx.swiperefreshlayout.widget.d dVar3 = this.ab;
        d.b bVar3 = dVar3.a;
        if (fMin3 != bVar3.p) {
            bVar3.p = fMin3;
        }
        dVar3.invalidateSelf();
        androidx.swiperefreshlayout.widget.d dVar4 = this.ab;
        dVar4.a.g = ((fPow * 2.0f) + ((fMax * 0.4f) - 0.25f)) * 0.5f;
        dVar4.invalidateSelf();
        setTargetOffsetTopAndBottom(i2 - this.p);
    }

    @Override // android.view.View
    public final boolean dispatchNestedFling(float f2, float f3, boolean z) {
        return this.j.a(f2, f3, z);
    }

    @Override // android.view.View
    public final boolean dispatchNestedPreFling(float f2, float f3) {
        return this.j.b(f2, f3);
    }

    @Override // android.view.View
    public final boolean dispatchNestedPreScroll(int i, int i2, int[] iArr, int[] iArr2) {
        return this.j.c(i, i2, iArr, iArr2, 0);
    }

    @Override // android.view.View
    public final boolean dispatchNestedScroll(int i, int i2, int i3, int i4, int[] iArr) {
        return this.j.d(i, i2, i3, i4, iArr, 0, null);
    }

    public final void e(float f2) {
        setTargetOffsetTopAndBottom((this.x + ((int) ((this.y - r0) * f2))) - this.v.getTop());
    }

    public final void f() {
        this.v.clearAnimation();
        this.ab.stop();
        this.v.setVisibility(8);
        setColorViewAlpha(255);
        setTargetOffsetTopAndBottom(this.y - this.p);
        this.p = this.v.getTop();
    }

    public final void g(boolean z, boolean z2) {
        if (this.c != z) {
            this.ag = z2;
            b();
            this.c = z;
            Animation.AnimationListener animationListener = this.ak;
            if (!z) {
                androidx.swiperefreshlayout.widget.f fVar = new androidx.swiperefreshlayout.widget.f(this);
                this.ad = fVar;
                fVar.setDuration(150L);
                androidx.swiperefreshlayout.widget.a aVar = this.v;
                aVar.a = animationListener;
                aVar.clearAnimation();
                this.v.startAnimation(this.ad);
                return;
            }
            this.x = this.p;
            Animation animation = this.al;
            animation.reset();
            animation.setDuration(200L);
            animation.setInterpolator(this.u);
            if (animationListener != null) {
                this.v.a = animationListener;
            }
            this.v.clearAnimation();
            this.v.startAnimation(animation);
        }
    }

    @Override // android.view.ViewGroup
    public final int getChildDrawingOrder(int i, int i2) {
        int i3 = this.w;
        return i3 < 0 ? i2 : i2 == i + (-1) ? i3 : i2 >= i3 ? i2 + 1 : i2;
    }

    @Override // android.view.ViewGroup
    public int getNestedScrollAxes() {
        ik6 ik6Var = this.i;
        return ik6Var.b | ik6Var.a;
    }

    public int getProgressCircleDiameter() {
        return this.ah;
    }

    public int getProgressViewEndOffset() {
        return this.z;
    }

    public int getProgressViewStartOffset() {
        return this.y;
    }

    public final void h(float f2) {
        float f3 = this.r;
        float f4 = f2 - f3;
        float f5 = this.d;
        if (f4 <= f5 || this.s) {
            return;
        }
        this.q = f3 + f5;
        this.s = true;
        this.ab.setAlpha(76);
    }

    @Override // android.view.View
    public final boolean hasNestedScrollingParent() {
        return this.j.f(0);
    }

    @Override // android.view.View
    public final boolean isNestedScrollingEnabled() {
        return this.j.d;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        f();
    }

    /* JADX WARN: Removed duplicated region for block: B:34:0x005f  */
    @Override // android.view.ViewGroup
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        b();
        int actionMasked = motionEvent.getActionMasked();
        if (isEnabled() && !a() && !this.c && !this.n) {
            if (actionMasked != 0) {
                if (actionMasked == 1) {
                    this.s = false;
                    this.t = -1;
                } else if (actionMasked == 2) {
                    int i = this.t;
                    if (i == -1) {
                        Log.e("SwipeRefreshLayout", "Got ACTION_MOVE event but don't have an active pointer id.");
                        return false;
                    }
                    int iFindPointerIndex = motionEvent.findPointerIndex(i);
                    if (iFindPointerIndex >= 0) {
                        h(motionEvent.getY(iFindPointerIndex));
                    }
                } else if (actionMasked != 3) {
                    if (actionMasked == 6) {
                        int actionIndex = motionEvent.getActionIndex();
                        if (motionEvent.getPointerId(actionIndex) == this.t) {
                            this.t = motionEvent.getPointerId(actionIndex == 0 ? 1 : 0);
                        }
                    }
                }
                return this.s;
            }
            setTargetOffsetTopAndBottom(this.y - this.v.getTop());
            int pointerId = motionEvent.getPointerId(0);
            this.t = pointerId;
            this.s = false;
            int iFindPointerIndex2 = motionEvent.findPointerIndex(pointerId);
            if (iFindPointerIndex2 >= 0) {
                this.r = motionEvent.getY(iFindPointerIndex2);
                return this.s;
            }
        }
        return false;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onLayout(boolean z, int i, int i2, int i3, int i4) {
        int measuredWidth = getMeasuredWidth();
        int measuredHeight = getMeasuredHeight();
        if (getChildCount() == 0) {
            return;
        }
        if (this.a == null) {
            b();
        }
        View view = this.a;
        if (view == null) {
            return;
        }
        int paddingLeft = getPaddingLeft();
        int paddingTop = getPaddingTop();
        view.layout(paddingLeft, paddingTop, ((measuredWidth - getPaddingLeft()) - getPaddingRight()) + paddingLeft, ((measuredHeight - getPaddingTop()) - getPaddingBottom()) + paddingTop);
        int measuredWidth2 = this.v.getMeasuredWidth();
        int measuredHeight2 = this.v.getMeasuredHeight();
        int i5 = measuredWidth / 2;
        int i6 = measuredWidth2 / 2;
        int i7 = this.p;
        this.v.layout(i5 - i6, i7, i5 + i6, measuredHeight2 + i7);
    }

    @Override // android.view.View
    public final void onMeasure(int i, int i2) {
        super.onMeasure(i, i2);
        if (this.a == null) {
            b();
        }
        View view = this.a;
        if (view == null) {
            return;
        }
        view.measure(View.MeasureSpec.makeMeasureSpec((getMeasuredWidth() - getPaddingLeft()) - getPaddingRight(), 1073741824), View.MeasureSpec.makeMeasureSpec((getMeasuredHeight() - getPaddingTop()) - getPaddingBottom(), 1073741824));
        this.v.measure(View.MeasureSpec.makeMeasureSpec(this.ah, 1073741824), View.MeasureSpec.makeMeasureSpec(this.ah, 1073741824));
        this.w = -1;
        for (int i3 = 0; i3 < getChildCount(); i3++) {
            if (getChildAt(i3) == this.v) {
                this.w = i3;
                return;
            }
        }
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final boolean onNestedFling(View view, float f2, float f3, boolean z) {
        return this.j.a(f2, f3, z);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final boolean onNestedPreFling(View view, float f2, float f3) {
        return this.j.b(f2, f3);
    }

    @Override // defpackage.fk6
    public final void onNestedPreScroll(View view, int i, int i2, int[] iArr, int i3) {
        if (i3 == 0) {
            onNestedPreScroll(view, i, i2, iArr);
        }
    }

    @Override // defpackage.gk6
    public final void onNestedScroll(View view, int i, int i2, int i3, int i4, int i5, int[] iArr) {
        if (i5 != 0) {
            return;
        }
        int i6 = iArr[1];
        if (i5 == 0) {
            this.j.d(i, i2, i3, i4, this.l, i5, iArr);
        }
        int i7 = i4 - (iArr[1] - i6);
        if ((i7 == 0 ? i4 + this.l[1] : i7) >= 0 || a()) {
            return;
        }
        float fAbs = this.f + Math.abs(r14);
        this.f = fAbs;
        d(fAbs);
        iArr[1] = iArr[1] + i7;
    }

    @Override // defpackage.fk6
    public final void onNestedScrollAccepted(View view, View view2, int i, int i2) {
        if (i2 == 0) {
            onNestedScrollAccepted(view, view2, i);
        }
    }

    @Override // android.view.View
    public final void onRestoreInstanceState(Parcelable parcelable) {
        f fVar = (f) parcelable;
        super.onRestoreInstanceState(fVar.getSuperState());
        setRefreshing(fVar.a);
    }

    @Override // android.view.View
    public final Parcelable onSaveInstanceState() {
        return new f(super.onSaveInstanceState(), this.c);
    }

    @Override // defpackage.fk6
    public final boolean onStartNestedScroll(View view, View view2, int i, int i2) {
        if (i2 == 0) {
            return onStartNestedScroll(view, view2, i);
        }
        return false;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void onStopNestedScroll(View view) {
        this.i.a = 0;
        this.n = false;
        float f2 = this.f;
        if (f2 > 0.0f) {
            c(f2);
            this.f = 0.0f;
        }
        stopNestedScroll();
    }

    @Override // android.view.View
    public final boolean onTouchEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (isEnabled() && !a() && !this.c && !this.n) {
            if (actionMasked == 0) {
                this.t = motionEvent.getPointerId(0);
                this.s = false;
                return true;
            }
            if (actionMasked == 1) {
                int iFindPointerIndex = motionEvent.findPointerIndex(this.t);
                if (iFindPointerIndex < 0) {
                    Log.e("SwipeRefreshLayout", "Got ACTION_UP event but don't have an active pointer id.");
                    return false;
                }
                if (this.s) {
                    float y = (motionEvent.getY(iFindPointerIndex) - this.q) * 0.5f;
                    this.s = false;
                    c(y);
                }
                this.t = -1;
                return false;
            }
            if (actionMasked == 2) {
                int iFindPointerIndex2 = motionEvent.findPointerIndex(this.t);
                if (iFindPointerIndex2 < 0) {
                    Log.e("SwipeRefreshLayout", "Got ACTION_MOVE event but have an invalid active pointer id.");
                    return false;
                }
                float y2 = motionEvent.getY(iFindPointerIndex2);
                h(y2);
                if (this.s) {
                    float f2 = (y2 - this.q) * 0.5f;
                    if (f2 > 0.0f) {
                        getParent().requestDisallowInterceptTouchEvent(true);
                        d(f2);
                    }
                }
                return true;
            }
            if (actionMasked != 3) {
                if (actionMasked != 5) {
                    if (actionMasked == 6) {
                        int actionIndex = motionEvent.getActionIndex();
                        if (motionEvent.getPointerId(actionIndex) == this.t) {
                            this.t = motionEvent.getPointerId(actionIndex == 0 ? 1 : 0);
                            return true;
                        }
                    }
                    return true;
                }
                int actionIndex2 = motionEvent.getActionIndex();
                if (actionIndex2 < 0) {
                    Log.e("SwipeRefreshLayout", "Got ACTION_POINTER_DOWN event but have an invalid action index.");
                    return false;
                }
                this.t = motionEvent.getPointerId(actionIndex2);
                return true;
            }
        }
        return false;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void requestDisallowInterceptTouchEvent(boolean z) {
        ViewParent parent;
        View view = this.a;
        if (view == null || sia.q(view)) {
            super.requestDisallowInterceptTouchEvent(z);
        } else {
            if (this.aj || (parent = getParent()) == null) {
                return;
            }
            parent.requestDisallowInterceptTouchEvent(z);
        }
    }

    public void setAnimationProgress(float f2) {
        this.v.setScaleX(f2);
        this.v.setScaleY(f2);
    }

    @Deprecated
    public void setColorScheme(@e61 int... iArr) {
        setColorSchemeResources(iArr);
    }

    public void setColorSchemeColors(@w51 int... iArr) {
        b();
        androidx.swiperefreshlayout.widget.d dVar = this.ab;
        d.b bVar = dVar.a;
        bVar.i = iArr;
        bVar.a(0);
        bVar.a(0);
        dVar.invalidateSelf();
    }

    public void setColorSchemeResources(@e61 int... iArr) {
        Context context = getContext();
        int[] iArr2 = new int[iArr.length];
        for (int i = 0; i < iArr.length; i++) {
            iArr2[i] = sf1.getColor(context, iArr[i]);
        }
        setColorSchemeColors(iArr2);
    }

    public void setDistanceToTriggerSync(int i) {
        this.e = i;
    }

    @Override // android.view.View
    public void setEnabled(boolean z) {
        super.setEnabled(z);
        if (z) {
            return;
        }
        f();
    }

    @Deprecated
    public void setLegacyRequestDisallowInterceptTouchEventEnabled(boolean z) {
        this.aj = z;
    }

    @Override // android.view.View
    public void setNestedScrollingEnabled(boolean z) {
        this.j.g(z);
    }

    public void setOnChildScrollUpCallback(@rq6 d dVar) {
        this.ai = dVar;
    }

    public void setOnRefreshListener(@rq6 e eVar) {
        this.b = eVar;
    }

    @Deprecated
    public void setProgressBackgroundColor(int i) {
        setProgressBackgroundColorSchemeResource(i);
    }

    public void setProgressBackgroundColorSchemeColor(@w51 int i) {
        this.v.setBackgroundColor(i);
    }

    public void setProgressBackgroundColorSchemeResource(@e61 int i) {
        setProgressBackgroundColorSchemeColor(sf1.getColor(getContext(), i));
    }

    public void setRefreshing(boolean z) {
        if (!z || this.c == z) {
            g(z, false);
            return;
        }
        this.c = z;
        setTargetOffsetTopAndBottom((this.z + this.y) - this.p);
        this.ag = false;
        this.v.setVisibility(0);
        this.ab.setAlpha(255);
        androidx.swiperefreshlayout.widget.e eVar = new androidx.swiperefreshlayout.widget.e(this);
        this.ac = eVar;
        eVar.setDuration(this.o);
        Animation.AnimationListener animationListener = this.ak;
        if (animationListener != null) {
            this.v.a = animationListener;
        }
        this.v.clearAnimation();
        this.v.startAnimation(this.ac);
    }

    public void setSize(int i) {
        if (i == 0 || i == 1) {
            DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
            if (i == 0) {
                this.ah = (int) (displayMetrics.density * 56.0f);
            } else {
                this.ah = (int) (displayMetrics.density * 40.0f);
            }
            this.v.setImageDrawable(null);
            this.ab.c(i);
            this.v.setImageDrawable(this.ab);
        }
    }

    public void setSlingshotDistance(@cm7 int i) {
        this.aa = i;
    }

    public void setTargetOffsetTopAndBottom(int i) {
        androidx.swiperefreshlayout.widget.a aVar = this.v;
        aVar.bringToFront();
        WeakHashMap weakHashMap = sia.a;
        aVar.offsetTopAndBottom(i);
        this.p = aVar.getTop();
    }

    @Override // android.view.View
    public final boolean startNestedScroll(int i) {
        return this.j.h(i, 0);
    }

    @Override // android.view.View
    public final void stopNestedScroll() {
        this.j.i(0);
    }

    public static class f extends View.BaseSavedState {
        public static final Parcelable.Creator<f> CREATOR = new a();
        public final boolean a;

        public class a implements Parcelable.Creator<f> {
            @Override // android.os.Parcelable.Creator
            public final f createFromParcel(Parcel parcel) {
                return new f(parcel);
            }

            @Override // android.os.Parcelable.Creator
            public final f[] newArray(int i) {
                return new f[i];
            }
        }

        public f(Parcelable parcelable, boolean z) {
            super(parcelable);
            this.a = z;
        }

        @Override // android.view.View.BaseSavedState, android.view.AbsSavedState, android.os.Parcelable
        public final void writeToParcel(Parcel parcel, int i) {
            super.writeToParcel(parcel, i);
            parcel.writeByte(this.a ? (byte) 1 : (byte) 0);
        }

        public f(Parcel parcel) {
            super(parcel);
            this.a = parcel.readByte() != 0;
        }
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void onNestedPreScroll(View view, int i, int i2, int[] iArr) {
        if (i2 > 0) {
            float f2 = this.f;
            if (f2 > 0.0f) {
                float f3 = i2;
                if (f3 > f2) {
                    iArr[1] = (int) f2;
                    this.f = 0.0f;
                } else {
                    this.f = f2 - f3;
                    iArr[1] = i2;
                }
                d(this.f);
            }
        }
        int i3 = i - iArr[0];
        int i4 = i2 - iArr[1];
        int[] iArr2 = this.k;
        if (dispatchNestedPreScroll(i3, i4, iArr2, null)) {
            iArr[0] = iArr[0] + iArr2[0];
            iArr[1] = iArr[1] + iArr2[1];
        }
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void onNestedScrollAccepted(View view, View view2, int i) {
        this.i.a = i;
        startNestedScroll(i & 2);
        this.f = 0.0f;
        this.n = true;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final boolean onStartNestedScroll(View view, View view2, int i) {
        return (!isEnabled() || this.c || (i & 2) == 0) ? false : true;
    }

    @Override // defpackage.fk6
    public final void onStopNestedScroll(View view, int i) {
        if (i == 0) {
            onStopNestedScroll(view);
        }
    }

    @Override // defpackage.fk6
    public final void onNestedScroll(View view, int i, int i2, int i3, int i4, int i5) {
        onNestedScroll(view, i, i2, i3, i4, i5, this.m);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void onNestedScroll(View view, int i, int i2, int i3, int i4) {
        onNestedScroll(view, i, i2, i3, i4, 0, this.m);
    }
}
