package ῲ.䀟.K;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import androidx.recyclerview.widget.RecyclerView;
import com.facebook.appevents.internal.InAppPurchaseEventManager;
import com.google.android.material.progressindicator.BaseProgressIndicator;
import ῲ.ᨨ.ᨨ.C1729;

/* renamed from: ῲ.䀟.K.㿎  reason: contains not printable characters */
/* compiled from: FastScroller */
public class C2338 extends RecyclerView.AbstractC0232 implements RecyclerView.AbstractC0236 {

    /* renamed from: ᆯ  reason: contains not printable characters */
    public static final int[] f8072 = new int[0];

    /* renamed from: ᝁ  reason: contains not printable characters */
    public static final int[] f8073 = {16842919};

    /* renamed from: ʬ  reason: contains not printable characters */
    public final StateListDrawable f8074;

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

    /* renamed from: Ԛ  reason: contains not printable characters */
    public boolean f8076 = false;

    /* renamed from: ؿ  reason: contains not printable characters */
    public float f8077;

    /* renamed from: ݜ  reason: contains not printable characters */
    public RecyclerView f8078;

    /* renamed from: ඓ  reason: contains not printable characters */
    public final int f8079;

    /* renamed from: ᑓ  reason: contains not printable characters */
    public final int[] f8080 = new int[2];

    /* renamed from: ᓆ  reason: contains not printable characters */
    public int f8081 = 0;

    /* renamed from: ᓣ  reason: contains not printable characters */
    public int f8082 = 0;

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

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

    /* renamed from: ῲ  reason: contains not printable characters */
    public final int f8085;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public final StateListDrawable f8086;

    /* renamed from: K  reason: contains not printable characters */
    public final int f8087;

    /* renamed from: ゎ  reason: contains not printable characters */
    public final ValueAnimator f8088 = ValueAnimator.ofFloat(0.0f, 1.0f);

    /* renamed from: ト  reason: contains not printable characters */
    public int f8089 = 0;

    /* renamed from: 㑃  reason: contains not printable characters */
    public int f8090;

    /* renamed from: 㗗  reason: contains not printable characters */
    public int f8091;

    /* renamed from: 㗽  reason: contains not printable characters */
    public int f8092 = 0;

    /* renamed from: 㮔  reason: contains not printable characters */
    public final Runnable f8093 = new RunnableC2341();

    /* renamed from: 㳳  reason: contains not printable characters */
    public final int f8094;

    /* renamed from: 㴪  reason: contains not printable characters */
    public final int[] f8095 = new int[2];

    /* renamed from: 㴹  reason: contains not printable characters */
    public final int f8096;

    /* renamed from: 㶋  reason: contains not printable characters */
    public int f8097 = 0;

    /* renamed from: 㸾  reason: contains not printable characters */
    public final Drawable f8098;

    /* renamed from: 㿎  reason: contains not printable characters */
    public final Drawable f8099;

    /* renamed from: 䀟  reason: contains not printable characters */
    public boolean f8100 = false;

    /* renamed from: 䁗  reason: contains not printable characters */
    public float f8101;

    /* renamed from: 䃖  reason: contains not printable characters */
    public final RecyclerView.AbstractC0267 f8102 = new C2340();

    /* renamed from: ῲ.䀟.K.㿎$ʬ  reason: contains not printable characters */
    /* compiled from: FastScroller */
    public class C2339 extends AnimatorListenerAdapter {

        /* renamed from: K  reason: contains not printable characters */
        public boolean f8104 = false;

        public C2339() {
        }

        public void onAnimationCancel(Animator animator) {
            this.f8104 = true;
        }

        public void onAnimationEnd(Animator animator) {
            if (this.f8104) {
                this.f8104 = false;
            } else if (((Float) C2338.this.f8088.getAnimatedValue()).floatValue() == 0.0f) {
                C2338 r3 = C2338.this;
                r3.f8089 = 0;
                r3.m6130(0);
            } else {
                C2338 r32 = C2338.this;
                r32.f8089 = 2;
                r32.f8078.invalidate();
            }
        }
    }

    /* renamed from: ῲ.䀟.K.㿎$ῲ  reason: contains not printable characters */
    /* compiled from: FastScroller */
    public class C2340 extends RecyclerView.AbstractC0267 {
        public C2340() {
        }

        @Override // androidx.recyclerview.widget.RecyclerView.AbstractC0267
        public void onScrolled(RecyclerView recyclerView, int i, int i2) {
            C2338 r10 = C2338.this;
            int computeHorizontalScrollOffset = recyclerView.computeHorizontalScrollOffset();
            int computeVerticalScrollOffset = recyclerView.computeVerticalScrollOffset();
            int computeVerticalScrollRange = r10.f8078.computeVerticalScrollRange();
            int i3 = r10.f8092;
            r10.f8100 = computeVerticalScrollRange - i3 > 0 && i3 >= r10.f8087;
            int computeHorizontalScrollRange = r10.f8078.computeHorizontalScrollRange();
            int i4 = r10.f8082;
            r10.f8076 = computeHorizontalScrollRange - i4 > 0 && i4 >= r10.f8087;
            if (r10.f8100 || r10.f8076) {
                if (r10.f8100) {
                    float f = (float) i3;
                    r10.f8090 = (int) ((((f / 2.0f) + ((float) computeVerticalScrollOffset)) * f) / ((float) computeVerticalScrollRange));
                    r10.f8083 = Math.min(i3, (i3 * i3) / computeVerticalScrollRange);
                }
                if (r10.f8076) {
                    float f2 = (float) computeHorizontalScrollOffset;
                    float f3 = (float) i4;
                    r10.f8091 = (int) ((((f3 / 2.0f) + f2) * f3) / ((float) computeHorizontalScrollRange));
                    r10.f8075 = Math.min(i4, (i4 * i4) / computeHorizontalScrollRange);
                }
                int i5 = r10.f8097;
                if (i5 == 0 || i5 == 1) {
                    r10.m6130(1);
                }
            } else if (r10.f8097 != 0) {
                r10.m6130(0);
            }
        }
    }

    /* renamed from: ῲ.䀟.K.㿎$K  reason: contains not printable characters */
    /* compiled from: FastScroller */
    public class RunnableC2341 implements Runnable {
        public RunnableC2341() {
        }

        public void run() {
            C2338 r0 = C2338.this;
            int i = r0.f8089;
            if (i == 1) {
                r0.f8088.cancel();
            } else if (i != 2) {
                return;
            }
            r0.f8089 = 3;
            ValueAnimator valueAnimator = r0.f8088;
            valueAnimator.setFloatValues(((Float) valueAnimator.getAnimatedValue()).floatValue(), 0.0f);
            r0.f8088.setDuration((long) 500);
            r0.f8088.start();
        }
    }

    /* renamed from: ῲ.䀟.K.㿎$㸾  reason: contains not printable characters */
    /* compiled from: FastScroller */
    public class C2342 implements ValueAnimator.AnimatorUpdateListener {
        public C2342() {
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int floatValue = (int) (((Float) valueAnimator.getAnimatedValue()).floatValue() * 255.0f);
            C2338.this.f8074.setAlpha(floatValue);
            C2338.this.f8098.setAlpha(floatValue);
            C2338.this.f8078.invalidate();
        }
    }

    public C2338(RecyclerView recyclerView, StateListDrawable stateListDrawable, Drawable drawable, StateListDrawable stateListDrawable2, Drawable drawable2, int i, int i2, int i3) {
        this.f8074 = stateListDrawable;
        this.f8098 = drawable;
        this.f8086 = stateListDrawable2;
        this.f8099 = drawable2;
        this.f8079 = Math.max(i, stateListDrawable.getIntrinsicWidth());
        this.f8096 = Math.max(i, drawable.getIntrinsicWidth());
        this.f8084 = Math.max(i, stateListDrawable2.getIntrinsicWidth());
        this.f8094 = Math.max(i, drawable2.getIntrinsicWidth());
        this.f8087 = i2;
        this.f8085 = i3;
        this.f8074.setAlpha(BaseProgressIndicator.MAX_ALPHA);
        this.f8098.setAlpha(BaseProgressIndicator.MAX_ALPHA);
        this.f8088.addListener(new C2339());
        this.f8088.addUpdateListener(new C2342());
        RecyclerView recyclerView2 = this.f8078;
        if (recyclerView2 != recyclerView) {
            if (recyclerView2 != null) {
                recyclerView2.removeItemDecoration(this);
                this.f8078.removeOnItemTouchListener(this);
                this.f8078.removeOnScrollListener(this.f8102);
                m6129();
            }
            this.f8078 = recyclerView;
            RecyclerView recyclerView3 = this.f8078;
            if (recyclerView3 != null) {
                recyclerView3.addItemDecoration(this);
                this.f8078.addOnItemTouchListener(this);
                this.f8078.addOnScrollListener(this.f8102);
            }
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.AbstractC0232
    public void onDrawOver(Canvas canvas, RecyclerView recyclerView, RecyclerView.C0248 r8) {
        if (this.f8082 != this.f8078.getWidth() || this.f8092 != this.f8078.getHeight()) {
            this.f8082 = this.f8078.getWidth();
            this.f8092 = this.f8078.getHeight();
            m6130(0);
        } else if (this.f8089 != 0) {
            if (this.f8100) {
                int i = this.f8082;
                int i2 = this.f8079;
                int i3 = i - i2;
                int i4 = this.f8090;
                int i5 = this.f8083;
                int i6 = i4 - (i5 / 2);
                this.f8074.setBounds(0, 0, i2, i5);
                this.f8098.setBounds(0, 0, this.f8096, this.f8092);
                if (m6126()) {
                    this.f8098.draw(canvas);
                    canvas.translate((float) this.f8079, (float) i6);
                    canvas.scale(-1.0f, 1.0f);
                    this.f8074.draw(canvas);
                    canvas.scale(1.0f, 1.0f);
                    canvas.translate((float) (-this.f8079), (float) (-i6));
                } else {
                    canvas.translate((float) i3, 0.0f);
                    this.f8098.draw(canvas);
                    canvas.translate(0.0f, (float) i6);
                    this.f8074.draw(canvas);
                    canvas.translate((float) (-i3), (float) (-i6));
                }
            }
            if (this.f8076) {
                int i7 = this.f8092;
                int i8 = this.f8084;
                int i9 = i7 - i8;
                int i10 = this.f8091;
                int i11 = this.f8075;
                int i12 = i10 - (i11 / 2);
                this.f8086.setBounds(0, 0, i11, i8);
                this.f8099.setBounds(0, 0, this.f8082, this.f8094);
                canvas.translate(0.0f, (float) i9);
                this.f8099.draw(canvas);
                canvas.translate((float) i12, 0.0f);
                this.f8086.draw(canvas);
                canvas.translate((float) (-i12), (float) (-i9));
            }
        }
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public void m6125() {
        int i = this.f8089;
        if (i != 0) {
            if (i == 3) {
                this.f8088.cancel();
            } else {
                return;
            }
        }
        this.f8089 = 1;
        ValueAnimator valueAnimator = this.f8088;
        valueAnimator.setFloatValues(((Float) valueAnimator.getAnimatedValue()).floatValue(), 1.0f);
        this.f8088.setDuration(500L);
        this.f8088.setStartDelay(0);
        this.f8088.start();
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public final boolean m6126() {
        return C1729.m4511(this.f8078) == 1;
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6130(int i) {
        if (i == 2 && this.f8097 != 2) {
            this.f8074.setState(f8073);
            m6129();
        }
        if (i == 0) {
            this.f8078.invalidate();
        } else {
            m6125();
        }
        if (this.f8097 == 2 && i != 2) {
            this.f8074.setState(f8072);
            m6129();
            this.f8078.postDelayed(this.f8093, (long) InAppPurchaseEventManager.PURCHASE_STOP_QUERY_TIME_SEC);
        } else if (i == 1) {
            m6129();
            this.f8078.postDelayed(this.f8093, (long) 1500);
        }
        this.f8097 = i;
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6131(boolean z) {
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public boolean m6127(float f, float f2) {
        if (C1729.m4511(this.f8078) == 1) {
            if (f > ((float) (this.f8079 / 2))) {
                return false;
            }
        } else if (f < ((float) (this.f8082 - this.f8079))) {
            return false;
        }
        int i = this.f8090;
        int i2 = this.f8083 / 2;
        if (f2 < ((float) (i - i2)) || f2 > ((float) (i2 + i))) {
            return false;
        }
        return true;
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m6129() {
        this.f8078.removeCallbacks(this.f8093);
    }

    /* renamed from: K  reason: contains not printable characters */
    public final int m6128(float f, float f2, int[] iArr, int i, int i2, int i3) {
        int i4 = iArr[1] - iArr[0];
        if (i4 == 0) {
            return 0;
        }
        int i5 = i - i3;
        int i6 = (int) (((f2 - f) / ((float) i4)) * ((float) i5));
        int i7 = i2 + i6;
        if (i7 >= i5 || i7 < 0) {
            return 0;
        }
        return i6;
    }

    /* renamed from: K  reason: contains not printable characters */
    public boolean m6132(float f, float f2) {
        if (f2 >= ((float) (this.f8092 - this.f8084))) {
            int i = this.f8091;
            int i2 = this.f8075;
            return f >= ((float) (i - (i2 / 2))) && f <= ((float) ((i2 / 2) + i));
        }
    }
}
