package c.b.f;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.SeekBar;
import c.f.j.a0;
import java.util.WeakHashMap;

/* JADX INFO: compiled from: AppCompatSeekBarHelper.java */
/* JADX INFO: loaded from: classes.dex */
public class a0 extends v {

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

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

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

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

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

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

    public a0(SeekBar seekBar) {
        super(seekBar);
        this.f772f = null;
        this.f773g = null;
        this.f774h = false;
        this.f775i = false;
        this.f770d = seekBar;
    }

    @Override // c.b.f.v
    public void a(AttributeSet attributeSet, int i2) {
        super.a(attributeSet, i2);
        Context context = this.f770d.getContext();
        int[] iArr = c.b.b.f538g;
        d1 d1VarO = d1.o(context, attributeSet, iArr, i2, 0);
        SeekBar seekBar = this.f770d;
        c.f.j.a0.k(seekBar, seekBar.getContext(), iArr, attributeSet, d1VarO.f806b, i2, 0);
        Drawable drawableF = d1VarO.f(0);
        if (drawableF != null) {
            this.f770d.setThumb(drawableF);
        }
        Drawable drawableE = d1VarO.e(1);
        Drawable drawable = this.f771e;
        if (drawable != null) {
            drawable.setCallback(null);
        }
        this.f771e = drawableE;
        if (drawableE != null) {
            drawableE.setCallback(this.f770d);
            SeekBar seekBar2 = this.f770d;
            WeakHashMap<View, c.f.j.i0> weakHashMap = c.f.j.a0.a;
            c.f.d.l.c.b(drawableE, a0.e.d(seekBar2));
            if (drawableE.isStateful()) {
                drawableE.setState(this.f770d.getDrawableState());
            }
            c();
        }
        this.f770d.invalidate();
        if (d1VarO.m(3)) {
            this.f773g = k0.c(d1VarO.h(3, -1), this.f773g);
            this.f775i = true;
        }
        if (d1VarO.m(2)) {
            this.f772f = d1VarO.b(2);
            this.f774h = true;
        }
        d1VarO.f806b.recycle();
        c();
    }

    public final void c() {
        Drawable drawable = this.f771e;
        if (drawable != null) {
            if (this.f774h || this.f775i) {
                Drawable drawableMutate = drawable.mutate();
                this.f771e = drawableMutate;
                if (this.f774h) {
                    c.f.d.l.b.h(drawableMutate, this.f772f);
                }
                if (this.f775i) {
                    c.f.d.l.b.i(this.f771e, this.f773g);
                }
                if (this.f771e.isStateful()) {
                    this.f771e.setState(this.f770d.getDrawableState());
                }
            }
        }
    }

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