content: package androidx.cardview.widget;
  
  import android.content.Context;
  import android.content.res.ColorStateList;
  import android.content.res.TypedArray;
  import android.graphics.Color;
  import android.graphics.Rect;
  import android.graphics.drawable.Drawable;
  import android.os.Build;
  import android.util.AttributeSet;
  import android.view.View;
  import android.widget.FrameLayout;
  import androidx.cardview.R;
  import androidx.constraintlayout.core.widgets.analyzer.BasicMeasure;
  
  public class CardView extends FrameLayout {
      private static final int[] COLOR_BACKGROUND_ATTR = {16842801};
      private static final CardViewImpl IMPL;
      private final CardViewDelegate mCardViewDelegate;
      private boolean mCompatPadding;
      final Rect mContentPadding;
      private boolean mPreventCornerOverlap;
      final Rect mShadowBounds;
      int mUserSetMinHeight;
      int mUserSetMinWidth;
  
      static {
          if (Build.VERSION.SDK_INT >= 21) {
              IMPL = new CardViewApi21Impl();
          } else if (Build.VERSION.SDK_INT >= 17) {
              IMPL = new CardViewApi17Impl();
          } else {
              IMPL = new CardViewBaseImpl();
          }
          IMPL.initStatic();
      }
  
      public CardView(Context context) {
          this(context, (AttributeSet) null);
      }
  
      public CardView(Context context, AttributeSet attrs) {
          this(context, attrs, R.attr.cardViewStyle);
      }
  
      /* JADX INFO: super call moved to the top of the method (can break code semantics) */
      public CardView(Context context, AttributeSet attrs, int defStyleAttr) {
          super(context, attrs, defStyleAttr);
          ColorStateList colorStateList;
          Rect rect = new Rect();
          this.mContentPadding = rect;
          this.mShadowBounds = new Rect();
          AnonymousClass1 r4 = new CardViewDelegate() {
              private Drawable mCardBackground;
  
              public Drawable getCardBackground() {
                  return this.mCardBackground;
              }
  
              public View getCardView() {
                  return CardView.this;
              }
  
              public boolean getPreventCornerOverlap() {
                  return CardView.this.getPreventCornerOverlap();
              }
  
              public boolean getUseCompatPadding() {
                  return CardView.this.getUseCompatPadding();
              }
  
              public void setCardBackground(Drawable drawable) {
                  this.mCardBackground = drawable;
                  CardView.this.setBackgroundDrawable(drawable);
              }
  
              public void setMinWidthHeightInternal(int width, int height) {
                  if (width > CardView.this.mUserSetMinWidth) {
                      CardView.super.setMinimumWidth(width);
                  }
                  if (height > CardView.this.mUserSetMinHeight) {
                      CardView.super.setMinimumHeight(height);
                  }
              }
  
              public void setShadowPadding(int left, int top, int right, int bottom) {
                  CardView.this.mShadowBounds.set(left, top, right, bottom);
                  CardView cardView = CardView.this;
                  CardView.super.setPadding(cardView.mContentPadding.left + left, CardView.this.mContentPadding.top + top, CardView.this.mContentPadding.right + right, CardView.this.mContentPadding.bottom + bottom);
              }
          };
          this.mCardViewDelegate = r4;
          TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attrs, R.styleable.CardView, defStyleAttr, R.style.CardView);
          if (obtainStyledAttributes.hasValue(R.styleable.CardView_cardBackgroundColor)) {
              colorStateList = obtainStyledAttributes.getColorStateList(R.styleable.CardView_cardBackgroundColor);
          } else {
              TypedArray obtainStyledAttributes2 = getContext().obtainStyledAttributes(COLOR_BACKGROUND_ATTR);
              int color = obtainStyledAttributes2.getColor(0, 0);
              obtainStyledAttributes2.recycle();
              float[] fArr = new float[3];
              Color.colorToHSV(color, fArr);
              colorStateList = ColorStateList.valueOf(fArr[2] > 0.5f ? getResources().getColor(R.color.cardview_light_background) : getResources().getColor(R.color.cardview_dark_background));
          }
          float dimension = obtainStyledAttributes.getDimension(R.styleable.CardView_cardCornerRadius, 0.0f);
          float dimension2 = obtainStyledAttributes.getDimension(R.styleable.CardView_cardElevation, 0.0f);
          float dimension3 = obtainStyledAttributes.getDimension(R.styleable.CardView_cardMaxElevation, 0.0f);
          this.mCompatPadding = obtainStyledAttributes.getBoolean(R.styleable.CardView_cardUseCompatPadding, false);
          this.mPreventCornerOverlap = obtainStyledAttributes.getBoolean(R.styleable.CardView_cardPreventCornerOverlap, true);
          int dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(R.styleable.CardView_contentPadding, 0);
          rect.left = obtainStyledAttributes.getDimensionPixelSize(R.styleable.CardView_contentPaddingLeft, dimensionPixelSize);
          rect.top = obtainStyledAttributes.getDimensionPixelSize(R.styleable.CardView_contentPaddingTop, dimensionPixelSize);
          rect.right = obtainStyledAttributes.getDimensionPixelSize(R.styleable.CardView_contentPaddingRight, dimensionPixelSize);
          rect.bottom = obtainStyledAttributes.getDimensionPixelSize(R.styleable.CardView_contentPaddingBottom, dimensionPixelSize);
          float f = dimension2 > dimension3 ? dimension2 : dimension3;
          this.mUserSetMinWidth = obtainStyledAttributes.getDimensionPixelSize(R.styleable.CardView_android_minWidth, 0);
          this.mUserSetMinHeight = obtainStyledAttributes.getDimensionPixelSize(R.styleable.CardView_android_minHeight, 0);
          obtainStyledAttributes.recycle();
          int i = dimensionPixelSize;
          IMPL.initialize(r4, context, colorStateList, dimension, dimension2, f);
      }
  
      public ColorStateList getCardBackgroundColor() {
          return IMPL.getBackgroundColor(this.mCardViewDelegate);
      }
  
      public float getCardElevation() {
          return IMPL.getElevation(this.mCardViewDelegate);
      }
  
      public int getContentPaddingBottom() {
          return this.mContentPadding.bottom;
      }
  
      public int getContentPaddingLeft() {
          return this.mContentPadding.left;
      }
  
      public int getContentPaddingRight() {
          return this.mContentPadding.right;
      }
  
      public int getContentPaddingTop() {
          return this.mContentPadding.top;
      }
  
      public float getMaxCardElevation() {
          return IMPL.getMaxElevation(this.mCardViewDelegate);
      }
  
      public boolean getPreventCornerOverlap() {
          return this.mPreventCornerOverlap;
      }
  
      public float getRadius() {
          return IMPL.getRadius(this.mCardViewDelegate);
      }
  
      public boolean getUseCompatPadding() {
          return this.mCompatPadding;
      }
  
      /* access modifiers changed from: protected */
      public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
          CardViewImpl cardViewImpl = IMPL;
          if (!(cardViewImpl instanceof CardViewApi21Impl)) {
              int mode = View.MeasureSpec.getMode(widthMeasureSpec);
              switch (mode) {
                  case Integer.MIN_VALUE:
                  case BasicMeasure.EXACTLY /*1073741824*/:
                      widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(Math.max((int) Math.ceil((double) cardViewImpl.getMinWidth(this.mCardViewDelegate)), View.MeasureSpec.getSize(widthMeasureSpec)), mode);
                      break;
              }
              int mode2 = View.MeasureSpec.getMode(heightMeasureSpec);
              switch (mode2) {
                  case Integer.MIN_VALUE:
                  case BasicMeasure.EXACTLY /*1073741824*/:
                      heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(Math.max((int) Math.ceil((double) cardViewImpl.getMinHeight(this.mCardViewDelegate)), View.MeasureSpec.getSize(heightMeasureSpec)), mode2);
                      break;
              }
              super.onMeasure(widthMeasureSpec, heightMeasureSpec);
              return;
          }
          super.onMeasure(widthMeasureSpec, heightMeasureSpec);
      }
  
      public void setCardBackgroundColor(int color) {
          IMPL.setBackgroundColor(this.mCardViewDelegate, ColorStateList.valueOf(color));
      }
  
      public void setCardBackgroundColor(ColorStateList color) {
          IMPL.setBackgroundColor(this.mCardViewDelegate, color);
      }
  
      public void setCardElevation(float elevation) {
          IMPL.setElevation(this.mCardViewDelegate, elevation);
      }
  
      public void setContentPadding(int left, int top, int right, int bottom) {
          this.mContentPadding.set(left, top, right, bottom);
          IMPL.updatePadding(this.mCardViewDelegate);
      }
  
      public void setMaxCardElevation(float maxElevation) {
          IMPL.setMaxElevation(this.mCardViewDelegate, maxElevation);
      }
  
      public void setMinimumHeight(int minHeight) {
          this.mUserSetMinHeight = minHeight;
          super.setMinimumHeight(minHeight);
      }
  
      public void setMinimumWidth(int minWidth) {
          this.mUserSetMinWidth = minWidth;
          super.setMinimumWidth(minWidth);
      }
  
      public void setPadding(int left, int top, int right, int bottom) {
      }
  
      public void setPaddingRelative(int start, int top, int end, int bottom) {
      }
  
      public void setPreventCornerOverlap(boolean preventCornerOverlap) {
          if (preventCornerOverlap != this.mPreventCornerOverlap) {
              this.mPreventCornerOverlap = preventCornerOverlap;
              IMPL.onPreventCornerOverlapChanged(this.mCardViewDelegate);
          }
      }
  
      public void setRadius(float radius) {
          IMPL.setRadius(this.mCardViewDelegate, radius);
      }
  
      public void setUseCompatPadding(boolean useCompatPadding) {
          if (this.mCompatPadding != useCompatPadding) {
              this.mCompatPadding = useCompatPadding;
              IMPL.onCompatPaddingChanged(this.mCardViewDelegate);
          }
      }
  }
  