package com.google.android.material.card;

import android.R;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.Checkable;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.DimenRes;
import androidx.annotation.Dimension;
import androidx.annotation.DrawableRes;
import androidx.annotation.FloatRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.cardview.widget.CardView;
import com.bumptech.glide.f;
import com.google.android.material.internal.q0;
import com.google.android.material.shape.g0;
import com.google.android.material.shape.s;
import d9.d;
import f.a;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import x8.c;
import x8.l;
import x8.m;

/* JADX INFO: loaded from: classes2.dex */
public class MaterialCardView extends CardView implements Checkable, g0 {

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

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

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

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

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public static final int[] f22390l = {R.attr.state_checkable};

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public static final int[] f22391m = {R.attr.state_checked};
    public static final int[] Q = {c.state_dragged};
    public static final int R = l.Widget_MaterialComponents_CardView;

    @Retention(RetentionPolicy.SOURCE)
    public @interface CheckedIconGravity {
    }

    public MaterialCardView(Context context) {
        this(context, null);
    }

    @NonNull
    private RectF getBoundsAsRectF() {
        RectF rectF = new RectF();
        rectF.set(this.f22392h.f25052c.getBounds());
        return rectF;
    }

    public final void f(int i10, int i11, int i12, int i13) {
        super.setContentPadding(i10, i11, i12, i13);
    }

    @Override // androidx.cardview.widget.CardView
    @NonNull
    public ColorStateList getCardBackgroundColor() {
        return this.f22392h.f25052c.getFillColor();
    }

    @NonNull
    public ColorStateList getCardForegroundColor() {
        return this.f22392h.f25053d.getFillColor();
    }

    public float getCardViewRadius() {
        return super.getRadius();
    }

    @Nullable
    public Drawable getCheckedIcon() {
        return this.f22392h.getCheckedIcon();
    }

    public int getCheckedIconGravity() {
        return this.f22392h.f25056g;
    }

    @Dimension
    public int getCheckedIconMargin() {
        return this.f22392h.f25054e;
    }

    @Dimension
    public int getCheckedIconSize() {
        return this.f22392h.f25055f;
    }

    @Nullable
    public ColorStateList getCheckedIconTint() {
        return this.f22392h.getCheckedIconTint();
    }

    @Override // androidx.cardview.widget.CardView
    public int getContentPaddingBottom() {
        return this.f22392h.f25051b.bottom;
    }

    @Override // androidx.cardview.widget.CardView
    public int getContentPaddingLeft() {
        return this.f22392h.f25051b.left;
    }

    @Override // androidx.cardview.widget.CardView
    public int getContentPaddingRight() {
        return this.f22392h.f25051b.right;
    }

    @Override // androidx.cardview.widget.CardView
    public int getContentPaddingTop() {
        return this.f22392h.f25051b.top;
    }

    @FloatRange(from = 0.0d, to = 1.0d)
    public float getProgress() {
        return this.f22392h.f25052c.f23095b.f23070c;
    }

    @Override // androidx.cardview.widget.CardView
    public float getRadius() {
        return this.f22392h.f25052c.p();
    }

    public ColorStateList getRippleColor() {
        return this.f22392h.getRippleColor();
    }

    @NonNull
    public s getShapeAppearanceModel() {
        return this.f22392h.f();
    }

    @ColorInt
    @Deprecated
    public int getStrokeColor() {
        return this.f22392h.g();
    }

    @Nullable
    public ColorStateList getStrokeColorStateList() {
        return this.f22392h.getStrokeColorStateList();
    }

    @Dimension
    public int getStrokeWidth() {
        return this.f22392h.f25057h;
    }

    @Override // android.widget.Checkable
    public final boolean isChecked() {
        return this.f22394j;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onAttachedToWindow() {
        super.onAttachedToWindow();
        d dVar = this.f22392h;
        dVar.r();
        f.v(this, dVar.f25052c);
    }

    @Override // android.view.ViewGroup, android.view.View
    public final int[] onCreateDrawableState(int i10) {
        int[] iArrOnCreateDrawableState = super.onCreateDrawableState(i10 + 3);
        d dVar = this.f22392h;
        if (dVar != null && dVar.f25059j) {
            View.mergeDrawableStates(iArrOnCreateDrawableState, f22390l);
        }
        if (isChecked()) {
            View.mergeDrawableStates(iArrOnCreateDrawableState, f22391m);
        }
        if (this.f22395k) {
            View.mergeDrawableStates(iArrOnCreateDrawableState, Q);
        }
        return iArrOnCreateDrawableState;
    }

    @Override // android.view.View
    public final void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
        super.onInitializeAccessibilityEvent(accessibilityEvent);
        accessibilityEvent.setClassName("androidx.cardview.widget.CardView");
        accessibilityEvent.setChecked(isChecked());
    }

    @Override // android.view.View
    public final void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
        super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
        accessibilityNodeInfo.setClassName("androidx.cardview.widget.CardView");
        d dVar = this.f22392h;
        accessibilityNodeInfo.setCheckable(dVar != null && dVar.f25059j);
        accessibilityNodeInfo.setClickable(isClickable());
        accessibilityNodeInfo.setChecked(isChecked());
    }

    @Override // androidx.cardview.widget.CardView, android.widget.FrameLayout, android.view.View
    public final void onMeasure(int i10, int i11) {
        super.onMeasure(i10, i11);
        this.f22392h.j(getMeasuredWidth(), getMeasuredHeight());
    }

    @Override // android.view.View
    public void setBackground(Drawable drawable) {
        setBackgroundDrawable(drawable);
    }

    @Override // android.view.View
    public void setBackgroundDrawable(Drawable drawable) {
        if (this.f22393i) {
            d dVar = this.f22392h;
            if (!dVar.f25058i) {
                dVar.f25058i = true;
            }
            super.setBackgroundDrawable(drawable);
        }
    }

    public void setBackgroundInternal(Drawable drawable) {
        super.setBackgroundDrawable(drawable);
    }

    @Override // androidx.cardview.widget.CardView
    public void setCardBackgroundColor(@Nullable ColorStateList colorStateList) {
        this.f22392h.f25052c.setFillColor(colorStateList);
    }

    @Override // androidx.cardview.widget.CardView
    public void setCardElevation(float f10) {
        super.setCardElevation(f10);
        d dVar = this.f22392h;
        dVar.f25052c.w(dVar.f25050a.getCardElevation());
    }

    public void setCardForegroundColor(@Nullable ColorStateList colorStateList) {
        this.f22392h.setCardForegroundColor(colorStateList);
    }

    public void setCheckable(boolean z10) {
        this.f22392h.f25059j = z10;
    }

    @Override // android.widget.Checkable
    public void setChecked(boolean z10) {
        if (this.f22394j != z10) {
            toggle();
        }
    }

    public void setCheckedIcon(@Nullable Drawable drawable) {
        this.f22392h.setCheckedIcon(drawable);
    }

    public void setCheckedIconGravity(int i10) {
        d dVar = this.f22392h;
        if (dVar.f25056g != i10) {
            dVar.f25056g = i10;
            MaterialCardView materialCardView = dVar.f25050a;
            dVar.j(materialCardView.getMeasuredWidth(), materialCardView.getMeasuredHeight());
        }
    }

    public void setCheckedIconMargin(@Dimension int i10) {
        this.f22392h.f25054e = i10;
    }

    public void setCheckedIconMarginResource(@DimenRes int i10) {
        if (i10 != -1) {
            this.f22392h.f25054e = getResources().getDimensionPixelSize(i10);
        }
    }

    public void setCheckedIconResource(@DrawableRes int i10) {
        this.f22392h.setCheckedIcon(a.getDrawable(getContext(), i10));
    }

    public void setCheckedIconSize(@Dimension int i10) {
        this.f22392h.f25055f = i10;
    }

    public void setCheckedIconSizeResource(@DimenRes int i10) {
        if (i10 != 0) {
            this.f22392h.f25055f = getResources().getDimensionPixelSize(i10);
        }
    }

    public void setCheckedIconTint(@Nullable ColorStateList colorStateList) {
        this.f22392h.setCheckedIconTint(colorStateList);
    }

    @Override // android.view.View
    public void setClickable(boolean z10) {
        super.setClickable(z10);
        d dVar = this.f22392h;
        if (dVar != null) {
            dVar.r();
        }
    }

    @Override // androidx.cardview.widget.CardView
    public void setContentPadding(int i10, int i11, int i12, int i13) {
        d dVar = this.f22392h;
        dVar.f25051b.set(i10, i11, i12, i13);
        dVar.s();
    }

    public void setDragged(boolean z10) {
        if (this.f22395k != z10) {
            this.f22395k = z10;
            refreshDrawableState();
            if (Build.VERSION.SDK_INT > 26) {
                this.f22392h.d();
            }
            invalidate();
        }
    }

    @Override // androidx.cardview.widget.CardView
    public void setMaxCardElevation(float f10) {
        super.setMaxCardElevation(f10);
        this.f22392h.t();
    }

    public void setOnCheckedChangeListener(@Nullable d9.a aVar) {
    }

    @Override // androidx.cardview.widget.CardView
    public void setPreventCornerOverlap(boolean z10) {
        super.setPreventCornerOverlap(z10);
        d dVar = this.f22392h;
        dVar.t();
        dVar.s();
    }

    public void setProgress(@FloatRange(from = 0.0d, to = 1.0d) float f10) {
        this.f22392h.m(f10);
    }

    @Override // androidx.cardview.widget.CardView
    public void setRadius(float f10) {
        super.setRadius(f10);
        this.f22392h.l(f10);
    }

    public void setRippleColor(@Nullable ColorStateList colorStateList) {
        this.f22392h.setRippleColor(colorStateList);
    }

    public void setRippleColorResource(@ColorRes int i10) {
        this.f22392h.setRippleColor(g0.d.getColorStateList(getContext(), i10));
    }

    @Override // com.google.android.material.shape.g0
    public void setShapeAppearanceModel(@NonNull s sVar) {
        setClipToOutline(sVar.g(getBoundsAsRectF()));
        this.f22392h.n(sVar);
    }

    public void setStrokeColor(@ColorInt int i10) {
        setStrokeColor(ColorStateList.valueOf(i10));
    }

    public void setStrokeWidth(@Dimension int i10) {
        d dVar = this.f22392h;
        if (i10 != dVar.f25057h) {
            dVar.f25057h = i10;
            dVar.u();
        }
        invalidate();
    }

    @Override // androidx.cardview.widget.CardView
    public void setUseCompatPadding(boolean z10) {
        super.setUseCompatPadding(z10);
        d dVar = this.f22392h;
        dVar.t();
        dVar.s();
    }

    @Override // android.widget.Checkable
    public final void toggle() {
        d dVar = this.f22392h;
        if (dVar != null && dVar.f25059j && isEnabled()) {
            this.f22394j = !this.f22394j;
            refreshDrawableState();
            if (Build.VERSION.SDK_INT > 26) {
                dVar.d();
            }
            dVar.k(this.f22394j, true);
        }
    }

    public MaterialCardView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, c.materialCardViewStyle);
    }

    public void setStrokeColor(ColorStateList colorStateList) {
        this.f22392h.o(colorStateList);
        invalidate();
    }

    /* JADX WARN: Illegal instructions before constructor call */
    public MaterialCardView(Context context, AttributeSet attributeSet, int i10) {
        int i11 = R;
        super(x9.a.wrap(context, attributeSet, i10, i11), attributeSet, i10);
        this.f22394j = false;
        this.f22395k = false;
        this.f22393i = true;
        TypedArray typedArrayC = q0.c(getContext(), attributeSet, m.MaterialCardView, i10, i11, new int[0]);
        d dVar = new d(this, attributeSet, i10);
        this.f22392h = dVar;
        dVar.f25052c.setFillColor(super.getCardBackgroundColor());
        dVar.f25051b.set(super.getContentPaddingLeft(), super.getContentPaddingTop(), super.getContentPaddingRight(), super.getContentPaddingBottom());
        dVar.s();
        dVar.i(typedArrayC);
        typedArrayC.recycle();
    }

    @Override // androidx.cardview.widget.CardView
    public void setCardBackgroundColor(@ColorInt int i10) {
        this.f22392h.f25052c.setFillColor(ColorStateList.valueOf(i10));
    }
}
