package androidx.leanback.widget;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Property;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import p037.p091.C2073;
import p037.p091.C2074;
import p037.p091.C2075;
import p037.p091.C2083;

/* JADX INFO: loaded from: classes.dex */
public class PagingIndicator extends View {

    /* JADX INFO: renamed from: ޜ, reason: contains not printable characters */
    public static final TimeInterpolator f736 = new DecelerateInterpolator();

    /* JADX INFO: renamed from: ޝ, reason: contains not printable characters */
    public static final Property<C0116, Float> f737 = new C0113(Float.class, "alpha");

    /* JADX INFO: renamed from: ޞ, reason: contains not printable characters */
    public static final Property<C0116, Float> f738 = new C0114(Float.class, "diameter");

    /* JADX INFO: renamed from: ޟ, reason: contains not printable characters */
    public static final Property<C0116, Float> f739 = new C0115(Float.class, "translation_x");

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public boolean f740;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final int f741;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final int f742;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public final int f743;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public final int f744;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public final int f745;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public final int f746;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public final int f747;

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public C0116[] f748;

    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    public int[] f749;

    /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
    public int[] f750;

    /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
    public int[] f751;

    /* JADX INFO: renamed from: ޏ, reason: contains not printable characters */
    public int f752;

    /* JADX INFO: renamed from: ސ, reason: contains not printable characters */
    public int f753;

    /* JADX INFO: renamed from: ޑ, reason: contains not printable characters */
    public int f754;

    /* JADX INFO: renamed from: ޒ, reason: contains not printable characters */
    public int f755;

    /* JADX INFO: renamed from: ޓ, reason: contains not printable characters */
    public final Paint f756;

    /* JADX INFO: renamed from: ޔ, reason: contains not printable characters */
    public final Paint f757;

    /* JADX INFO: renamed from: ޕ, reason: contains not printable characters */
    public final AnimatorSet f758;

    /* JADX INFO: renamed from: ޖ, reason: contains not printable characters */
    public final AnimatorSet f759;

    /* JADX INFO: renamed from: ޗ, reason: contains not printable characters */
    public final AnimatorSet f760;

    /* JADX INFO: renamed from: ޘ, reason: contains not printable characters */
    public Bitmap f761;

    /* JADX INFO: renamed from: ޙ, reason: contains not printable characters */
    public Paint f762;

    /* JADX INFO: renamed from: ޚ, reason: contains not printable characters */
    public final Rect f763;

    /* JADX INFO: renamed from: ޛ, reason: contains not printable characters */
    public final float f764;

    /* JADX INFO: renamed from: androidx.leanback.widget.PagingIndicator$֏, reason: contains not printable characters */
    public static class C0113 extends Property<C0116, Float> {
        public C0113(Class cls, String str) {
            super(cls, str);
        }

        @Override // android.util.Property
        public Float get(C0116 c0116) {
            return Float.valueOf(c0116.f765);
        }

        @Override // android.util.Property
        public void set(C0116 c0116, Float f) {
            C0116 c01162 = c0116;
            c01162.f765 = f.floatValue();
            c01162.m290();
            PagingIndicator.this.invalidate();
        }
    }

    /* JADX INFO: renamed from: androidx.leanback.widget.PagingIndicator$ؠ, reason: contains not printable characters */
    public static class C0114 extends Property<C0116, Float> {
        public C0114(Class cls, String str) {
            super(cls, str);
        }

        @Override // android.util.Property
        public Float get(C0116 c0116) {
            return Float.valueOf(c0116.f769);
        }

        @Override // android.util.Property
        public void set(C0116 c0116, Float f) {
            C0116 c01162 = c0116;
            float fFloatValue = f.floatValue();
            c01162.f769 = fFloatValue;
            float f2 = fFloatValue / 2.0f;
            c01162.f770 = f2;
            PagingIndicator pagingIndicator = PagingIndicator.this;
            c01162.f771 = f2 * pagingIndicator.f764;
            pagingIndicator.invalidate();
        }
    }

    /* JADX INFO: renamed from: androidx.leanback.widget.PagingIndicator$ހ, reason: contains not printable characters */
    public static class C0115 extends Property<C0116, Float> {
        public C0115(Class cls, String str) {
            super(cls, str);
        }

        @Override // android.util.Property
        public Float get(C0116 c0116) {
            return Float.valueOf(c0116.f767);
        }

        @Override // android.util.Property
        public void set(C0116 c0116, Float f) {
            C0116 c01162 = c0116;
            c01162.f767 = f.floatValue() * c01162.f772 * c01162.f773;
            PagingIndicator.this.invalidate();
        }
    }

    /* JADX INFO: renamed from: androidx.leanback.widget.PagingIndicator$ށ, reason: contains not printable characters */
    public class C0116 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public float f765;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public int f766;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public float f767;

        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public float f768;

        /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
        public float f769;

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public float f770;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public float f771;

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public float f772 = 1.0f;

        /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
        public float f773;

        public C0116() {
            this.f773 = PagingIndicator.this.f740 ? 1.0f : -1.0f;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public void m290() {
            this.f766 = Color.argb(Math.round(this.f765 * 255.0f), Color.red(PagingIndicator.this.f755), Color.green(PagingIndicator.this.f755), Color.blue(PagingIndicator.this.f755));
        }

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public void m291() {
            this.f767 = 0.0f;
            this.f768 = 0.0f;
            PagingIndicator pagingIndicator = PagingIndicator.this;
            this.f769 = pagingIndicator.f741;
            float f = pagingIndicator.f742;
            this.f770 = f;
            this.f771 = f * pagingIndicator.f764;
            this.f765 = 0.0f;
            m290();
        }
    }

    public PagingIndicator(Context context) {
        this(context, null, 0);
    }

    public PagingIndicator(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public PagingIndicator(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.f760 = new AnimatorSet();
        Resources resources = getResources();
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, C2083.PagingIndicator, i, 0);
        if (Build.VERSION.SDK_INT >= 29) {
            saveAttributeDataForStyleable(context, C2083.PagingIndicator, attributeSet, typedArrayObtainStyledAttributes, i, 0);
        }
        int iM283 = m283(typedArrayObtainStyledAttributes, C2083.PagingIndicator_lbDotRadius, C2074.lb_page_indicator_dot_radius);
        this.f742 = iM283;
        this.f741 = iM283 * 2;
        int iM2832 = m283(typedArrayObtainStyledAttributes, C2083.PagingIndicator_arrowRadius, C2074.lb_page_indicator_arrow_radius);
        this.f745 = iM2832;
        this.f744 = iM2832 * 2;
        this.f743 = m283(typedArrayObtainStyledAttributes, C2083.PagingIndicator_dotToDotGap, C2074.lb_page_indicator_dot_gap);
        this.f746 = m283(typedArrayObtainStyledAttributes, C2083.PagingIndicator_dotToArrowGap, C2074.lb_page_indicator_arrow_gap);
        int color = typedArrayObtainStyledAttributes.getColor(C2083.PagingIndicator_dotBgColor, getResources().getColor(C2073.lb_page_indicator_dot));
        Paint paint = new Paint(1);
        this.f756 = paint;
        paint.setColor(color);
        this.f755 = typedArrayObtainStyledAttributes.getColor(C2083.PagingIndicator_arrowBgColor, getResources().getColor(C2073.lb_page_indicator_arrow_background));
        if (this.f762 == null && typedArrayObtainStyledAttributes.hasValue(C2083.PagingIndicator_arrowColor)) {
            setArrowColor(typedArrayObtainStyledAttributes.getColor(C2083.PagingIndicator_arrowColor, 0));
        }
        typedArrayObtainStyledAttributes.recycle();
        this.f740 = resources.getConfiguration().getLayoutDirection() == 0;
        int color2 = resources.getColor(C2073.lb_page_indicator_arrow_shadow);
        this.f747 = resources.getDimensionPixelSize(C2074.lb_page_indicator_arrow_shadow_radius);
        this.f757 = new Paint(1);
        float dimensionPixelSize = resources.getDimensionPixelSize(C2074.lb_page_indicator_arrow_shadow_offset);
        this.f757.setShadowLayer(this.f747, dimensionPixelSize, dimensionPixelSize, color2);
        this.f761 = m289();
        this.f763 = new Rect(0, 0, this.f761.getWidth(), this.f761.getHeight());
        this.f764 = this.f761.getWidth() / this.f744;
        AnimatorSet animatorSet = new AnimatorSet();
        this.f758 = animatorSet;
        animatorSet.playTogether(m284(0.0f, 1.0f), m286(this.f742 * 2, this.f745 * 2), m288());
        AnimatorSet animatorSet2 = new AnimatorSet();
        this.f759 = animatorSet2;
        animatorSet2.playTogether(m284(1.0f, 0.0f), m286(this.f745 * 2, this.f742 * 2), m288());
        this.f760.playTogether(this.f758, this.f759);
        setLayerType(1, null);
    }

    private int getDesiredHeight() {
        return getPaddingBottom() + getPaddingTop() + this.f744 + this.f747;
    }

    private int getDesiredWidth() {
        return getPaddingRight() + getPaddingLeft() + getRequiredWidth();
    }

    private int getRequiredWidth() {
        return ((this.f753 - 3) * this.f743) + (this.f746 * 2) + (this.f742 * 2);
    }

    private void setSelectedPage(int i) {
        if (i == this.f754) {
            return;
        }
        this.f754 = i;
        m285();
    }

    public int[] getDotSelectedLeftX() {
        return this.f750;
    }

    public int[] getDotSelectedRightX() {
        return this.f751;
    }

    public int[] getDotSelectedX() {
        return this.f749;
    }

    public int getPageCount() {
        return this.f753;
    }

    @Override // android.view.View
    public void onDraw(Canvas canvas) {
        for (int i = 0; i < this.f753; i++) {
            C0116 c0116 = this.f748[i];
            float f = c0116.f768 + c0116.f767;
            canvas.drawCircle(f, r3.f752, c0116.f770, PagingIndicator.this.f756);
            if (c0116.f765 > 0.0f) {
                PagingIndicator.this.f757.setColor(c0116.f766);
                canvas.drawCircle(f, r3.f752, c0116.f770, PagingIndicator.this.f757);
                PagingIndicator pagingIndicator = PagingIndicator.this;
                Bitmap bitmap = pagingIndicator.f761;
                Rect rect = pagingIndicator.f763;
                float f2 = c0116.f771;
                float f3 = PagingIndicator.this.f752;
                canvas.drawBitmap(bitmap, rect, new Rect((int) (f - f2), (int) (f3 - f2), (int) (f + f2), (int) (f3 + f2)), PagingIndicator.this.f762);
            }
        }
    }

    @Override // android.view.View
    public void onMeasure(int i, int i2) {
        int desiredHeight = getDesiredHeight();
        int mode = View.MeasureSpec.getMode(i2);
        if (mode == Integer.MIN_VALUE) {
            desiredHeight = Math.min(desiredHeight, View.MeasureSpec.getSize(i2));
        } else if (mode == 1073741824) {
            desiredHeight = View.MeasureSpec.getSize(i2);
        }
        int desiredWidth = getDesiredWidth();
        int mode2 = View.MeasureSpec.getMode(i);
        if (mode2 == Integer.MIN_VALUE) {
            desiredWidth = Math.min(desiredWidth, View.MeasureSpec.getSize(i));
        } else if (mode2 == 1073741824) {
            desiredWidth = View.MeasureSpec.getSize(i);
        }
        setMeasuredDimension(desiredWidth, desiredHeight);
    }

    @Override // android.view.View
    public void onRtlPropertiesChanged(int i) {
        super.onRtlPropertiesChanged(i);
        boolean z = i == 0;
        if (this.f740 != z) {
            this.f740 = z;
            this.f761 = m289();
            C0116[] c0116Arr = this.f748;
            if (c0116Arr != null) {
                for (C0116 c0116 : c0116Arr) {
                    c0116.f773 = PagingIndicator.this.f740 ? 1.0f : -1.0f;
                }
            }
            m287();
            invalidate();
        }
    }

    @Override // android.view.View
    public void onSizeChanged(int i, int i2, int i3, int i4) {
        setMeasuredDimension(i, i2);
        m287();
    }

    public void setArrowBackgroundColor(int i) {
        this.f755 = i;
    }

    public void setArrowColor(int i) {
        if (this.f762 == null) {
            this.f762 = new Paint();
        }
        this.f762.setColorFilter(new PorterDuffColorFilter(i, PorterDuff.Mode.SRC_IN));
    }

    public void setDotBackgroundColor(int i) {
        this.f756.setColor(i);
    }

    public void setPageCount(int i) {
        if (i <= 0) {
            throw new IllegalArgumentException("The page count should be a positive integer");
        }
        this.f753 = i;
        this.f748 = new C0116[i];
        for (int i2 = 0; i2 < this.f753; i2++) {
            this.f748[i2] = new C0116();
        }
        m287();
        setSelectedPage(0);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final int m283(TypedArray typedArray, int i, int i2) {
        return typedArray.getDimensionPixelOffset(i, getResources().getDimensionPixelOffset(i2));
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Animator m284(float f, float f2) {
        ObjectAnimator objectAnimatorOfFloat = ObjectAnimator.ofFloat((Object) null, f737, f, f2);
        objectAnimatorOfFloat.setDuration(167L);
        objectAnimatorOfFloat.setInterpolator(f736);
        return objectAnimatorOfFloat;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m285() {
        int i;
        int i2 = 0;
        while (true) {
            i = this.f754;
            if (i2 >= i) {
                break;
            }
            this.f748[i2].m291();
            C0116 c0116 = this.f748[i2];
            if (i2 != 0) {
                f = 1.0f;
            }
            c0116.f772 = f;
            this.f748[i2].f768 = this.f750[i2];
            i2++;
        }
        C0116 c01162 = this.f748[i];
        c01162.f767 = 0.0f;
        c01162.f768 = 0.0f;
        PagingIndicator pagingIndicator = PagingIndicator.this;
        c01162.f769 = pagingIndicator.f744;
        float f = pagingIndicator.f745;
        c01162.f770 = f;
        c01162.f771 = f * pagingIndicator.f764;
        c01162.f765 = 1.0f;
        c01162.m290();
        C0116[] c0116Arr = this.f748;
        int i3 = this.f754;
        c0116Arr[i3].f772 = i3 <= 0 ? 1.0f : -1.0f;
        C0116[] c0116Arr2 = this.f748;
        int i4 = this.f754;
        c0116Arr2[i4].f768 = this.f749[i4];
        while (true) {
            i4++;
            if (i4 >= this.f753) {
                return;
            }
            this.f748[i4].m291();
            C0116[] c0116Arr3 = this.f748;
            c0116Arr3[i4].f772 = 1.0f;
            c0116Arr3[i4].f768 = this.f751[i4];
        }
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final Animator m286(float f, float f2) {
        ObjectAnimator objectAnimatorOfFloat = ObjectAnimator.ofFloat((Object) null, f738, f, f2);
        objectAnimatorOfFloat.setDuration(417L);
        objectAnimatorOfFloat.setInterpolator(f736);
        return objectAnimatorOfFloat;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final void m287() {
        int paddingLeft = getPaddingLeft();
        int paddingTop = getPaddingTop();
        int width = getWidth() - getPaddingRight();
        int requiredWidth = getRequiredWidth();
        int i = (paddingLeft + width) / 2;
        int i2 = this.f753;
        int[] iArr = new int[i2];
        this.f749 = iArr;
        int[] iArr2 = new int[i2];
        this.f750 = iArr2;
        int[] iArr3 = new int[i2];
        this.f751 = iArr3;
        int i3 = 1;
        if (this.f740) {
            int i4 = i - (requiredWidth / 2);
            int i5 = this.f742;
            int i6 = this.f743;
            int i7 = this.f746;
            iArr[0] = ((i4 + i5) - i6) + i7;
            iArr2[0] = i4 + i5;
            iArr3[0] = (i7 * 2) + ((i4 + i5) - (i6 * 2));
            while (i3 < this.f753) {
                int[] iArr4 = this.f749;
                int[] iArr5 = this.f750;
                int i8 = i3 - 1;
                int i9 = iArr5[i8];
                int i10 = this.f746;
                iArr4[i3] = i9 + i10;
                iArr5[i3] = iArr5[i8] + this.f743;
                this.f751[i3] = iArr4[i8] + i10;
                i3++;
            }
        } else {
            int i11 = (requiredWidth / 2) + i;
            int i12 = this.f742;
            int i13 = this.f743;
            int i14 = this.f746;
            iArr[0] = ((i11 - i12) + i13) - i14;
            iArr2[0] = i11 - i12;
            iArr3[0] = ((i13 * 2) + (i11 - i12)) - (i14 * 2);
            while (i3 < this.f753) {
                int[] iArr6 = this.f749;
                int[] iArr7 = this.f750;
                int i15 = i3 - 1;
                int i16 = iArr7[i15];
                int i17 = this.f746;
                iArr6[i3] = i16 - i17;
                iArr7[i3] = iArr7[i15] - this.f743;
                this.f751[i3] = iArr6[i15] - i17;
                i3++;
            }
        }
        this.f752 = paddingTop + this.f745;
        m285();
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final Animator m288() {
        ObjectAnimator objectAnimatorOfFloat = ObjectAnimator.ofFloat((Object) null, f739, (-this.f746) + this.f743, 0.0f);
        objectAnimatorOfFloat.setDuration(417L);
        objectAnimatorOfFloat.setInterpolator(f736);
        return objectAnimatorOfFloat;
    }

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final Bitmap m289() {
        Bitmap bitmapDecodeResource = BitmapFactory.decodeResource(getResources(), C2075.lb_ic_nav_arrow);
        if (this.f740) {
            return bitmapDecodeResource;
        }
        Matrix matrix = new Matrix();
        matrix.preScale(-1.0f, 1.0f);
        return Bitmap.createBitmap(bitmapDecodeResource, 0, 0, bitmapDecodeResource.getWidth(), bitmapDecodeResource.getHeight(), matrix, false);
    }
}
