package o;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import com.google.android.gms.common.R;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.i8, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1458i8 extends C3040yr {
    public final C1362h8 p;
    public Drawable q;
    public ColorStateList r;
    public PorterDuff.Mode s;
    public boolean t;
    public boolean u;

    public C1458i8(C1362h8 c1362h8) {
        super(c1362h8);
        this.r = null;
        this.s = null;
        this.t = false;
        this.u = false;
        this.p = c1362h8;
    }

    @Override // o.C3040yr
    public final void g(AttributeSet attributeSet, int i) {
        super.g(attributeSet, R.attr.seekBarStyle);
        C1362h8 c1362h8 = this.p;
        Context context = c1362h8.getContext();
        int[] iArr = YZ.g;
        C70 c70R = C70.r(context, attributeSet, iArr, R.attr.seekBarStyle);
        TypedArray typedArray = (TypedArray) c70R.n;
        Oj0.l(c1362h8, c1362h8.getContext(), iArr, attributeSet, (TypedArray) c70R.n, R.attr.seekBarStyle);
        Drawable drawableN = c70R.n(0);
        if (drawableN != null) {
            c1362h8.setThumb(drawableN);
        }
        Drawable drawableM = c70R.m(1);
        Drawable drawable = this.q;
        if (drawable != null) {
            drawable.setCallback(null);
        }
        this.q = drawableM;
        if (drawableM != null) {
            drawableM.setCallback(c1362h8);
            drawableM.setLayoutDirection(c1362h8.getLayoutDirection());
            if (drawableM.isStateful()) {
                drawableM.setState(c1362h8.getDrawableState());
            }
            l();
        }
        c1362h8.invalidate();
        if (typedArray.hasValue(3)) {
            this.s = AbstractC2949xt.b(typedArray.getInt(3, -1), this.s);
            this.u = true;
        }
        if (typedArray.hasValue(2)) {
            this.r = c70R.l(2);
            this.t = true;
        }
        c70R.t();
        l();
    }

    public final void l() {
        Drawable drawable = this.q;
        if (drawable != null) {
            if (this.t || this.u) {
                Drawable drawableMutate = drawable.mutate();
                this.q = drawableMutate;
                if (this.t) {
                    drawableMutate.setTintList(this.r);
                }
                if (this.u) {
                    this.q.setTintMode(this.s);
                }
                if (this.q.isStateful()) {
                    this.q.setState(this.p.getDrawableState());
                }
            }
        }
    }

    public final void m(Canvas canvas) {
        if (this.q != null) {
            int max = this.p.getMax();
            if (max > 1) {
                int intrinsicWidth = this.q.getIntrinsicWidth();
                int intrinsicHeight = this.q.getIntrinsicHeight();
                int i = intrinsicWidth >= 0 ? intrinsicWidth / 2 : 1;
                int i2 = intrinsicHeight >= 0 ? intrinsicHeight / 2 : 1;
                this.q.setBounds(-i, -i2, i, i2);
                float width = ((r0.getWidth() - r0.getPaddingLeft()) - r0.getPaddingRight()) / max;
                int iSave = canvas.save();
                canvas.translate(r0.getPaddingLeft(), r0.getHeight() / 2);
                for (int i3 = 0; i3 <= max; i3++) {
                    this.q.draw(canvas);
                    canvas.translate(width, 0.0f);
                }
                canvas.restoreToCount(iSave);
            }
        }
    }
}
