ADD week 5
This commit is contained in:
		
							
								
								
									
										243
									
								
								02-Easy5/E5/sources/androidx/cardview/widget/CardView.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										243
									
								
								02-Easy5/E5/sources/androidx/cardview/widget/CardView.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,243 @@ | ||||
| package androidx.cardview.widget; | ||||
|  | ||||
| import android.R; | ||||
| 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.util.AttributeSet; | ||||
| import android.view.View; | ||||
| import android.widget.FrameLayout; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class CardView extends FrameLayout { | ||||
|     private static final int[] COLOR_BACKGROUND_ATTR = {R.attr.colorBackground}; | ||||
|     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; | ||||
|  | ||||
|     public boolean getPreventCornerOverlap() { | ||||
|         return this.mPreventCornerOverlap; | ||||
|     } | ||||
|  | ||||
|     public boolean getUseCompatPadding() { | ||||
|         return this.mCompatPadding; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     public void setPadding(int i, int i2, int i3, int i4) { | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     public void setPaddingRelative(int i, int i2, int i3, int i4) { | ||||
|     } | ||||
|  | ||||
|     static { | ||||
|         CardViewApi21Impl cardViewApi21Impl = new CardViewApi21Impl(); | ||||
|         IMPL = cardViewApi21Impl; | ||||
|         cardViewApi21Impl.initStatic(); | ||||
|     } | ||||
|  | ||||
|     public CardView(Context context) { | ||||
|         this(context, null); | ||||
|     } | ||||
|  | ||||
|     public CardView(Context context, AttributeSet attributeSet) { | ||||
|         this(context, attributeSet, androidx.cardview.R.attr.cardViewStyle); | ||||
|     } | ||||
|  | ||||
|     public CardView(Context context, AttributeSet attributeSet, int i) { | ||||
|         super(context, attributeSet, i); | ||||
|         int color; | ||||
|         ColorStateList valueOf; | ||||
|         Rect rect = new Rect(); | ||||
|         this.mContentPadding = rect; | ||||
|         this.mShadowBounds = new Rect(); | ||||
|         CardViewDelegate cardViewDelegate = new CardViewDelegate() { // from class: androidx.cardview.widget.CardView.1 | ||||
|             private Drawable mCardBackground; | ||||
|  | ||||
|             @Override // androidx.cardview.widget.CardViewDelegate | ||||
|             public Drawable getCardBackground() { | ||||
|                 return this.mCardBackground; | ||||
|             } | ||||
|  | ||||
|             @Override // androidx.cardview.widget.CardViewDelegate | ||||
|             public View getCardView() { | ||||
|                 return CardView.this; | ||||
|             } | ||||
|  | ||||
|             @Override // androidx.cardview.widget.CardViewDelegate | ||||
|             public void setCardBackground(Drawable drawable) { | ||||
|                 this.mCardBackground = drawable; | ||||
|                 CardView.this.setBackgroundDrawable(drawable); | ||||
|             } | ||||
|  | ||||
|             @Override // androidx.cardview.widget.CardViewDelegate | ||||
|             public boolean getUseCompatPadding() { | ||||
|                 return CardView.this.getUseCompatPadding(); | ||||
|             } | ||||
|  | ||||
|             @Override // androidx.cardview.widget.CardViewDelegate | ||||
|             public boolean getPreventCornerOverlap() { | ||||
|                 return CardView.this.getPreventCornerOverlap(); | ||||
|             } | ||||
|  | ||||
|             @Override // androidx.cardview.widget.CardViewDelegate | ||||
|             public void setShadowPadding(int i2, int i3, int i4, int i5) { | ||||
|                 CardView.this.mShadowBounds.set(i2, i3, i4, i5); | ||||
|                 CardView cardView = CardView.this; | ||||
|                 CardView.super.setPadding(i2 + cardView.mContentPadding.left, i3 + CardView.this.mContentPadding.top, i4 + CardView.this.mContentPadding.right, i5 + CardView.this.mContentPadding.bottom); | ||||
|             } | ||||
|  | ||||
|             @Override // androidx.cardview.widget.CardViewDelegate | ||||
|             public void setMinWidthHeightInternal(int i2, int i3) { | ||||
|                 if (i2 > CardView.this.mUserSetMinWidth) { | ||||
|                     CardView.super.setMinimumWidth(i2); | ||||
|                 } | ||||
|                 if (i3 > CardView.this.mUserSetMinHeight) { | ||||
|                     CardView.super.setMinimumHeight(i3); | ||||
|                 } | ||||
|             } | ||||
|         }; | ||||
|         this.mCardViewDelegate = cardViewDelegate; | ||||
|         TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, androidx.cardview.R.styleable.CardView, i, androidx.cardview.R.style.CardView); | ||||
|         if (obtainStyledAttributes.hasValue(androidx.cardview.R.styleable.CardView_cardBackgroundColor)) { | ||||
|             valueOf = obtainStyledAttributes.getColorStateList(androidx.cardview.R.styleable.CardView_cardBackgroundColor); | ||||
|         } else { | ||||
|             TypedArray obtainStyledAttributes2 = getContext().obtainStyledAttributes(COLOR_BACKGROUND_ATTR); | ||||
|             int color2 = obtainStyledAttributes2.getColor(0, 0); | ||||
|             obtainStyledAttributes2.recycle(); | ||||
|             float[] fArr = new float[3]; | ||||
|             Color.colorToHSV(color2, fArr); | ||||
|             if (fArr[2] > 0.5f) { | ||||
|                 color = getResources().getColor(androidx.cardview.R.color.cardview_light_background); | ||||
|             } else { | ||||
|                 color = getResources().getColor(androidx.cardview.R.color.cardview_dark_background); | ||||
|             } | ||||
|             valueOf = ColorStateList.valueOf(color); | ||||
|         } | ||||
|         ColorStateList colorStateList = valueOf; | ||||
|         float dimension = obtainStyledAttributes.getDimension(androidx.cardview.R.styleable.CardView_cardCornerRadius, 0.0f); | ||||
|         float dimension2 = obtainStyledAttributes.getDimension(androidx.cardview.R.styleable.CardView_cardElevation, 0.0f); | ||||
|         float dimension3 = obtainStyledAttributes.getDimension(androidx.cardview.R.styleable.CardView_cardMaxElevation, 0.0f); | ||||
|         this.mCompatPadding = obtainStyledAttributes.getBoolean(androidx.cardview.R.styleable.CardView_cardUseCompatPadding, false); | ||||
|         this.mPreventCornerOverlap = obtainStyledAttributes.getBoolean(androidx.cardview.R.styleable.CardView_cardPreventCornerOverlap, true); | ||||
|         int dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(androidx.cardview.R.styleable.CardView_contentPadding, 0); | ||||
|         rect.left = obtainStyledAttributes.getDimensionPixelSize(androidx.cardview.R.styleable.CardView_contentPaddingLeft, dimensionPixelSize); | ||||
|         rect.top = obtainStyledAttributes.getDimensionPixelSize(androidx.cardview.R.styleable.CardView_contentPaddingTop, dimensionPixelSize); | ||||
|         rect.right = obtainStyledAttributes.getDimensionPixelSize(androidx.cardview.R.styleable.CardView_contentPaddingRight, dimensionPixelSize); | ||||
|         rect.bottom = obtainStyledAttributes.getDimensionPixelSize(androidx.cardview.R.styleable.CardView_contentPaddingBottom, dimensionPixelSize); | ||||
|         float f = dimension2 > dimension3 ? dimension2 : dimension3; | ||||
|         this.mUserSetMinWidth = obtainStyledAttributes.getDimensionPixelSize(androidx.cardview.R.styleable.CardView_android_minWidth, 0); | ||||
|         this.mUserSetMinHeight = obtainStyledAttributes.getDimensionPixelSize(androidx.cardview.R.styleable.CardView_android_minHeight, 0); | ||||
|         obtainStyledAttributes.recycle(); | ||||
|         IMPL.initialize(cardViewDelegate, context, colorStateList, dimension, dimension2, f); | ||||
|     } | ||||
|  | ||||
|     public void setUseCompatPadding(boolean z) { | ||||
|         if (this.mCompatPadding != z) { | ||||
|             this.mCompatPadding = z; | ||||
|             IMPL.onCompatPaddingChanged(this.mCardViewDelegate); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void setContentPadding(int i, int i2, int i3, int i4) { | ||||
|         this.mContentPadding.set(i, i2, i3, i4); | ||||
|         IMPL.updatePadding(this.mCardViewDelegate); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.FrameLayout, android.view.View | ||||
|     protected void onMeasure(int i, int i2) { | ||||
|         if (!(IMPL instanceof CardViewApi21Impl)) { | ||||
|             int mode = View.MeasureSpec.getMode(i); | ||||
|             if (mode == Integer.MIN_VALUE || mode == 1073741824) { | ||||
|                 i = View.MeasureSpec.makeMeasureSpec(Math.max((int) Math.ceil(r0.getMinWidth(this.mCardViewDelegate)), View.MeasureSpec.getSize(i)), mode); | ||||
|             } | ||||
|             int mode2 = View.MeasureSpec.getMode(i2); | ||||
|             if (mode2 == Integer.MIN_VALUE || mode2 == 1073741824) { | ||||
|                 i2 = View.MeasureSpec.makeMeasureSpec(Math.max((int) Math.ceil(r0.getMinHeight(this.mCardViewDelegate)), View.MeasureSpec.getSize(i2)), mode2); | ||||
|             } | ||||
|             super.onMeasure(i, i2); | ||||
|             return; | ||||
|         } | ||||
|         super.onMeasure(i, i2); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     public void setMinimumWidth(int i) { | ||||
|         this.mUserSetMinWidth = i; | ||||
|         super.setMinimumWidth(i); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     public void setMinimumHeight(int i) { | ||||
|         this.mUserSetMinHeight = i; | ||||
|         super.setMinimumHeight(i); | ||||
|     } | ||||
|  | ||||
|     public void setCardBackgroundColor(int i) { | ||||
|         IMPL.setBackgroundColor(this.mCardViewDelegate, ColorStateList.valueOf(i)); | ||||
|     } | ||||
|  | ||||
|     public void setCardBackgroundColor(ColorStateList colorStateList) { | ||||
|         IMPL.setBackgroundColor(this.mCardViewDelegate, colorStateList); | ||||
|     } | ||||
|  | ||||
|     public ColorStateList getCardBackgroundColor() { | ||||
|         return IMPL.getBackgroundColor(this.mCardViewDelegate); | ||||
|     } | ||||
|  | ||||
|     public int getContentPaddingLeft() { | ||||
|         return this.mContentPadding.left; | ||||
|     } | ||||
|  | ||||
|     public int getContentPaddingRight() { | ||||
|         return this.mContentPadding.right; | ||||
|     } | ||||
|  | ||||
|     public int getContentPaddingTop() { | ||||
|         return this.mContentPadding.top; | ||||
|     } | ||||
|  | ||||
|     public int getContentPaddingBottom() { | ||||
|         return this.mContentPadding.bottom; | ||||
|     } | ||||
|  | ||||
|     public void setRadius(float f) { | ||||
|         IMPL.setRadius(this.mCardViewDelegate, f); | ||||
|     } | ||||
|  | ||||
|     public float getRadius() { | ||||
|         return IMPL.getRadius(this.mCardViewDelegate); | ||||
|     } | ||||
|  | ||||
|     public void setCardElevation(float f) { | ||||
|         IMPL.setElevation(this.mCardViewDelegate, f); | ||||
|     } | ||||
|  | ||||
|     public float getCardElevation() { | ||||
|         return IMPL.getElevation(this.mCardViewDelegate); | ||||
|     } | ||||
|  | ||||
|     public void setMaxCardElevation(float f) { | ||||
|         IMPL.setMaxElevation(this.mCardViewDelegate, f); | ||||
|     } | ||||
|  | ||||
|     public float getMaxCardElevation() { | ||||
|         return IMPL.getMaxElevation(this.mCardViewDelegate); | ||||
|     } | ||||
|  | ||||
|     public void setPreventCornerOverlap(boolean z) { | ||||
|         if (z != this.mPreventCornerOverlap) { | ||||
|             this.mPreventCornerOverlap = z; | ||||
|             IMPL.onPreventCornerOverlapChanged(this.mCardViewDelegate); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,22 @@ | ||||
| package androidx.cardview.widget; | ||||
|  | ||||
| import android.graphics.Canvas; | ||||
| import android.graphics.Paint; | ||||
| import android.graphics.RectF; | ||||
| import androidx.cardview.widget.RoundRectDrawableWithShadow; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class CardViewApi17Impl extends CardViewBaseImpl { | ||||
|     CardViewApi17Impl() { | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewBaseImpl, androidx.cardview.widget.CardViewImpl | ||||
|     public void initStatic() { | ||||
|         RoundRectDrawableWithShadow.sRoundRectHelper = new RoundRectDrawableWithShadow.RoundRectHelper() { // from class: androidx.cardview.widget.CardViewApi17Impl.1 | ||||
|             @Override // androidx.cardview.widget.RoundRectDrawableWithShadow.RoundRectHelper | ||||
|             public void drawRoundRect(Canvas canvas, RectF rectF, float f, Paint paint) { | ||||
|                 canvas.drawRoundRect(rectF, f, f, paint); | ||||
|             } | ||||
|         }; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,102 @@ | ||||
| package androidx.cardview.widget; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.ColorStateList; | ||||
| import android.view.View; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class CardViewApi21Impl implements CardViewImpl { | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void initStatic() { | ||||
|     } | ||||
|  | ||||
|     CardViewApi21Impl() { | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void initialize(CardViewDelegate cardViewDelegate, Context context, ColorStateList colorStateList, float f, float f2, float f3) { | ||||
|         cardViewDelegate.setCardBackground(new RoundRectDrawable(colorStateList, f)); | ||||
|         View cardView = cardViewDelegate.getCardView(); | ||||
|         cardView.setClipToOutline(true); | ||||
|         cardView.setElevation(f2); | ||||
|         setMaxElevation(cardViewDelegate, f3); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void setRadius(CardViewDelegate cardViewDelegate, float f) { | ||||
|         getCardBackground(cardViewDelegate).setRadius(f); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void setMaxElevation(CardViewDelegate cardViewDelegate, float f) { | ||||
|         getCardBackground(cardViewDelegate).setPadding(f, cardViewDelegate.getUseCompatPadding(), cardViewDelegate.getPreventCornerOverlap()); | ||||
|         updatePadding(cardViewDelegate); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public float getMaxElevation(CardViewDelegate cardViewDelegate) { | ||||
|         return getCardBackground(cardViewDelegate).getPadding(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public float getMinWidth(CardViewDelegate cardViewDelegate) { | ||||
|         return getRadius(cardViewDelegate) * 2.0f; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public float getMinHeight(CardViewDelegate cardViewDelegate) { | ||||
|         return getRadius(cardViewDelegate) * 2.0f; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public float getRadius(CardViewDelegate cardViewDelegate) { | ||||
|         return getCardBackground(cardViewDelegate).getRadius(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void setElevation(CardViewDelegate cardViewDelegate, float f) { | ||||
|         cardViewDelegate.getCardView().setElevation(f); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public float getElevation(CardViewDelegate cardViewDelegate) { | ||||
|         return cardViewDelegate.getCardView().getElevation(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void updatePadding(CardViewDelegate cardViewDelegate) { | ||||
|         if (!cardViewDelegate.getUseCompatPadding()) { | ||||
|             cardViewDelegate.setShadowPadding(0, 0, 0, 0); | ||||
|             return; | ||||
|         } | ||||
|         float maxElevation = getMaxElevation(cardViewDelegate); | ||||
|         float radius = getRadius(cardViewDelegate); | ||||
|         int ceil = (int) Math.ceil(RoundRectDrawableWithShadow.calculateHorizontalPadding(maxElevation, radius, cardViewDelegate.getPreventCornerOverlap())); | ||||
|         int ceil2 = (int) Math.ceil(RoundRectDrawableWithShadow.calculateVerticalPadding(maxElevation, radius, cardViewDelegate.getPreventCornerOverlap())); | ||||
|         cardViewDelegate.setShadowPadding(ceil, ceil2, ceil, ceil2); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void onCompatPaddingChanged(CardViewDelegate cardViewDelegate) { | ||||
|         setMaxElevation(cardViewDelegate, getMaxElevation(cardViewDelegate)); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void onPreventCornerOverlapChanged(CardViewDelegate cardViewDelegate) { | ||||
|         setMaxElevation(cardViewDelegate, getMaxElevation(cardViewDelegate)); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void setBackgroundColor(CardViewDelegate cardViewDelegate, ColorStateList colorStateList) { | ||||
|         getCardBackground(cardViewDelegate).setColor(colorStateList); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public ColorStateList getBackgroundColor(CardViewDelegate cardViewDelegate) { | ||||
|         return getCardBackground(cardViewDelegate).getColor(); | ||||
|     } | ||||
|  | ||||
|     private RoundRectDrawable getCardBackground(CardViewDelegate cardViewDelegate) { | ||||
|         return (RoundRectDrawable) cardViewDelegate.getCardBackground(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,136 @@ | ||||
| package androidx.cardview.widget; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.ColorStateList; | ||||
| import android.graphics.Canvas; | ||||
| import android.graphics.Paint; | ||||
| import android.graphics.Rect; | ||||
| import android.graphics.RectF; | ||||
| import androidx.cardview.widget.RoundRectDrawableWithShadow; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class CardViewBaseImpl implements CardViewImpl { | ||||
|     final RectF mCornerRect = new RectF(); | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void onCompatPaddingChanged(CardViewDelegate cardViewDelegate) { | ||||
|     } | ||||
|  | ||||
|     CardViewBaseImpl() { | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void initStatic() { | ||||
|         RoundRectDrawableWithShadow.sRoundRectHelper = new RoundRectDrawableWithShadow.RoundRectHelper() { // from class: androidx.cardview.widget.CardViewBaseImpl.1 | ||||
|             @Override // androidx.cardview.widget.RoundRectDrawableWithShadow.RoundRectHelper | ||||
|             public void drawRoundRect(Canvas canvas, RectF rectF, float f, Paint paint) { | ||||
|                 float f2 = 2.0f * f; | ||||
|                 float width = (rectF.width() - f2) - 1.0f; | ||||
|                 float height = (rectF.height() - f2) - 1.0f; | ||||
|                 if (f >= 1.0f) { | ||||
|                     float f3 = f + 0.5f; | ||||
|                     float f4 = -f3; | ||||
|                     CardViewBaseImpl.this.mCornerRect.set(f4, f4, f3, f3); | ||||
|                     int save = canvas.save(); | ||||
|                     canvas.translate(rectF.left + f3, rectF.top + f3); | ||||
|                     canvas.drawArc(CardViewBaseImpl.this.mCornerRect, 180.0f, 90.0f, true, paint); | ||||
|                     canvas.translate(width, 0.0f); | ||||
|                     canvas.rotate(90.0f); | ||||
|                     canvas.drawArc(CardViewBaseImpl.this.mCornerRect, 180.0f, 90.0f, true, paint); | ||||
|                     canvas.translate(height, 0.0f); | ||||
|                     canvas.rotate(90.0f); | ||||
|                     canvas.drawArc(CardViewBaseImpl.this.mCornerRect, 180.0f, 90.0f, true, paint); | ||||
|                     canvas.translate(width, 0.0f); | ||||
|                     canvas.rotate(90.0f); | ||||
|                     canvas.drawArc(CardViewBaseImpl.this.mCornerRect, 180.0f, 90.0f, true, paint); | ||||
|                     canvas.restoreToCount(save); | ||||
|                     canvas.drawRect((rectF.left + f3) - 1.0f, rectF.top, (rectF.right - f3) + 1.0f, rectF.top + f3, paint); | ||||
|                     canvas.drawRect((rectF.left + f3) - 1.0f, rectF.bottom - f3, (rectF.right - f3) + 1.0f, rectF.bottom, paint); | ||||
|                 } | ||||
|                 canvas.drawRect(rectF.left, rectF.top + f, rectF.right, rectF.bottom - f, paint); | ||||
|             } | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void initialize(CardViewDelegate cardViewDelegate, Context context, ColorStateList colorStateList, float f, float f2, float f3) { | ||||
|         RoundRectDrawableWithShadow createBackground = createBackground(context, colorStateList, f, f2, f3); | ||||
|         createBackground.setAddPaddingForCorners(cardViewDelegate.getPreventCornerOverlap()); | ||||
|         cardViewDelegate.setCardBackground(createBackground); | ||||
|         updatePadding(cardViewDelegate); | ||||
|     } | ||||
|  | ||||
|     private RoundRectDrawableWithShadow createBackground(Context context, ColorStateList colorStateList, float f, float f2, float f3) { | ||||
|         return new RoundRectDrawableWithShadow(context.getResources(), colorStateList, f, f2, f3); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void updatePadding(CardViewDelegate cardViewDelegate) { | ||||
|         Rect rect = new Rect(); | ||||
|         getShadowBackground(cardViewDelegate).getMaxShadowAndCornerPadding(rect); | ||||
|         cardViewDelegate.setMinWidthHeightInternal((int) Math.ceil(getMinWidth(cardViewDelegate)), (int) Math.ceil(getMinHeight(cardViewDelegate))); | ||||
|         cardViewDelegate.setShadowPadding(rect.left, rect.top, rect.right, rect.bottom); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void onPreventCornerOverlapChanged(CardViewDelegate cardViewDelegate) { | ||||
|         getShadowBackground(cardViewDelegate).setAddPaddingForCorners(cardViewDelegate.getPreventCornerOverlap()); | ||||
|         updatePadding(cardViewDelegate); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void setBackgroundColor(CardViewDelegate cardViewDelegate, ColorStateList colorStateList) { | ||||
|         getShadowBackground(cardViewDelegate).setColor(colorStateList); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public ColorStateList getBackgroundColor(CardViewDelegate cardViewDelegate) { | ||||
|         return getShadowBackground(cardViewDelegate).getColor(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void setRadius(CardViewDelegate cardViewDelegate, float f) { | ||||
|         getShadowBackground(cardViewDelegate).setCornerRadius(f); | ||||
|         updatePadding(cardViewDelegate); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public float getRadius(CardViewDelegate cardViewDelegate) { | ||||
|         return getShadowBackground(cardViewDelegate).getCornerRadius(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void setElevation(CardViewDelegate cardViewDelegate, float f) { | ||||
|         getShadowBackground(cardViewDelegate).setShadowSize(f); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public float getElevation(CardViewDelegate cardViewDelegate) { | ||||
|         return getShadowBackground(cardViewDelegate).getShadowSize(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public void setMaxElevation(CardViewDelegate cardViewDelegate, float f) { | ||||
|         getShadowBackground(cardViewDelegate).setMaxShadowSize(f); | ||||
|         updatePadding(cardViewDelegate); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public float getMaxElevation(CardViewDelegate cardViewDelegate) { | ||||
|         return getShadowBackground(cardViewDelegate).getMaxShadowSize(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public float getMinWidth(CardViewDelegate cardViewDelegate) { | ||||
|         return getShadowBackground(cardViewDelegate).getMinWidth(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.cardview.widget.CardViewImpl | ||||
|     public float getMinHeight(CardViewDelegate cardViewDelegate) { | ||||
|         return getShadowBackground(cardViewDelegate).getMinHeight(); | ||||
|     } | ||||
|  | ||||
|     private RoundRectDrawableWithShadow getShadowBackground(CardViewDelegate cardViewDelegate) { | ||||
|         return (RoundRectDrawableWithShadow) cardViewDelegate.getCardBackground(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,21 @@ | ||||
| package androidx.cardview.widget; | ||||
|  | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.view.View; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| interface CardViewDelegate { | ||||
|     Drawable getCardBackground(); | ||||
|  | ||||
|     View getCardView(); | ||||
|  | ||||
|     boolean getPreventCornerOverlap(); | ||||
|  | ||||
|     boolean getUseCompatPadding(); | ||||
|  | ||||
|     void setCardBackground(Drawable drawable); | ||||
|  | ||||
|     void setMinWidthHeightInternal(int i, int i2); | ||||
|  | ||||
|     void setShadowPadding(int i, int i2, int i3, int i4); | ||||
| } | ||||
| @@ -0,0 +1,37 @@ | ||||
| package androidx.cardview.widget; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.ColorStateList; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| interface CardViewImpl { | ||||
|     ColorStateList getBackgroundColor(CardViewDelegate cardViewDelegate); | ||||
|  | ||||
|     float getElevation(CardViewDelegate cardViewDelegate); | ||||
|  | ||||
|     float getMaxElevation(CardViewDelegate cardViewDelegate); | ||||
|  | ||||
|     float getMinHeight(CardViewDelegate cardViewDelegate); | ||||
|  | ||||
|     float getMinWidth(CardViewDelegate cardViewDelegate); | ||||
|  | ||||
|     float getRadius(CardViewDelegate cardViewDelegate); | ||||
|  | ||||
|     void initStatic(); | ||||
|  | ||||
|     void initialize(CardViewDelegate cardViewDelegate, Context context, ColorStateList colorStateList, float f, float f2, float f3); | ||||
|  | ||||
|     void onCompatPaddingChanged(CardViewDelegate cardViewDelegate); | ||||
|  | ||||
|     void onPreventCornerOverlapChanged(CardViewDelegate cardViewDelegate); | ||||
|  | ||||
|     void setBackgroundColor(CardViewDelegate cardViewDelegate, ColorStateList colorStateList); | ||||
|  | ||||
|     void setElevation(CardViewDelegate cardViewDelegate, float f); | ||||
|  | ||||
|     void setMaxElevation(CardViewDelegate cardViewDelegate, float f); | ||||
|  | ||||
|     void setRadius(CardViewDelegate cardViewDelegate, float f); | ||||
|  | ||||
|     void updatePadding(CardViewDelegate cardViewDelegate); | ||||
| } | ||||
| @@ -0,0 +1,180 @@ | ||||
| package androidx.cardview.widget; | ||||
|  | ||||
| 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; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class RoundRectDrawable extends Drawable { | ||||
|     private ColorStateList mBackground; | ||||
|     private final RectF mBoundsF; | ||||
|     private final Rect mBoundsI; | ||||
|     private float mPadding; | ||||
|     private float mRadius; | ||||
|     private ColorStateList mTint; | ||||
|     private PorterDuffColorFilter mTintFilter; | ||||
|     private boolean mInsetForPadding = false; | ||||
|     private boolean mInsetForRadius = true; | ||||
|     private PorterDuff.Mode mTintMode = PorterDuff.Mode.SRC_IN; | ||||
|     private final Paint mPaint = new Paint(5); | ||||
|  | ||||
|     public ColorStateList getColor() { | ||||
|         return this.mBackground; | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     public int getOpacity() { | ||||
|         return -3; | ||||
|     } | ||||
|  | ||||
|     float getPadding() { | ||||
|         return this.mPadding; | ||||
|     } | ||||
|  | ||||
|     public float getRadius() { | ||||
|         return this.mRadius; | ||||
|     } | ||||
|  | ||||
|     RoundRectDrawable(ColorStateList colorStateList, float f) { | ||||
|         this.mRadius = f; | ||||
|         setBackground(colorStateList); | ||||
|         this.mBoundsF = new RectF(); | ||||
|         this.mBoundsI = new Rect(); | ||||
|     } | ||||
|  | ||||
|     private void setBackground(ColorStateList colorStateList) { | ||||
|         if (colorStateList == null) { | ||||
|             colorStateList = ColorStateList.valueOf(0); | ||||
|         } | ||||
|         this.mBackground = colorStateList; | ||||
|         this.mPaint.setColor(colorStateList.getColorForState(getState(), this.mBackground.getDefaultColor())); | ||||
|     } | ||||
|  | ||||
|     void setPadding(float f, boolean z, boolean z2) { | ||||
|         if (f == this.mPadding && this.mInsetForPadding == z && this.mInsetForRadius == z2) { | ||||
|             return; | ||||
|         } | ||||
|         this.mPadding = f; | ||||
|         this.mInsetForPadding = z; | ||||
|         this.mInsetForRadius = z2; | ||||
|         updateBounds(null); | ||||
|         invalidateSelf(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     public void draw(Canvas canvas) { | ||||
|         boolean z; | ||||
|         Paint paint = this.mPaint; | ||||
|         if (this.mTintFilter == null || paint.getColorFilter() != null) { | ||||
|             z = false; | ||||
|         } else { | ||||
|             paint.setColorFilter(this.mTintFilter); | ||||
|             z = true; | ||||
|         } | ||||
|         RectF rectF = this.mBoundsF; | ||||
|         float f = this.mRadius; | ||||
|         canvas.drawRoundRect(rectF, f, f, paint); | ||||
|         if (z) { | ||||
|             paint.setColorFilter(null); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void updateBounds(Rect rect) { | ||||
|         if (rect == null) { | ||||
|             rect = getBounds(); | ||||
|         } | ||||
|         this.mBoundsF.set(rect.left, rect.top, rect.right, rect.bottom); | ||||
|         this.mBoundsI.set(rect); | ||||
|         if (this.mInsetForPadding) { | ||||
|             this.mBoundsI.inset((int) Math.ceil(RoundRectDrawableWithShadow.calculateHorizontalPadding(this.mPadding, this.mRadius, this.mInsetForRadius)), (int) Math.ceil(RoundRectDrawableWithShadow.calculateVerticalPadding(this.mPadding, this.mRadius, this.mInsetForRadius))); | ||||
|             this.mBoundsF.set(this.mBoundsI); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     protected void onBoundsChange(Rect rect) { | ||||
|         super.onBoundsChange(rect); | ||||
|         updateBounds(rect); | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     public void getOutline(Outline outline) { | ||||
|         outline.setRoundRect(this.mBoundsI, this.mRadius); | ||||
|     } | ||||
|  | ||||
|     void setRadius(float f) { | ||||
|         if (f == this.mRadius) { | ||||
|             return; | ||||
|         } | ||||
|         this.mRadius = f; | ||||
|         updateBounds(null); | ||||
|         invalidateSelf(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     public void setAlpha(int i) { | ||||
|         this.mPaint.setAlpha(i); | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     public void setColorFilter(ColorFilter colorFilter) { | ||||
|         this.mPaint.setColorFilter(colorFilter); | ||||
|     } | ||||
|  | ||||
|     public void setColor(ColorStateList colorStateList) { | ||||
|         setBackground(colorStateList); | ||||
|         invalidateSelf(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     public void setTintList(ColorStateList colorStateList) { | ||||
|         this.mTint = colorStateList; | ||||
|         this.mTintFilter = createTintFilter(colorStateList, this.mTintMode); | ||||
|         invalidateSelf(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     public void setTintMode(PorterDuff.Mode mode) { | ||||
|         this.mTintMode = mode; | ||||
|         this.mTintFilter = createTintFilter(this.mTint, mode); | ||||
|         invalidateSelf(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     protected boolean onStateChange(int[] iArr) { | ||||
|         PorterDuff.Mode mode; | ||||
|         ColorStateList colorStateList = this.mBackground; | ||||
|         int colorForState = colorStateList.getColorForState(iArr, colorStateList.getDefaultColor()); | ||||
|         boolean z = colorForState != this.mPaint.getColor(); | ||||
|         if (z) { | ||||
|             this.mPaint.setColor(colorForState); | ||||
|         } | ||||
|         ColorStateList colorStateList2 = this.mTint; | ||||
|         if (colorStateList2 == null || (mode = this.mTintMode) == null) { | ||||
|             return z; | ||||
|         } | ||||
|         this.mTintFilter = createTintFilter(colorStateList2, mode); | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     public boolean isStateful() { | ||||
|         ColorStateList colorStateList; | ||||
|         ColorStateList colorStateList2 = this.mTint; | ||||
|         return (colorStateList2 != null && colorStateList2.isStateful()) || ((colorStateList = this.mBackground) != null && colorStateList.isStateful()) || super.isStateful(); | ||||
|     } | ||||
|  | ||||
|     private PorterDuffColorFilter createTintFilter(ColorStateList colorStateList, PorterDuff.Mode mode) { | ||||
|         if (colorStateList == null || mode == null) { | ||||
|             return null; | ||||
|         } | ||||
|         return new PorterDuffColorFilter(colorStateList.getColorForState(getState(), 0), mode); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,307 @@ | ||||
| package androidx.cardview.widget; | ||||
|  | ||||
| import android.content.res.ColorStateList; | ||||
| import android.content.res.Resources; | ||||
| import android.graphics.Canvas; | ||||
| import android.graphics.ColorFilter; | ||||
| import android.graphics.LinearGradient; | ||||
| import android.graphics.Paint; | ||||
| import android.graphics.Path; | ||||
| import android.graphics.RadialGradient; | ||||
| import android.graphics.Rect; | ||||
| import android.graphics.RectF; | ||||
| import android.graphics.Shader; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import androidx.cardview.R; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class RoundRectDrawableWithShadow extends Drawable { | ||||
|     private static final double COS_45 = Math.cos(Math.toRadians(45.0d)); | ||||
|     private static final float SHADOW_MULTIPLIER = 1.5f; | ||||
|     static RoundRectHelper sRoundRectHelper; | ||||
|     private ColorStateList mBackground; | ||||
|     private final RectF mCardBounds; | ||||
|     private float mCornerRadius; | ||||
|     private Paint mCornerShadowPaint; | ||||
|     private Path mCornerShadowPath; | ||||
|     private Paint mEdgeShadowPaint; | ||||
|     private final int mInsetShadow; | ||||
|     private float mRawMaxShadowSize; | ||||
|     private float mRawShadowSize; | ||||
|     private final int mShadowEndColor; | ||||
|     private float mShadowSize; | ||||
|     private final int mShadowStartColor; | ||||
|     private boolean mDirty = true; | ||||
|     private boolean mAddPaddingForCorners = true; | ||||
|     private boolean mPrintedShadowClipWarning = false; | ||||
|     private Paint mPaint = new Paint(5); | ||||
|  | ||||
|     interface RoundRectHelper { | ||||
|         void drawRoundRect(Canvas canvas, RectF rectF, float f, Paint paint); | ||||
|     } | ||||
|  | ||||
|     static float calculateHorizontalPadding(float f, float f2, boolean z) { | ||||
|         return z ? (float) (f + ((1.0d - COS_45) * f2)) : f; | ||||
|     } | ||||
|  | ||||
|     static float calculateVerticalPadding(float f, float f2, boolean z) { | ||||
|         return z ? (float) ((f * SHADOW_MULTIPLIER) + ((1.0d - COS_45) * f2)) : f * SHADOW_MULTIPLIER; | ||||
|     } | ||||
|  | ||||
|     ColorStateList getColor() { | ||||
|         return this.mBackground; | ||||
|     } | ||||
|  | ||||
|     float getCornerRadius() { | ||||
|         return this.mCornerRadius; | ||||
|     } | ||||
|  | ||||
|     float getMaxShadowSize() { | ||||
|         return this.mRawMaxShadowSize; | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     public int getOpacity() { | ||||
|         return -3; | ||||
|     } | ||||
|  | ||||
|     float getShadowSize() { | ||||
|         return this.mRawShadowSize; | ||||
|     } | ||||
|  | ||||
|     RoundRectDrawableWithShadow(Resources resources, ColorStateList colorStateList, float f, float f2, float f3) { | ||||
|         this.mShadowStartColor = resources.getColor(R.color.cardview_shadow_start_color); | ||||
|         this.mShadowEndColor = resources.getColor(R.color.cardview_shadow_end_color); | ||||
|         this.mInsetShadow = resources.getDimensionPixelSize(R.dimen.cardview_compat_inset_shadow); | ||||
|         setBackground(colorStateList); | ||||
|         Paint paint = new Paint(5); | ||||
|         this.mCornerShadowPaint = paint; | ||||
|         paint.setStyle(Paint.Style.FILL); | ||||
|         this.mCornerRadius = (int) (f + 0.5f); | ||||
|         this.mCardBounds = new RectF(); | ||||
|         Paint paint2 = new Paint(this.mCornerShadowPaint); | ||||
|         this.mEdgeShadowPaint = paint2; | ||||
|         paint2.setAntiAlias(false); | ||||
|         setShadowSize(f2, f3); | ||||
|     } | ||||
|  | ||||
|     private void setBackground(ColorStateList colorStateList) { | ||||
|         if (colorStateList == null) { | ||||
|             colorStateList = ColorStateList.valueOf(0); | ||||
|         } | ||||
|         this.mBackground = colorStateList; | ||||
|         this.mPaint.setColor(colorStateList.getColorForState(getState(), this.mBackground.getDefaultColor())); | ||||
|     } | ||||
|  | ||||
|     private int toEven(float f) { | ||||
|         int i = (int) (f + 0.5f); | ||||
|         return i % 2 == 1 ? i - 1 : i; | ||||
|     } | ||||
|  | ||||
|     void setAddPaddingForCorners(boolean z) { | ||||
|         this.mAddPaddingForCorners = z; | ||||
|         invalidateSelf(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     public void setAlpha(int i) { | ||||
|         this.mPaint.setAlpha(i); | ||||
|         this.mCornerShadowPaint.setAlpha(i); | ||||
|         this.mEdgeShadowPaint.setAlpha(i); | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     protected void onBoundsChange(Rect rect) { | ||||
|         super.onBoundsChange(rect); | ||||
|         this.mDirty = true; | ||||
|     } | ||||
|  | ||||
|     private void setShadowSize(float f, float f2) { | ||||
|         if (f < 0.0f) { | ||||
|             throw new IllegalArgumentException("Invalid shadow size " + f + ". Must be >= 0"); | ||||
|         } | ||||
|         if (f2 < 0.0f) { | ||||
|             throw new IllegalArgumentException("Invalid max shadow size " + f2 + ". Must be >= 0"); | ||||
|         } | ||||
|         float even = toEven(f); | ||||
|         float even2 = toEven(f2); | ||||
|         if (even > even2) { | ||||
|             if (!this.mPrintedShadowClipWarning) { | ||||
|                 this.mPrintedShadowClipWarning = true; | ||||
|             } | ||||
|             even = even2; | ||||
|         } | ||||
|         if (this.mRawShadowSize == even && this.mRawMaxShadowSize == even2) { | ||||
|             return; | ||||
|         } | ||||
|         this.mRawShadowSize = even; | ||||
|         this.mRawMaxShadowSize = even2; | ||||
|         this.mShadowSize = (int) ((even * SHADOW_MULTIPLIER) + this.mInsetShadow + 0.5f); | ||||
|         this.mDirty = true; | ||||
|         invalidateSelf(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     public boolean getPadding(Rect rect) { | ||||
|         int ceil = (int) Math.ceil(calculateVerticalPadding(this.mRawMaxShadowSize, this.mCornerRadius, this.mAddPaddingForCorners)); | ||||
|         int ceil2 = (int) Math.ceil(calculateHorizontalPadding(this.mRawMaxShadowSize, this.mCornerRadius, this.mAddPaddingForCorners)); | ||||
|         rect.set(ceil2, ceil, ceil2, ceil); | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     protected boolean onStateChange(int[] iArr) { | ||||
|         ColorStateList colorStateList = this.mBackground; | ||||
|         int colorForState = colorStateList.getColorForState(iArr, colorStateList.getDefaultColor()); | ||||
|         if (this.mPaint.getColor() == colorForState) { | ||||
|             return false; | ||||
|         } | ||||
|         this.mPaint.setColor(colorForState); | ||||
|         this.mDirty = true; | ||||
|         invalidateSelf(); | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     public boolean isStateful() { | ||||
|         ColorStateList colorStateList = this.mBackground; | ||||
|         return (colorStateList != null && colorStateList.isStateful()) || super.isStateful(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     public void setColorFilter(ColorFilter colorFilter) { | ||||
|         this.mPaint.setColorFilter(colorFilter); | ||||
|     } | ||||
|  | ||||
|     void setCornerRadius(float f) { | ||||
|         if (f < 0.0f) { | ||||
|             throw new IllegalArgumentException("Invalid radius " + f + ". Must be >= 0"); | ||||
|         } | ||||
|         float f2 = (int) (f + 0.5f); | ||||
|         if (this.mCornerRadius == f2) { | ||||
|             return; | ||||
|         } | ||||
|         this.mCornerRadius = f2; | ||||
|         this.mDirty = true; | ||||
|         invalidateSelf(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.graphics.drawable.Drawable | ||||
|     public void draw(Canvas canvas) { | ||||
|         if (this.mDirty) { | ||||
|             buildComponents(getBounds()); | ||||
|             this.mDirty = false; | ||||
|         } | ||||
|         canvas.translate(0.0f, this.mRawShadowSize / 2.0f); | ||||
|         drawShadow(canvas); | ||||
|         canvas.translate(0.0f, (-this.mRawShadowSize) / 2.0f); | ||||
|         sRoundRectHelper.drawRoundRect(canvas, this.mCardBounds, this.mCornerRadius, this.mPaint); | ||||
|     } | ||||
|  | ||||
|     private void drawShadow(Canvas canvas) { | ||||
|         float f = this.mCornerRadius; | ||||
|         float f2 = (-f) - this.mShadowSize; | ||||
|         float f3 = f + this.mInsetShadow + (this.mRawShadowSize / 2.0f); | ||||
|         float f4 = f3 * 2.0f; | ||||
|         boolean z = this.mCardBounds.width() - f4 > 0.0f; | ||||
|         boolean z2 = this.mCardBounds.height() - f4 > 0.0f; | ||||
|         int save = canvas.save(); | ||||
|         canvas.translate(this.mCardBounds.left + f3, this.mCardBounds.top + f3); | ||||
|         canvas.drawPath(this.mCornerShadowPath, this.mCornerShadowPaint); | ||||
|         if (z) { | ||||
|             canvas.drawRect(0.0f, f2, this.mCardBounds.width() - f4, -this.mCornerRadius, this.mEdgeShadowPaint); | ||||
|         } | ||||
|         canvas.restoreToCount(save); | ||||
|         int save2 = canvas.save(); | ||||
|         canvas.translate(this.mCardBounds.right - f3, this.mCardBounds.bottom - f3); | ||||
|         canvas.rotate(180.0f); | ||||
|         canvas.drawPath(this.mCornerShadowPath, this.mCornerShadowPaint); | ||||
|         if (z) { | ||||
|             canvas.drawRect(0.0f, f2, this.mCardBounds.width() - f4, (-this.mCornerRadius) + this.mShadowSize, this.mEdgeShadowPaint); | ||||
|         } | ||||
|         canvas.restoreToCount(save2); | ||||
|         int save3 = canvas.save(); | ||||
|         canvas.translate(this.mCardBounds.left + f3, this.mCardBounds.bottom - f3); | ||||
|         canvas.rotate(270.0f); | ||||
|         canvas.drawPath(this.mCornerShadowPath, this.mCornerShadowPaint); | ||||
|         if (z2) { | ||||
|             canvas.drawRect(0.0f, f2, this.mCardBounds.height() - f4, -this.mCornerRadius, this.mEdgeShadowPaint); | ||||
|         } | ||||
|         canvas.restoreToCount(save3); | ||||
|         int save4 = canvas.save(); | ||||
|         canvas.translate(this.mCardBounds.right - f3, this.mCardBounds.top + f3); | ||||
|         canvas.rotate(90.0f); | ||||
|         canvas.drawPath(this.mCornerShadowPath, this.mCornerShadowPaint); | ||||
|         if (z2) { | ||||
|             canvas.drawRect(0.0f, f2, this.mCardBounds.height() - f4, -this.mCornerRadius, this.mEdgeShadowPaint); | ||||
|         } | ||||
|         canvas.restoreToCount(save4); | ||||
|     } | ||||
|  | ||||
|     private void buildShadowCorners() { | ||||
|         float f = this.mCornerRadius; | ||||
|         RectF rectF = new RectF(-f, -f, f, f); | ||||
|         RectF rectF2 = new RectF(rectF); | ||||
|         float f2 = this.mShadowSize; | ||||
|         rectF2.inset(-f2, -f2); | ||||
|         Path path = this.mCornerShadowPath; | ||||
|         if (path == null) { | ||||
|             this.mCornerShadowPath = new Path(); | ||||
|         } else { | ||||
|             path.reset(); | ||||
|         } | ||||
|         this.mCornerShadowPath.setFillType(Path.FillType.EVEN_ODD); | ||||
|         this.mCornerShadowPath.moveTo(-this.mCornerRadius, 0.0f); | ||||
|         this.mCornerShadowPath.rLineTo(-this.mShadowSize, 0.0f); | ||||
|         this.mCornerShadowPath.arcTo(rectF2, 180.0f, 90.0f, false); | ||||
|         this.mCornerShadowPath.arcTo(rectF, 270.0f, -90.0f, false); | ||||
|         this.mCornerShadowPath.close(); | ||||
|         float f3 = this.mCornerRadius; | ||||
|         float f4 = f3 / (this.mShadowSize + f3); | ||||
|         Paint paint = this.mCornerShadowPaint; | ||||
|         float f5 = this.mCornerRadius + this.mShadowSize; | ||||
|         int i = this.mShadowStartColor; | ||||
|         paint.setShader(new RadialGradient(0.0f, 0.0f, f5, new int[]{i, i, this.mShadowEndColor}, new float[]{0.0f, f4, 1.0f}, Shader.TileMode.CLAMP)); | ||||
|         Paint paint2 = this.mEdgeShadowPaint; | ||||
|         float f6 = this.mCornerRadius; | ||||
|         float f7 = this.mShadowSize; | ||||
|         float f8 = (-f6) + f7; | ||||
|         float f9 = (-f6) - f7; | ||||
|         int i2 = this.mShadowStartColor; | ||||
|         paint2.setShader(new LinearGradient(0.0f, f8, 0.0f, f9, new int[]{i2, i2, this.mShadowEndColor}, new float[]{0.0f, 0.5f, 1.0f}, Shader.TileMode.CLAMP)); | ||||
|         this.mEdgeShadowPaint.setAntiAlias(false); | ||||
|     } | ||||
|  | ||||
|     private void buildComponents(Rect rect) { | ||||
|         float f = this.mRawMaxShadowSize * SHADOW_MULTIPLIER; | ||||
|         this.mCardBounds.set(rect.left + this.mRawMaxShadowSize, rect.top + f, rect.right - this.mRawMaxShadowSize, rect.bottom - f); | ||||
|         buildShadowCorners(); | ||||
|     } | ||||
|  | ||||
|     void getMaxShadowAndCornerPadding(Rect rect) { | ||||
|         getPadding(rect); | ||||
|     } | ||||
|  | ||||
|     void setShadowSize(float f) { | ||||
|         setShadowSize(f, this.mRawMaxShadowSize); | ||||
|     } | ||||
|  | ||||
|     void setMaxShadowSize(float f) { | ||||
|         setShadowSize(this.mRawShadowSize, f); | ||||
|     } | ||||
|  | ||||
|     float getMinWidth() { | ||||
|         float f = this.mRawMaxShadowSize; | ||||
|         return (Math.max(f, this.mCornerRadius + this.mInsetShadow + (f / 2.0f)) * 2.0f) + ((this.mRawMaxShadowSize + this.mInsetShadow) * 2.0f); | ||||
|     } | ||||
|  | ||||
|     float getMinHeight() { | ||||
|         float f = this.mRawMaxShadowSize; | ||||
|         return (Math.max(f, this.mCornerRadius + this.mInsetShadow + ((f * SHADOW_MULTIPLIER) / 2.0f)) * 2.0f) + (((this.mRawMaxShadowSize * SHADOW_MULTIPLIER) + this.mInsetShadow) * 2.0f); | ||||
|     } | ||||
|  | ||||
|     void setColor(ColorStateList colorStateList) { | ||||
|         setBackground(colorStateList); | ||||
|         invalidateSelf(); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user