package i;

import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;

/* JADX INFO: compiled from: RoundRectDrawable.java */
/* JADX INFO: loaded from: classes.dex */
class g extends Drawable {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private float f4825a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final Paint f4826b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private final RectF f4827c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private final Rect f4828d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private float f4829e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private boolean f4830f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private boolean f4831g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private ColorStateList f4832h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private PorterDuffColorFilter f4833i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private ColorStateList f4834j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private PorterDuff.Mode f4835k;

    private PorterDuffColorFilter a(ColorStateList colorStateList, PorterDuff.Mode mode) {
        if (colorStateList == null || mode == null) {
            return null;
        }
        return new PorterDuffColorFilter(colorStateList.getColorForState(getState(), 0), mode);
    }

    private void e(ColorStateList colorStateList) {
        if (colorStateList == null) {
            colorStateList = ColorStateList.valueOf(0);
        }
        this.f4832h = colorStateList;
        this.f4826b.setColor(colorStateList.getColorForState(getState(), this.f4832h.getDefaultColor()));
    }

    private void i(Rect rect) {
        if (rect == null) {
            rect = getBounds();
        }
        this.f4827c.set(rect.left, rect.top, rect.right, rect.bottom);
        this.f4828d.set(rect);
        if (this.f4830f) {
            this.f4828d.inset((int) Math.ceil(h.c(this.f4829e, this.f4825a, this.f4831g)), (int) Math.ceil(h.d(this.f4829e, this.f4825a, this.f4831g)));
            this.f4827c.set(this.f4828d);
        }
    }

    public ColorStateList b() {
        return this.f4832h;
    }

    float c() {
        return this.f4829e;
    }

    public float d() {
        return this.f4825a;
    }

    @Override // android.graphics.drawable.Drawable
    public void draw(Canvas canvas) {
        boolean z2;
        Paint paint = this.f4826b;
        if (this.f4833i == null || paint.getColorFilter() != null) {
            z2 = false;
        } else {
            paint.setColorFilter(this.f4833i);
            z2 = true;
        }
        RectF rectF = this.f4827c;
        float f3 = this.f4825a;
        canvas.drawRoundRect(rectF, f3, f3, paint);
        if (z2) {
            paint.setColorFilter(null);
        }
    }

    public void f(ColorStateList colorStateList) {
        e(colorStateList);
        invalidateSelf();
    }

    void g(float f3, boolean z2, boolean z3) {
        if (f3 == this.f4829e && this.f4830f == z2 && this.f4831g == z3) {
            return;
        }
        this.f4829e = f3;
        this.f4830f = z2;
        this.f4831g = z3;
        i(null);
        invalidateSelf();
    }

    @Override // android.graphics.drawable.Drawable
    public int getOpacity() {
        return -3;
    }

    @Override // android.graphics.drawable.Drawable
    public void getOutline(Outline outline) {
        outline.setRoundRect(this.f4828d, this.f4825a);
    }

    void h(float f3) {
        if (f3 == this.f4825a) {
            return;
        }
        this.f4825a = f3;
        i(null);
        invalidateSelf();
    }

    @Override // android.graphics.drawable.Drawable
    public boolean isStateful() {
        ColorStateList colorStateList;
        ColorStateList colorStateList2 = this.f4834j;
        return (colorStateList2 != null && colorStateList2.isStateful()) || ((colorStateList = this.f4832h) != null && colorStateList.isStateful()) || super.isStateful();
    }

    @Override // android.graphics.drawable.Drawable
    protected void onBoundsChange(Rect rect) {
        super.onBoundsChange(rect);
        i(rect);
    }

    @Override // android.graphics.drawable.Drawable
    protected boolean onStateChange(int[] iArr) {
        PorterDuff.Mode mode;
        ColorStateList colorStateList = this.f4832h;
        int colorForState = colorStateList.getColorForState(iArr, colorStateList.getDefaultColor());
        boolean z2 = colorForState != this.f4826b.getColor();
        if (z2) {
            this.f4826b.setColor(colorForState);
        }
        ColorStateList colorStateList2 = this.f4834j;
        if (colorStateList2 == null || (mode = this.f4835k) == null) {
            return z2;
        }
        this.f4833i = a(colorStateList2, mode);
        return true;
    }

    @Override // android.graphics.drawable.Drawable
    public void setAlpha(int i3) {
        this.f4826b.setAlpha(i3);
    }

    @Override // android.graphics.drawable.Drawable
    public void setColorFilter(ColorFilter colorFilter) {
        this.f4826b.setColorFilter(colorFilter);
    }

    @Override // android.graphics.drawable.Drawable
    public void setTintList(ColorStateList colorStateList) {
        this.f4834j = colorStateList;
        this.f4833i = a(colorStateList, this.f4835k);
        invalidateSelf();
    }

    @Override // android.graphics.drawable.Drawable
    public void setTintMode(PorterDuff.Mode mode) {
        this.f4835k = mode;
        this.f4833i = a(this.f4834j, mode);
        invalidateSelf();
    }
}
