ADD week 5
This commit is contained in:
		| @@ -0,0 +1,160 @@ | ||||
| package com.google.android.material.divider; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.ColorStateList; | ||||
| import android.graphics.Canvas; | ||||
| import android.util.AttributeSet; | ||||
| import android.view.View; | ||||
| import androidx.core.content.ContextCompat; | ||||
| import androidx.core.view.ViewCompat; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.shape.MaterialShapeDrawable; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class MaterialDivider extends View { | ||||
|     private static final int DEF_STYLE_RES = R.style.Widget_MaterialComponents_MaterialDivider; | ||||
|     private int color; | ||||
|     private final MaterialShapeDrawable dividerDrawable; | ||||
|     private int insetEnd; | ||||
|     private int insetStart; | ||||
|     private int thickness; | ||||
|  | ||||
|     public int getDividerColor() { | ||||
|         return this.color; | ||||
|     } | ||||
|  | ||||
|     public int getDividerInsetEnd() { | ||||
|         return this.insetEnd; | ||||
|     } | ||||
|  | ||||
|     public int getDividerInsetStart() { | ||||
|         return this.insetStart; | ||||
|     } | ||||
|  | ||||
|     public int getDividerThickness() { | ||||
|         return this.thickness; | ||||
|     } | ||||
|  | ||||
|     public void setDividerInsetEnd(int i) { | ||||
|         this.insetEnd = i; | ||||
|     } | ||||
|  | ||||
|     public void setDividerInsetStart(int i) { | ||||
|         this.insetStart = i; | ||||
|     } | ||||
|  | ||||
|     public MaterialDivider(Context context) { | ||||
|         this(context, null); | ||||
|     } | ||||
|  | ||||
|     public MaterialDivider(Context context, AttributeSet attributeSet) { | ||||
|         this(context, attributeSet, R.attr.materialDividerStyle); | ||||
|     } | ||||
|  | ||||
|     /* 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 MaterialDivider(android.content.Context r8, android.util.AttributeSet r9, int r10) { | ||||
|         /* | ||||
|             r7 = this; | ||||
|             int r4 = com.google.android.material.divider.MaterialDivider.DEF_STYLE_RES | ||||
|             android.content.Context r8 = com.google.android.material.theme.overlay.MaterialThemeOverlay.wrap(r8, r9, r10, r4) | ||||
|             r7.<init>(r8, r9, r10) | ||||
|             android.content.Context r8 = r7.getContext() | ||||
|             com.google.android.material.shape.MaterialShapeDrawable r0 = new com.google.android.material.shape.MaterialShapeDrawable | ||||
|             r0.<init>() | ||||
|             r7.dividerDrawable = r0 | ||||
|             int[] r2 = com.google.android.material.R.styleable.MaterialDivider | ||||
|             r6 = 0 | ||||
|             int[] r5 = new int[r6] | ||||
|             r0 = r8 | ||||
|             r1 = r9 | ||||
|             r3 = r10 | ||||
|             android.content.res.TypedArray r9 = com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(r0, r1, r2, r3, r4, r5) | ||||
|             int r10 = com.google.android.material.R.styleable.MaterialDivider_dividerThickness | ||||
|             android.content.res.Resources r0 = r7.getResources() | ||||
|             int r1 = com.google.android.material.R.dimen.material_divider_thickness | ||||
|             int r0 = r0.getDimensionPixelSize(r1) | ||||
|             int r10 = r9.getDimensionPixelSize(r10, r0) | ||||
|             r7.thickness = r10 | ||||
|             int r10 = com.google.android.material.R.styleable.MaterialDivider_dividerInsetStart | ||||
|             int r10 = r9.getDimensionPixelOffset(r10, r6) | ||||
|             r7.insetStart = r10 | ||||
|             int r10 = com.google.android.material.R.styleable.MaterialDivider_dividerInsetEnd | ||||
|             int r10 = r9.getDimensionPixelOffset(r10, r6) | ||||
|             r7.insetEnd = r10 | ||||
|             int r10 = com.google.android.material.R.styleable.MaterialDivider_dividerColor | ||||
|             android.content.res.ColorStateList r8 = com.google.android.material.resources.MaterialResources.getColorStateList(r8, r9, r10) | ||||
|             int r8 = r8.getDefaultColor() | ||||
|             r7.setDividerColor(r8) | ||||
|             r9.recycle() | ||||
|             return | ||||
|         */ | ||||
|         throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.divider.MaterialDivider.<init>(android.content.Context, android.util.AttributeSet, int):void"); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     protected void onMeasure(int i, int i2) { | ||||
|         super.onMeasure(i, i2); | ||||
|         int mode = View.MeasureSpec.getMode(i2); | ||||
|         int measuredHeight = getMeasuredHeight(); | ||||
|         if (mode == Integer.MIN_VALUE || mode == 0) { | ||||
|             int i3 = this.thickness; | ||||
|             if (i3 > 0 && measuredHeight != i3) { | ||||
|                 measuredHeight = i3; | ||||
|             } | ||||
|             setMeasuredDimension(getMeasuredWidth(), measuredHeight); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     protected void onDraw(Canvas canvas) { | ||||
|         int width; | ||||
|         int i; | ||||
|         super.onDraw(canvas); | ||||
|         boolean z = ViewCompat.getLayoutDirection(this) == 1; | ||||
|         int i2 = z ? this.insetEnd : this.insetStart; | ||||
|         if (z) { | ||||
|             width = getWidth(); | ||||
|             i = this.insetStart; | ||||
|         } else { | ||||
|             width = getWidth(); | ||||
|             i = this.insetEnd; | ||||
|         } | ||||
|         this.dividerDrawable.setBounds(i2, 0, width - i, getBottom() - getTop()); | ||||
|         this.dividerDrawable.draw(canvas); | ||||
|     } | ||||
|  | ||||
|     public void setDividerThickness(int i) { | ||||
|         if (this.thickness != i) { | ||||
|             this.thickness = i; | ||||
|             requestLayout(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void setDividerThicknessResource(int i) { | ||||
|         setDividerThickness(getContext().getResources().getDimensionPixelSize(i)); | ||||
|     } | ||||
|  | ||||
|     public void setDividerInsetStartResource(int i) { | ||||
|         setDividerInsetStart(getContext().getResources().getDimensionPixelOffset(i)); | ||||
|     } | ||||
|  | ||||
|     public void setDividerInsetEndResource(int i) { | ||||
|         setDividerInsetEnd(getContext().getResources().getDimensionPixelOffset(i)); | ||||
|     } | ||||
|  | ||||
|     public void setDividerColor(int i) { | ||||
|         if (this.color != i) { | ||||
|             this.color = i; | ||||
|             this.dividerDrawable.setFillColor(ColorStateList.valueOf(i)); | ||||
|             invalidate(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void setDividerColorResource(int i) { | ||||
|         setDividerColor(ContextCompat.getColor(getContext(), i)); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,230 @@ | ||||
| package com.google.android.material.divider; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.TypedArray; | ||||
| import android.graphics.Canvas; | ||||
| import android.graphics.Rect; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.graphics.drawable.ShapeDrawable; | ||||
| import android.util.AttributeSet; | ||||
| import android.view.View; | ||||
| import androidx.core.content.ContextCompat; | ||||
| import androidx.core.graphics.drawable.DrawableCompat; | ||||
| import androidx.recyclerview.widget.RecyclerView; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.internal.ThemeEnforcement; | ||||
| import com.google.android.material.internal.ViewUtils; | ||||
| import com.google.android.material.resources.MaterialResources; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class MaterialDividerItemDecoration extends RecyclerView.ItemDecoration { | ||||
|     private static final int DEF_STYLE_RES = R.style.Widget_MaterialComponents_MaterialDivider; | ||||
|     public static final int HORIZONTAL = 0; | ||||
|     public static final int VERTICAL = 1; | ||||
|     private int color; | ||||
|     private Drawable dividerDrawable; | ||||
|     private int insetEnd; | ||||
|     private int insetStart; | ||||
|     private boolean lastItemDecorated; | ||||
|     private int orientation; | ||||
|     private final Rect tempRect; | ||||
|     private int thickness; | ||||
|  | ||||
|     public int getDividerColor() { | ||||
|         return this.color; | ||||
|     } | ||||
|  | ||||
|     public int getDividerInsetEnd() { | ||||
|         return this.insetEnd; | ||||
|     } | ||||
|  | ||||
|     public int getDividerInsetStart() { | ||||
|         return this.insetStart; | ||||
|     } | ||||
|  | ||||
|     public int getDividerThickness() { | ||||
|         return this.thickness; | ||||
|     } | ||||
|  | ||||
|     public int getOrientation() { | ||||
|         return this.orientation; | ||||
|     } | ||||
|  | ||||
|     public boolean isLastItemDecorated() { | ||||
|         return this.lastItemDecorated; | ||||
|     } | ||||
|  | ||||
|     public void setDividerInsetEnd(int i) { | ||||
|         this.insetEnd = i; | ||||
|     } | ||||
|  | ||||
|     public void setDividerInsetStart(int i) { | ||||
|         this.insetStart = i; | ||||
|     } | ||||
|  | ||||
|     public void setDividerThickness(int i) { | ||||
|         this.thickness = i; | ||||
|     } | ||||
|  | ||||
|     public void setLastItemDecorated(boolean z) { | ||||
|         this.lastItemDecorated = z; | ||||
|     } | ||||
|  | ||||
|     protected boolean shouldDrawDivider(int i, RecyclerView.Adapter<?> adapter) { | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     public MaterialDividerItemDecoration(Context context, int i) { | ||||
|         this(context, null, i); | ||||
|     } | ||||
|  | ||||
|     public MaterialDividerItemDecoration(Context context, AttributeSet attributeSet, int i) { | ||||
|         this(context, attributeSet, R.attr.materialDividerStyle, i); | ||||
|     } | ||||
|  | ||||
|     public MaterialDividerItemDecoration(Context context, AttributeSet attributeSet, int i, int i2) { | ||||
|         this.tempRect = new Rect(); | ||||
|         TypedArray obtainStyledAttributes = ThemeEnforcement.obtainStyledAttributes(context, attributeSet, R.styleable.MaterialDivider, i, DEF_STYLE_RES, new int[0]); | ||||
|         this.color = MaterialResources.getColorStateList(context, obtainStyledAttributes, R.styleable.MaterialDivider_dividerColor).getDefaultColor(); | ||||
|         this.thickness = obtainStyledAttributes.getDimensionPixelSize(R.styleable.MaterialDivider_dividerThickness, context.getResources().getDimensionPixelSize(R.dimen.material_divider_thickness)); | ||||
|         this.insetStart = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.MaterialDivider_dividerInsetStart, 0); | ||||
|         this.insetEnd = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.MaterialDivider_dividerInsetEnd, 0); | ||||
|         this.lastItemDecorated = obtainStyledAttributes.getBoolean(R.styleable.MaterialDivider_lastItemDecorated, true); | ||||
|         obtainStyledAttributes.recycle(); | ||||
|         this.dividerDrawable = new ShapeDrawable(); | ||||
|         setDividerColor(this.color); | ||||
|         setOrientation(i2); | ||||
|     } | ||||
|  | ||||
|     public void setOrientation(int i) { | ||||
|         if (i == 0 || i == 1) { | ||||
|             this.orientation = i; | ||||
|             return; | ||||
|         } | ||||
|         throw new IllegalArgumentException("Invalid orientation: " + i + ". It should be either HORIZONTAL or VERTICAL"); | ||||
|     } | ||||
|  | ||||
|     public void setDividerThicknessResource(Context context, int i) { | ||||
|         setDividerThickness(context.getResources().getDimensionPixelSize(i)); | ||||
|     } | ||||
|  | ||||
|     public void setDividerColor(int i) { | ||||
|         this.color = i; | ||||
|         Drawable wrap = DrawableCompat.wrap(this.dividerDrawable); | ||||
|         this.dividerDrawable = wrap; | ||||
|         DrawableCompat.setTint(wrap, i); | ||||
|     } | ||||
|  | ||||
|     public void setDividerColorResource(Context context, int i) { | ||||
|         setDividerColor(ContextCompat.getColor(context, i)); | ||||
|     } | ||||
|  | ||||
|     public void setDividerInsetStartResource(Context context, int i) { | ||||
|         setDividerInsetStart(context.getResources().getDimensionPixelOffset(i)); | ||||
|     } | ||||
|  | ||||
|     public void setDividerInsetEndResource(Context context, int i) { | ||||
|         setDividerInsetEnd(context.getResources().getDimensionPixelOffset(i)); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.recyclerview.widget.RecyclerView.ItemDecoration | ||||
|     public void onDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.State state) { | ||||
|         if (recyclerView.getLayoutManager() == null) { | ||||
|             return; | ||||
|         } | ||||
|         if (this.orientation == 1) { | ||||
|             drawForVerticalOrientation(canvas, recyclerView); | ||||
|         } else { | ||||
|             drawForHorizontalOrientation(canvas, recyclerView); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void drawForVerticalOrientation(Canvas canvas, RecyclerView recyclerView) { | ||||
|         int width; | ||||
|         int i; | ||||
|         canvas.save(); | ||||
|         if (recyclerView.getClipToPadding()) { | ||||
|             i = recyclerView.getPaddingLeft(); | ||||
|             width = recyclerView.getWidth() - recyclerView.getPaddingRight(); | ||||
|             canvas.clipRect(i, recyclerView.getPaddingTop(), width, recyclerView.getHeight() - recyclerView.getPaddingBottom()); | ||||
|         } else { | ||||
|             width = recyclerView.getWidth(); | ||||
|             i = 0; | ||||
|         } | ||||
|         boolean isLayoutRtl = ViewUtils.isLayoutRtl(recyclerView); | ||||
|         int i2 = i + (isLayoutRtl ? this.insetEnd : this.insetStart); | ||||
|         int i3 = width - (isLayoutRtl ? this.insetStart : this.insetEnd); | ||||
|         int childCount = recyclerView.getChildCount(); | ||||
|         for (int i4 = 0; i4 < childCount; i4++) { | ||||
|             View childAt = recyclerView.getChildAt(i4); | ||||
|             if (shouldDrawDivider(recyclerView, childAt)) { | ||||
|                 recyclerView.getLayoutManager().getDecoratedBoundsWithMargins(childAt, this.tempRect); | ||||
|                 int round = this.tempRect.bottom + Math.round(childAt.getTranslationY()); | ||||
|                 this.dividerDrawable.setBounds(i2, round - this.thickness, i3, round); | ||||
|                 this.dividerDrawable.draw(canvas); | ||||
|             } | ||||
|         } | ||||
|         canvas.restore(); | ||||
|     } | ||||
|  | ||||
|     private void drawForHorizontalOrientation(Canvas canvas, RecyclerView recyclerView) { | ||||
|         int height; | ||||
|         int i; | ||||
|         int i2; | ||||
|         int i3; | ||||
|         canvas.save(); | ||||
|         if (recyclerView.getClipToPadding()) { | ||||
|             i = recyclerView.getPaddingTop(); | ||||
|             height = recyclerView.getHeight() - recyclerView.getPaddingBottom(); | ||||
|             canvas.clipRect(recyclerView.getPaddingLeft(), i, recyclerView.getWidth() - recyclerView.getPaddingRight(), height); | ||||
|         } else { | ||||
|             height = recyclerView.getHeight(); | ||||
|             i = 0; | ||||
|         } | ||||
|         int i4 = i + this.insetStart; | ||||
|         int i5 = height - this.insetEnd; | ||||
|         boolean isLayoutRtl = ViewUtils.isLayoutRtl(recyclerView); | ||||
|         int childCount = recyclerView.getChildCount(); | ||||
|         for (int i6 = 0; i6 < childCount; i6++) { | ||||
|             View childAt = recyclerView.getChildAt(i6); | ||||
|             if (shouldDrawDivider(recyclerView, childAt)) { | ||||
|                 recyclerView.getLayoutManager().getDecoratedBoundsWithMargins(childAt, this.tempRect); | ||||
|                 int round = Math.round(childAt.getTranslationX()); | ||||
|                 if (isLayoutRtl) { | ||||
|                     i3 = this.tempRect.left + round; | ||||
|                     i2 = this.thickness + i3; | ||||
|                 } else { | ||||
|                     i2 = round + this.tempRect.right; | ||||
|                     i3 = i2 - this.thickness; | ||||
|                 } | ||||
|                 this.dividerDrawable.setBounds(i3, i4, i2, i5); | ||||
|                 this.dividerDrawable.draw(canvas); | ||||
|             } | ||||
|         } | ||||
|         canvas.restore(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.recyclerview.widget.RecyclerView.ItemDecoration | ||||
|     public void getItemOffsets(Rect rect, View view, RecyclerView recyclerView, RecyclerView.State state) { | ||||
|         rect.set(0, 0, 0, 0); | ||||
|         if (shouldDrawDivider(recyclerView, view)) { | ||||
|             if (this.orientation == 1) { | ||||
|                 rect.bottom = this.thickness; | ||||
|             } else if (ViewUtils.isLayoutRtl(recyclerView)) { | ||||
|                 rect.left = this.thickness; | ||||
|             } else { | ||||
|                 rect.right = this.thickness; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private boolean shouldDrawDivider(RecyclerView recyclerView, View view) { | ||||
|         int childAdapterPosition = recyclerView.getChildAdapterPosition(view); | ||||
|         RecyclerView.Adapter adapter = recyclerView.getAdapter(); | ||||
|         boolean z = adapter != null && childAdapterPosition == adapter.getItemCount() - 1; | ||||
|         if (childAdapterPosition != -1) { | ||||
|             return (!z || this.lastItemDecorated) && shouldDrawDivider(childAdapterPosition, (RecyclerView.Adapter<?>) adapter); | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user