package o; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.InsetDrawable; import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.RippleDrawable; import android.graphics.drawable.StateListDrawable; import android.os.Build; import android.util.AttributeSet; import android.util.TypedValue; import androidx.cardview.widget.CardView; import androidx.core.view.ViewCompat; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.material.card.MaterialCardView; import o.C17052tZT; import o.FLD; /* renamed from: o.akZ, reason: case insensitive filesystem */ /* loaded from: classes2.dex */ public final class C2753akZ { private static final Drawable r; private static final double v = Math.cos(Math.toRadians(45.0d)); private final int A; private final int D; public boolean b; public final C4363bXv c; public int d; public Drawable e; public final C4363bXv f; public int g; public int h; public ColorStateList i; public Drawable j; public final MaterialCardView k; public ColorStateList l; public C4363bXv m; /* renamed from: o, reason: collision with root package name */ public Drawable f8522o; public int p; public ColorStateList s; public FLD t; private C4363bXv u; private final TimeInterpolator w; private LayerDrawable x; private ValueAnimator y; public final Rect q = new Rect(); public boolean n = false; float a = BitmapDescriptorFactory.HUE_RED; static { r = Build.VERSION.SDK_INT <= 28 ? new ColorDrawable() : null; } public C2753akZ(MaterialCardView materialCardView, AttributeSet attributeSet, int i, int i2) { this.k = materialCardView; C4363bXv c4363bXv = new C4363bXv(materialCardView.getContext(), attributeSet, i, i2); this.c = c4363bXv; c4363bXv.d(materialCardView.getContext()); c4363bXv.f(); FLD.RVV rvv = new FLD.RVV(c4363bXv.B.l); TypedArray obtainStyledAttributes = materialCardView.getContext().obtainStyledAttributes(attributeSet, C17052tZT.jNh.CardView, i, C17052tZT.NHB.CardView); if (obtainStyledAttributes.hasValue(C17052tZT.jNh.CardView_cardCornerRadius)) { float dimension = obtainStyledAttributes.getDimension(C17052tZT.jNh.CardView_cardCornerRadius, BitmapDescriptorFactory.HUE_RED); rvv.f = new C17525xWe(dimension); rvv.k = new C17525xWe(dimension); rvv.d = new C17525xWe(dimension); rvv.e = new C17525xWe(dimension); } this.f = new C4363bXv(); a(new FLD(rvv, (byte) 0)); this.w = DAZ.Kh_(materialCardView.getContext(), C17052tZT.IeS.motionEasingLinearInterpolator, C6217cMa.e); Context context = materialCardView.getContext(); int i3 = C17052tZT.IeS.motionDurationShort2; TypedValue typedValue = new TypedValue(); typedValue = context.getTheme().resolveAttribute(i3, typedValue, true) ? typedValue : null; int i4 = 300; this.A = (typedValue == null || typedValue.type != 16) ? 300 : typedValue.data; Context context2 = materialCardView.getContext(); int i5 = C17052tZT.IeS.motionDurationShort1; TypedValue typedValue2 = new TypedValue(); TypedValue typedValue3 = context2.getTheme().resolveAttribute(i5, typedValue2, true) ? typedValue2 : null; if (typedValue3 != null && typedValue3.type == 16) { i4 = typedValue3.data; } this.D = i4; obtainStyledAttributes.recycle(); } private void b(boolean z) { float f = z ? 1.0f : BitmapDescriptorFactory.HUE_RED; float f2 = z ? 1.0f - this.a : this.a; ValueAnimator valueAnimator = this.y; if (valueAnimator != null) { valueAnimator.cancel(); this.y = null; } ValueAnimator ofFloat = ValueAnimator.ofFloat(this.a, f); this.y = ofFloat; ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener(this) { // from class: o.uMI private C2753akZ d; @Override // android.animation.ValueAnimator.AnimatorUpdateListener public final void onAnimationUpdate(ValueAnimator valueAnimator2) { C2753akZ c2753akZ = this.d; float floatValue = ((Float) valueAnimator2.getAnimatedValue()).floatValue(); c2753akZ.e.setAlpha((int) (255.0f * floatValue)); c2753akZ.a = floatValue; } { this.d = this; } }); this.y.setInterpolator(this.w); this.y.setDuration((z ? this.A : this.D) * f2); this.y.start(); } public final void a() { int j = (int) (((m() || e()) ? j() : BitmapDescriptorFactory.HUE_RED) - i()); this.k.e(this.q.left + j, this.q.top + j, this.q.right + j, this.q.bottom + j); } public final void Is_(Drawable drawable) { if (drawable != null) { Drawable mutate = Tlu.pI_(drawable).mutate(); this.e = mutate; Tlu.pF_(mutate, this.i); c(this.k.isChecked(), false); } else { this.e = r; } LayerDrawable layerDrawable = this.x; if (layerDrawable != null) { layerDrawable.setDrawableByLayerId(C17052tZT.ZqN.mtrl_card_checked_layer_id, this.e); } } public final void a(FLD fld) { this.t = fld; this.c.setShapeAppearanceModel(fld); C4363bXv c4363bXv = this.c; FLD fld2 = c4363bXv.B.l; c4363bXv.F.set(c4363bXv.getBounds()); c4363bXv.G = !fld2.Ln_(c4363bXv.F); C4363bXv c4363bXv2 = this.f; if (c4363bXv2 != null) { c4363bXv2.setShapeAppearanceModel(fld); } C4363bXv c4363bXv3 = this.m; if (c4363bXv3 != null) { c4363bXv3.setShapeAppearanceModel(fld); } C4363bXv c4363bXv4 = this.u; if (c4363bXv4 != null) { c4363bXv4.setShapeAppearanceModel(fld); } } private float h() { return (CardView.e.d(this.k.a) * 1.5f) + (e() ? j() : BitmapDescriptorFactory.HUE_RED); } private float g() { return CardView.e.d(this.k.a) + (e() ? j() : BitmapDescriptorFactory.HUE_RED); } public final Drawable Iq_() { if (this.f8522o == null) { this.f8522o = Ip_(); } if (this.x == null) { LayerDrawable layerDrawable = new LayerDrawable(new Drawable[]{this.f8522o, this.f, this.e}); this.x = layerDrawable; layerDrawable.setId(2, C17052tZT.ZqN.mtrl_card_checked_layer_id); } return this.x; } private Drawable Ip_() { if (C0459HUs.b) { this.m = new C4363bXv(this.t); return new RippleDrawable(this.l, null, this.m); } StateListDrawable stateListDrawable = new StateListDrawable(); C4363bXv c4363bXv = new C4363bXv(this.t); this.u = c4363bXv; ColorStateList colorStateList = this.l; if (c4363bXv.B.d != colorStateList) { c4363bXv.B.d = colorStateList; c4363bXv.onStateChange(c4363bXv.getState()); } stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, this.u); return stateListDrawable; } public final void d() { ColorStateList colorStateList; Drawable drawable; if (C0459HUs.b && (drawable = this.f8522o) != null) { ((RippleDrawable) drawable).setColor(this.l); return; } C4363bXv c4363bXv = this.u; if (c4363bXv == null || c4363bXv.B.d == (colorStateList = this.l)) { return; } c4363bXv.B.d = colorStateList; c4363bXv.onStateChange(c4363bXv.getState()); } public final void c(boolean z, boolean z2) { Drawable drawable = this.e; if (drawable != null) { if (z2) { b(z); } else { drawable.setAlpha(z ? 255 : 0); this.a = z ? 1.0f : BitmapDescriptorFactory.HUE_RED; } } } private float j() { float f; float f2; float f3; Spl spl = this.t.g; float h = this.c.h(); boolean z = spl instanceof kJO; float f4 = BitmapDescriptorFactory.HUE_RED; if (z) { f = (float) ((1.0d - v) * h); } else { f = spl instanceof vZD ? h / 2.0f : 0.0f; } Spl spl2 = this.t.m; float j = this.c.j(); if (spl2 instanceof kJO) { f2 = (float) ((1.0d - v) * j); } else { f2 = spl2 instanceof vZD ? j / 2.0f : 0.0f; } float max = Math.max(f, f2); Spl spl3 = this.t.d; float e = this.c.e(); if (spl3 instanceof kJO) { f3 = (float) ((1.0d - v) * e); } else { f3 = spl3 instanceof vZD ? e / 2.0f : 0.0f; } Spl spl4 = this.t.a; float b = this.c.b(); if (spl4 instanceof kJO) { f4 = (float) ((1.0d - v) * b); } else if (spl4 instanceof vZD) { f4 = b / 2.0f; } return Math.max(max, Math.max(f3, f4)); } private float i() { if (!this.k.d || !this.k.c) { return BitmapDescriptorFactory.HUE_RED; } return (float) ((1.0d - v) * this.k.h()); } public final Drawable Ir_(Drawable drawable) { int i; int i2; if (this.k.c) { i2 = (int) Math.ceil(h()); i = (int) Math.ceil(g()); } else { i = 0; i2 = 0; } return new InsetDrawable(this, drawable, i, i2, i, i2) { // from class: o.akZ.3 private C2753akZ a; @Override // android.graphics.drawable.Drawable public final int getMinimumHeight() { return -1; } @Override // android.graphics.drawable.Drawable public final int getMinimumWidth() { return -1; } @Override // android.graphics.drawable.InsetDrawable, android.graphics.drawable.DrawableWrapper, android.graphics.drawable.Drawable public final boolean getPadding(Rect rect) { return false; } { this.a = this; } }; } private boolean m() { if (this.k.d) { C4363bXv c4363bXv = this.c; FLD fld = c4363bXv.B.l; c4363bXv.F.set(c4363bXv.getBounds()); if (!fld.Ln_(c4363bXv.F)) { return true; } } return false; } public final boolean e() { if (this.k.d) { C4363bXv c4363bXv = this.c; FLD fld = c4363bXv.B.l; c4363bXv.F.set(c4363bXv.getBounds()); if (fld.Ln_(c4363bXv.F) && this.k.c) { return true; } } return false; } public final void a(int i, int i2) { int i3; int i4; int i5; int i6; if (this.x != null) { if (this.k.c) { i3 = (int) Math.ceil(h() * 2.0f); i4 = (int) Math.ceil(g() * 2.0f); } else { i3 = 0; i4 = 0; } int i7 = this.d; int i8 = (i7 & 8388613) == 8388613 ? ((i - this.h) - this.g) - i4 : this.h; int i9 = (i7 & 80) == 80 ? this.h : ((i2 - this.h) - this.g) - i3; int i10 = (i7 & 8388613) == 8388613 ? this.h : ((i - this.h) - this.g) - i4; int i11 = (i7 & 80) == 80 ? ((i2 - this.h) - this.g) - i3 : this.h; if (ViewCompat.m(this.k) != 1) { i6 = i10; i5 = i8; } else { i5 = i10; i6 = i8; } this.x.setLayerInset(2, i5, i11, i6, i9); } } public final void c() { if (!this.n) { this.k.Io_(Ir_(this.c)); } this.k.setForeground(Ir_(this.j)); } }