package s;

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

/* JADX INFO: loaded from: classes.dex */
public final class d extends Drawable {

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public boolean f32628f = false;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public boolean f32629g = true;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public PorterDuff.Mode f32633k = PorterDuff.Mode.SRC_IN;

    public d(float f10, ColorStateList colorStateList) {
        this.f32623a = f10;
        Paint paint = new Paint(5);
        this.f32624b = paint;
        colorStateList = colorStateList == null ? ColorStateList.valueOf(0) : colorStateList;
        this.f32630h = colorStateList;
        paint.setColor(colorStateList.getColorForState(getState(), this.f32630h.getDefaultColor()));
        this.f32625c = new RectF();
        this.f32626d = new Rect();
    }

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

    public final void b(Rect rect) {
        if (rect == null) {
            rect = getBounds();
        }
        RectF rectF = this.f32625c;
        rectF.set(rect.left, rect.top, rect.right, rect.bottom);
        Rect rect2 = this.f32626d;
        rect2.set(rect);
        if (this.f32628f) {
            rect2.inset((int) Math.ceil(e.a(this.f32627e, this.f32623a, this.f32629g)), (int) Math.ceil(e.b(this.f32627e, this.f32623a, this.f32629g)));
            rectF.set(rect2);
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final void draw(Canvas canvas) {
        boolean z10;
        Paint paint = this.f32624b;
        if (this.f32631i == null || paint.getColorFilter() != null) {
            z10 = false;
        } else {
            paint.setColorFilter(this.f32631i);
            z10 = true;
        }
        RectF rectF = this.f32625c;
        float f10 = this.f32623a;
        canvas.drawRoundRect(rectF, f10, f10, paint);
        if (z10) {
            paint.setColorFilter(null);
        }
    }

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

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

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

    @Override // android.graphics.drawable.Drawable
    public final void onBoundsChange(Rect rect) {
        super.onBoundsChange(rect);
        b(rect);
    }

    @Override // android.graphics.drawable.Drawable
    public final boolean onStateChange(int[] iArr) {
        PorterDuff.Mode mode;
        ColorStateList colorStateList = this.f32630h;
        int colorForState = colorStateList.getColorForState(iArr, colorStateList.getDefaultColor());
        Paint paint = this.f32624b;
        boolean z10 = colorForState != paint.getColor();
        if (z10) {
            paint.setColor(colorForState);
        }
        ColorStateList colorStateList2 = this.f32632j;
        if (colorStateList2 == null || (mode = this.f32633k) == null) {
            return z10;
        }
        this.f32631i = a(colorStateList2, mode);
        return true;
    }

    @Override // android.graphics.drawable.Drawable
    public final void setAlpha(int i10) {
        this.f32624b.setAlpha(i10);
    }

    public void setColor(@Nullable ColorStateList colorStateList) {
        if (colorStateList == null) {
            colorStateList = ColorStateList.valueOf(0);
        }
        this.f32630h = colorStateList;
        this.f32624b.setColor(colorStateList.getColorForState(getState(), this.f32630h.getDefaultColor()));
        invalidateSelf();
    }

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

    @Override // android.graphics.drawable.Drawable
    public final void setTintList(ColorStateList colorStateList) {
        this.f32632j = colorStateList;
        this.f32631i = a(colorStateList, this.f32633k);
        invalidateSelf();
    }

    @Override // android.graphics.drawable.Drawable
    public final void setTintMode(PorterDuff.Mode mode) {
        this.f32633k = mode;
        this.f32631i = a(this.f32632j, mode);
        invalidateSelf();
    }
}
