package p028j;

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.widget.SeekBar;
import p001a0.C0012f;
import p007c.C0494j;
import p023h0.C0829h1;

/* renamed from: j.r0 */
/* loaded from: classes.dex */
public class C1189r0 extends C1137l0 {

    /* renamed from: d */
    public final SeekBar f2885d;

    /* renamed from: e */
    public Drawable f2886e;

    /* renamed from: f */
    public ColorStateList f2887f;

    /* renamed from: g */
    public PorterDuff.Mode f2888g;

    /* renamed from: h */
    public boolean f2889h;

    /* renamed from: i */
    public boolean f2890i;

    public C1189r0(SeekBar seekBar) {
        super(seekBar);
        this.f2887f = null;
        this.f2888g = null;
        this.f2889h = false;
        this.f2890i = false;
        this.f2885d = seekBar;
    }

    @Override // p028j.C1137l0
    /* renamed from: c */
    public void mo1902c(AttributeSet attributeSet, int i) {
        super.mo1902c(attributeSet, i);
        Context context = this.f2885d.getContext();
        int[] iArr = C0494j.f1773T;
        C1106g3 m2160u = C1106g3.m2160u(context, attributeSet, iArr, i, 0);
        SeekBar seekBar = this.f2885d;
        C0829h1.m2850M(seekBar, seekBar.getContext(), iArr, attributeSet, m2160u.m2164q(), i, 0);
        Drawable m2174g = m2160u.m2174g(C0494j.f1777U);
        if (m2174g != null) {
            this.f2885d.setThumb(m2174g);
        }
        m1897j(m2160u.m2175f(C0494j.f1781V));
        int i2 = C0494j.f1789X;
        if (m2160u.m2163r(i2)) {
            this.f2888g = C1115i2.m2115d(m2160u.m2171j(i2, -1), this.f2888g);
            this.f2890i = true;
        }
        int i3 = C0494j.f1785W;
        if (m2160u.m2163r(i3)) {
            this.f2887f = m2160u.m2178c(i3);
            this.f2889h = true;
        }
        m2160u.m2159v();
        m1901f();
    }

    /* renamed from: f */
    public final void m1901f() {
        Drawable drawable = this.f2886e;
        if (drawable != null) {
            if (this.f2889h || this.f2890i) {
                Drawable m5083p = C0012f.m5083p(drawable.mutate());
                this.f2886e = m5083p;
                if (this.f2889h) {
                    C0012f.m5085n(m5083p, this.f2887f);
                }
                if (this.f2890i) {
                    C0012f.m5084o(this.f2886e, this.f2888g);
                }
                if (this.f2886e.isStateful()) {
                    this.f2886e.setState(this.f2885d.getDrawableState());
                }
            }
        }
    }

    /* renamed from: g */
    public void m1900g(Canvas canvas) {
        if (this.f2886e != null) {
            int max = this.f2885d.getMax();
            if (max > 1) {
                int intrinsicWidth = this.f2886e.getIntrinsicWidth();
                int intrinsicHeight = this.f2886e.getIntrinsicHeight();
                int i = intrinsicWidth >= 0 ? intrinsicWidth / 2 : 1;
                int i2 = intrinsicHeight >= 0 ? intrinsicHeight / 2 : 1;
                this.f2886e.setBounds(-i, -i2, i, i2);
                float width = ((this.f2885d.getWidth() - this.f2885d.getPaddingLeft()) - this.f2885d.getPaddingRight()) / max;
                int save = canvas.save();
                canvas.translate(this.f2885d.getPaddingLeft(), this.f2885d.getHeight() / 2);
                for (int i3 = 0; i3 <= max; i3++) {
                    this.f2886e.draw(canvas);
                    canvas.translate(width, 0.0f);
                }
                canvas.restoreToCount(save);
            }
        }
    }

    /* renamed from: h */
    public void m1899h() {
        Drawable drawable = this.f2886e;
        if (drawable != null && drawable.isStateful() && drawable.setState(this.f2885d.getDrawableState())) {
            this.f2885d.invalidateDrawable(drawable);
        }
    }

    /* renamed from: i */
    public void m1898i() {
        Drawable drawable = this.f2886e;
        if (drawable != null) {
            drawable.jumpToCurrentState();
        }
    }

    /* renamed from: j */
    public void m1897j(Drawable drawable) {
        Drawable drawable2 = this.f2886e;
        if (drawable2 != null) {
            drawable2.setCallback(null);
        }
        this.f2886e = drawable;
        if (drawable != null) {
            drawable.setCallback(this.f2885d);
            C0012f.m5087l(drawable, C0829h1.m2816r(this.f2885d));
            if (drawable.isStateful()) {
                drawable.setState(this.f2885d.getDrawableState());
            }
            m1901f();
        }
        this.f2885d.invalidate();
    }
}