ADD week 5
This commit is contained in:
		| @@ -0,0 +1,374 @@ | ||||
| package com.google.android.material.imageview; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.ColorStateList; | ||||
| import android.graphics.Canvas; | ||||
| import android.graphics.Outline; | ||||
| import android.graphics.Paint; | ||||
| import android.graphics.Path; | ||||
| import android.graphics.Rect; | ||||
| import android.graphics.RectF; | ||||
| import android.util.AttributeSet; | ||||
| import android.view.View; | ||||
| import android.view.ViewOutlineProvider; | ||||
| import androidx.appcompat.content.res.AppCompatResources; | ||||
| import androidx.appcompat.widget.AppCompatImageView; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.shape.MaterialShapeDrawable; | ||||
| import com.google.android.material.shape.ShapeAppearanceModel; | ||||
| import com.google.android.material.shape.ShapeAppearancePathProvider; | ||||
| import com.google.android.material.shape.Shapeable; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class ShapeableImageView extends AppCompatImageView implements Shapeable { | ||||
|     private static final int DEF_STYLE_RES = R.style.Widget_MaterialComponents_ShapeableImageView; | ||||
|     private static final int UNDEFINED_PADDING = Integer.MIN_VALUE; | ||||
|     private final Paint borderPaint; | ||||
|     private int bottomContentPadding; | ||||
|     private final Paint clearPaint; | ||||
|     private final RectF destination; | ||||
|     private int endContentPadding; | ||||
|     private boolean hasAdjustedPaddingAfterLayoutDirectionResolved; | ||||
|     private int leftContentPadding; | ||||
|     private Path maskPath; | ||||
|     private final RectF maskRect; | ||||
|     private final Path path; | ||||
|     private final ShapeAppearancePathProvider pathProvider; | ||||
|     private int rightContentPadding; | ||||
|     private MaterialShapeDrawable shadowDrawable; | ||||
|     private ShapeAppearanceModel shapeAppearanceModel; | ||||
|     private int startContentPadding; | ||||
|     private ColorStateList strokeColor; | ||||
|     private float strokeWidth; | ||||
|     private int topContentPadding; | ||||
|  | ||||
|     private boolean isContentPaddingRelative() { | ||||
|         return (this.startContentPadding == Integer.MIN_VALUE && this.endContentPadding == Integer.MIN_VALUE) ? false : true; | ||||
|     } | ||||
|  | ||||
|     public int getContentPaddingBottom() { | ||||
|         return this.bottomContentPadding; | ||||
|     } | ||||
|  | ||||
|     public int getContentPaddingTop() { | ||||
|         return this.topContentPadding; | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.shape.Shapeable | ||||
|     public ShapeAppearanceModel getShapeAppearanceModel() { | ||||
|         return this.shapeAppearanceModel; | ||||
|     } | ||||
|  | ||||
|     public ColorStateList getStrokeColor() { | ||||
|         return this.strokeColor; | ||||
|     } | ||||
|  | ||||
|     public float getStrokeWidth() { | ||||
|         return this.strokeWidth; | ||||
|     } | ||||
|  | ||||
|     public ShapeableImageView(Context context) { | ||||
|         this(context, null, 0); | ||||
|     } | ||||
|  | ||||
|     public ShapeableImageView(Context context, AttributeSet attributeSet) { | ||||
|         this(context, attributeSet, 0); | ||||
|     } | ||||
|  | ||||
|     /* JADX WARN: Illegal instructions before constructor call */ | ||||
|     /* | ||||
|         Code decompiled incorrectly, please refer to instructions dump. | ||||
|         To view partially-correct add '--show-bad-code' argument | ||||
|     */ | ||||
|     public ShapeableImageView(android.content.Context r7, android.util.AttributeSet r8, int r9) { | ||||
|         /* | ||||
|             r6 = this; | ||||
|             int r0 = com.google.android.material.imageview.ShapeableImageView.DEF_STYLE_RES | ||||
|             android.content.Context r7 = com.google.android.material.theme.overlay.MaterialThemeOverlay.wrap(r7, r8, r9, r0) | ||||
|             r6.<init>(r7, r8, r9) | ||||
|             com.google.android.material.shape.ShapeAppearancePathProvider r7 = com.google.android.material.shape.ShapeAppearancePathProvider.getInstance() | ||||
|             r6.pathProvider = r7 | ||||
|             android.graphics.Path r7 = new android.graphics.Path | ||||
|             r7.<init>() | ||||
|             r6.path = r7 | ||||
|             r7 = 0 | ||||
|             r6.hasAdjustedPaddingAfterLayoutDirectionResolved = r7 | ||||
|             android.content.Context r1 = r6.getContext() | ||||
|             android.graphics.Paint r2 = new android.graphics.Paint | ||||
|             r2.<init>() | ||||
|             r6.clearPaint = r2 | ||||
|             r3 = 1 | ||||
|             r2.setAntiAlias(r3) | ||||
|             r4 = -1 | ||||
|             r2.setColor(r4) | ||||
|             android.graphics.PorterDuffXfermode r4 = new android.graphics.PorterDuffXfermode | ||||
|             android.graphics.PorterDuff$Mode r5 = android.graphics.PorterDuff.Mode.DST_OUT | ||||
|             r4.<init>(r5) | ||||
|             r2.setXfermode(r4) | ||||
|             android.graphics.RectF r2 = new android.graphics.RectF | ||||
|             r2.<init>() | ||||
|             r6.destination = r2 | ||||
|             android.graphics.RectF r2 = new android.graphics.RectF | ||||
|             r2.<init>() | ||||
|             r6.maskRect = r2 | ||||
|             android.graphics.Path r2 = new android.graphics.Path | ||||
|             r2.<init>() | ||||
|             r6.maskPath = r2 | ||||
|             int[] r2 = com.google.android.material.R.styleable.ShapeableImageView | ||||
|             android.content.res.TypedArray r2 = r1.obtainStyledAttributes(r8, r2, r9, r0) | ||||
|             r4 = 2 | ||||
|             r5 = 0 | ||||
|             r6.setLayerType(r4, r5) | ||||
|             int r4 = com.google.android.material.R.styleable.ShapeableImageView_strokeColor | ||||
|             android.content.res.ColorStateList r4 = com.google.android.material.resources.MaterialResources.getColorStateList(r1, r2, r4) | ||||
|             r6.strokeColor = r4 | ||||
|             int r4 = com.google.android.material.R.styleable.ShapeableImageView_strokeWidth | ||||
|             int r4 = r2.getDimensionPixelSize(r4, r7) | ||||
|             float r4 = (float) r4 | ||||
|             r6.strokeWidth = r4 | ||||
|             int r4 = com.google.android.material.R.styleable.ShapeableImageView_contentPadding | ||||
|             int r7 = r2.getDimensionPixelSize(r4, r7) | ||||
|             r6.leftContentPadding = r7 | ||||
|             r6.topContentPadding = r7 | ||||
|             r6.rightContentPadding = r7 | ||||
|             r6.bottomContentPadding = r7 | ||||
|             int r4 = com.google.android.material.R.styleable.ShapeableImageView_contentPaddingLeft | ||||
|             int r4 = r2.getDimensionPixelSize(r4, r7) | ||||
|             r6.leftContentPadding = r4 | ||||
|             int r4 = com.google.android.material.R.styleable.ShapeableImageView_contentPaddingTop | ||||
|             int r4 = r2.getDimensionPixelSize(r4, r7) | ||||
|             r6.topContentPadding = r4 | ||||
|             int r4 = com.google.android.material.R.styleable.ShapeableImageView_contentPaddingRight | ||||
|             int r4 = r2.getDimensionPixelSize(r4, r7) | ||||
|             r6.rightContentPadding = r4 | ||||
|             int r4 = com.google.android.material.R.styleable.ShapeableImageView_contentPaddingBottom | ||||
|             int r7 = r2.getDimensionPixelSize(r4, r7) | ||||
|             r6.bottomContentPadding = r7 | ||||
|             int r7 = com.google.android.material.R.styleable.ShapeableImageView_contentPaddingStart | ||||
|             r4 = -2147483648(0xffffffff80000000, float:-0.0) | ||||
|             int r7 = r2.getDimensionPixelSize(r7, r4) | ||||
|             r6.startContentPadding = r7 | ||||
|             int r7 = com.google.android.material.R.styleable.ShapeableImageView_contentPaddingEnd | ||||
|             int r7 = r2.getDimensionPixelSize(r7, r4) | ||||
|             r6.endContentPadding = r7 | ||||
|             r2.recycle() | ||||
|             android.graphics.Paint r7 = new android.graphics.Paint | ||||
|             r7.<init>() | ||||
|             r6.borderPaint = r7 | ||||
|             android.graphics.Paint$Style r2 = android.graphics.Paint.Style.STROKE | ||||
|             r7.setStyle(r2) | ||||
|             r7.setAntiAlias(r3) | ||||
|             com.google.android.material.shape.ShapeAppearanceModel$Builder r7 = com.google.android.material.shape.ShapeAppearanceModel.builder(r1, r8, r9, r0) | ||||
|             com.google.android.material.shape.ShapeAppearanceModel r7 = r7.build() | ||||
|             r6.shapeAppearanceModel = r7 | ||||
|             com.google.android.material.imageview.ShapeableImageView$OutlineProvider r7 = new com.google.android.material.imageview.ShapeableImageView$OutlineProvider | ||||
|             r7.<init>() | ||||
|             r6.setOutlineProvider(r7) | ||||
|             return | ||||
|         */ | ||||
|         throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.imageview.ShapeableImageView.<init>(android.content.Context, android.util.AttributeSet, int):void"); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.ImageView, android.view.View | ||||
|     protected void onMeasure(int i, int i2) { | ||||
|         super.onMeasure(i, i2); | ||||
|         if (!this.hasAdjustedPaddingAfterLayoutDirectionResolved && isLayoutDirectionResolved()) { | ||||
|             this.hasAdjustedPaddingAfterLayoutDirectionResolved = true; | ||||
|             if (isPaddingRelative() || isContentPaddingRelative()) { | ||||
|                 setPaddingRelative(super.getPaddingStart(), super.getPaddingTop(), super.getPaddingEnd(), super.getPaddingBottom()); | ||||
|             } else { | ||||
|                 setPadding(super.getPaddingLeft(), super.getPaddingTop(), super.getPaddingRight(), super.getPaddingBottom()); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.ImageView, android.view.View | ||||
|     protected void onDraw(Canvas canvas) { | ||||
|         super.onDraw(canvas); | ||||
|         canvas.drawPath(this.maskPath, this.clearPaint); | ||||
|         drawStroke(canvas); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     protected void onSizeChanged(int i, int i2, int i3, int i4) { | ||||
|         super.onSizeChanged(i, i2, i3, i4); | ||||
|         updateShapeMask(i, i2); | ||||
|     } | ||||
|  | ||||
|     public void setContentPadding(int i, int i2, int i3, int i4) { | ||||
|         this.startContentPadding = Integer.MIN_VALUE; | ||||
|         this.endContentPadding = Integer.MIN_VALUE; | ||||
|         super.setPadding((super.getPaddingLeft() - this.leftContentPadding) + i, (super.getPaddingTop() - this.topContentPadding) + i2, (super.getPaddingRight() - this.rightContentPadding) + i3, (super.getPaddingBottom() - this.bottomContentPadding) + i4); | ||||
|         this.leftContentPadding = i; | ||||
|         this.topContentPadding = i2; | ||||
|         this.rightContentPadding = i3; | ||||
|         this.bottomContentPadding = i4; | ||||
|     } | ||||
|  | ||||
|     public void setContentPaddingRelative(int i, int i2, int i3, int i4) { | ||||
|         super.setPaddingRelative((super.getPaddingStart() - getContentPaddingStart()) + i, (super.getPaddingTop() - this.topContentPadding) + i2, (super.getPaddingEnd() - getContentPaddingEnd()) + i3, (super.getPaddingBottom() - this.bottomContentPadding) + i4); | ||||
|         this.leftContentPadding = isRtl() ? i3 : i; | ||||
|         this.topContentPadding = i2; | ||||
|         if (!isRtl()) { | ||||
|             i = i3; | ||||
|         } | ||||
|         this.rightContentPadding = i; | ||||
|         this.bottomContentPadding = i4; | ||||
|     } | ||||
|  | ||||
|     public final int getContentPaddingEnd() { | ||||
|         int i = this.endContentPadding; | ||||
|         return i != Integer.MIN_VALUE ? i : isRtl() ? this.leftContentPadding : this.rightContentPadding; | ||||
|     } | ||||
|  | ||||
|     public int getContentPaddingLeft() { | ||||
|         int i; | ||||
|         int i2; | ||||
|         if (isContentPaddingRelative()) { | ||||
|             if (isRtl() && (i2 = this.endContentPadding) != Integer.MIN_VALUE) { | ||||
|                 return i2; | ||||
|             } | ||||
|             if (!isRtl() && (i = this.startContentPadding) != Integer.MIN_VALUE) { | ||||
|                 return i; | ||||
|             } | ||||
|         } | ||||
|         return this.leftContentPadding; | ||||
|     } | ||||
|  | ||||
|     public int getContentPaddingRight() { | ||||
|         int i; | ||||
|         int i2; | ||||
|         if (isContentPaddingRelative()) { | ||||
|             if (isRtl() && (i2 = this.startContentPadding) != Integer.MIN_VALUE) { | ||||
|                 return i2; | ||||
|             } | ||||
|             if (!isRtl() && (i = this.endContentPadding) != Integer.MIN_VALUE) { | ||||
|                 return i; | ||||
|             } | ||||
|         } | ||||
|         return this.rightContentPadding; | ||||
|     } | ||||
|  | ||||
|     public final int getContentPaddingStart() { | ||||
|         int i = this.startContentPadding; | ||||
|         return i != Integer.MIN_VALUE ? i : isRtl() ? this.rightContentPadding : this.leftContentPadding; | ||||
|     } | ||||
|  | ||||
|     private boolean isRtl() { | ||||
|         return getLayoutDirection() == 1; | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     public void setPadding(int i, int i2, int i3, int i4) { | ||||
|         super.setPadding(i + getContentPaddingLeft(), i2 + getContentPaddingTop(), i3 + getContentPaddingRight(), i4 + getContentPaddingBottom()); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     public void setPaddingRelative(int i, int i2, int i3, int i4) { | ||||
|         super.setPaddingRelative(i + getContentPaddingStart(), i2 + getContentPaddingTop(), i3 + getContentPaddingEnd(), i4 + getContentPaddingBottom()); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     public int getPaddingBottom() { | ||||
|         return super.getPaddingBottom() - getContentPaddingBottom(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     public int getPaddingEnd() { | ||||
|         return super.getPaddingEnd() - getContentPaddingEnd(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     public int getPaddingLeft() { | ||||
|         return super.getPaddingLeft() - getContentPaddingLeft(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     public int getPaddingRight() { | ||||
|         return super.getPaddingRight() - getContentPaddingRight(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     public int getPaddingStart() { | ||||
|         return super.getPaddingStart() - getContentPaddingStart(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     public int getPaddingTop() { | ||||
|         return super.getPaddingTop() - getContentPaddingTop(); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.shape.Shapeable | ||||
|     public void setShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel) { | ||||
|         this.shapeAppearanceModel = shapeAppearanceModel; | ||||
|         MaterialShapeDrawable materialShapeDrawable = this.shadowDrawable; | ||||
|         if (materialShapeDrawable != null) { | ||||
|             materialShapeDrawable.setShapeAppearanceModel(shapeAppearanceModel); | ||||
|         } | ||||
|         updateShapeMask(getWidth(), getHeight()); | ||||
|         invalidate(); | ||||
|         invalidateOutline(); | ||||
|     } | ||||
|  | ||||
|     private void updateShapeMask(int i, int i2) { | ||||
|         this.destination.set(getPaddingLeft(), getPaddingTop(), i - getPaddingRight(), i2 - getPaddingBottom()); | ||||
|         this.pathProvider.calculatePath(this.shapeAppearanceModel, 1.0f, this.destination, this.path); | ||||
|         this.maskPath.rewind(); | ||||
|         this.maskPath.addPath(this.path); | ||||
|         this.maskRect.set(0.0f, 0.0f, i, i2); | ||||
|         this.maskPath.addRect(this.maskRect, Path.Direction.CCW); | ||||
|     } | ||||
|  | ||||
|     private void drawStroke(Canvas canvas) { | ||||
|         if (this.strokeColor == null) { | ||||
|             return; | ||||
|         } | ||||
|         this.borderPaint.setStrokeWidth(this.strokeWidth); | ||||
|         int colorForState = this.strokeColor.getColorForState(getDrawableState(), this.strokeColor.getDefaultColor()); | ||||
|         if (this.strokeWidth <= 0.0f || colorForState == 0) { | ||||
|             return; | ||||
|         } | ||||
|         this.borderPaint.setColor(colorForState); | ||||
|         canvas.drawPath(this.path, this.borderPaint); | ||||
|     } | ||||
|  | ||||
|     public void setStrokeColorResource(int i) { | ||||
|         setStrokeColor(AppCompatResources.getColorStateList(getContext(), i)); | ||||
|     } | ||||
|  | ||||
|     public void setStrokeWidth(float f) { | ||||
|         if (this.strokeWidth != f) { | ||||
|             this.strokeWidth = f; | ||||
|             invalidate(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void setStrokeWidthResource(int i) { | ||||
|         setStrokeWidth(getResources().getDimensionPixelSize(i)); | ||||
|     } | ||||
|  | ||||
|     public void setStrokeColor(ColorStateList colorStateList) { | ||||
|         this.strokeColor = colorStateList; | ||||
|         invalidate(); | ||||
|     } | ||||
|  | ||||
|     class OutlineProvider extends ViewOutlineProvider { | ||||
|         private final Rect rect = new Rect(); | ||||
|  | ||||
|         OutlineProvider() { | ||||
|         } | ||||
|  | ||||
|         @Override // android.view.ViewOutlineProvider | ||||
|         public void getOutline(View view, Outline outline) { | ||||
|             if (ShapeableImageView.this.shapeAppearanceModel == null) { | ||||
|                 return; | ||||
|             } | ||||
|             if (ShapeableImageView.this.shadowDrawable == null) { | ||||
|                 ShapeableImageView.this.shadowDrawable = new MaterialShapeDrawable(ShapeableImageView.this.shapeAppearanceModel); | ||||
|             } | ||||
|             ShapeableImageView.this.destination.round(this.rect); | ||||
|             ShapeableImageView.this.shadowDrawable.setBounds(this.rect); | ||||
|             ShapeableImageView.this.shadowDrawable.getOutline(outline); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user