package l;

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 android.widget.SeekBar;
import androidx.annotation.Nullable;

/* JADX INFO: loaded from: classes.dex */
public final class l0 extends i0 {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final SeekBar f29752d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public Drawable f29753e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public ColorStateList f29754f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public PorterDuff.Mode f29755g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public boolean f29756h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public boolean f29757i;

    public l0(SeekBar seekBar) {
        super(seekBar);
        this.f29754f = null;
        this.f29755g = null;
        this.f29756h = false;
        this.f29757i = false;
        this.f29752d = seekBar;
    }

    @Override // l.i0
    public final void a(AttributeSet attributeSet, int i10) {
        super.a(attributeSet, i10);
        SeekBar seekBar = this.f29752d;
        Context context = seekBar.getContext();
        int[] iArr = d.j.AppCompatSeekBar;
        p3 p3VarD = p3.d(context, attributeSet, iArr, i10);
        androidx.core.view.s1.saveAttributeDataForStyleable(seekBar, seekBar.getContext(), iArr, attributeSet, p3VarD.f29809b, i10, 0);
        Drawable drawableC = p3VarD.c(d.j.AppCompatSeekBar_android_thumb);
        if (drawableC != null) {
            seekBar.setThumb(drawableC);
        }
        setTickMark(p3VarD.b(d.j.AppCompatSeekBar_tickMark));
        int i11 = d.j.AppCompatSeekBar_tickMarkTintMode;
        TypedArray typedArray = p3VarD.f29809b;
        if (typedArray.hasValue(i11)) {
            this.f29755g = p1.c(typedArray.getInt(i11, -1), this.f29755g);
            this.f29757i = true;
        }
        int i12 = d.j.AppCompatSeekBar_tickMarkTint;
        if (typedArray.hasValue(i12)) {
            this.f29754f = p3VarD.a(i12);
            this.f29756h = true;
        }
        p3VarD.e();
        c();
    }

    public final void c() {
        Drawable drawable = this.f29753e;
        if (drawable != null) {
            if (this.f29756h || this.f29757i) {
                Drawable drawableMutate = drawable.mutate();
                this.f29753e = drawableMutate;
                if (this.f29756h) {
                    k0.a.setTintList(drawableMutate, this.f29754f);
                }
                if (this.f29757i) {
                    k0.a.setTintMode(this.f29753e, this.f29755g);
                }
                if (this.f29753e.isStateful()) {
                    this.f29753e.setState(this.f29752d.getDrawableState());
                }
            }
        }
    }

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

    @Nullable
    public Drawable getTickMark() {
        return this.f29753e;
    }

    @Nullable
    public ColorStateList getTickMarkTintList() {
        return this.f29754f;
    }

    @Nullable
    public PorterDuff.Mode getTickMarkTintMode() {
        return this.f29755g;
    }

    public void setTickMark(@Nullable Drawable drawable) {
        Drawable drawable2 = this.f29753e;
        if (drawable2 != null) {
            drawable2.setCallback(null);
        }
        this.f29753e = drawable;
        SeekBar seekBar = this.f29752d;
        if (drawable != null) {
            drawable.setCallback(seekBar);
            drawable.setLayoutDirection(seekBar.getLayoutDirection());
            if (drawable.isStateful()) {
                drawable.setState(seekBar.getDrawableState());
            }
            c();
        }
        seekBar.invalidate();
    }

    public void setTickMarkTintList(@Nullable ColorStateList colorStateList) {
        this.f29754f = colorStateList;
        this.f29756h = true;
        c();
    }

    public void setTickMarkTintMode(@Nullable PorterDuff.Mode mode) {
        this.f29755g = mode;
        this.f29757i = true;
        c();
    }
}
