ADD week 5
This commit is contained in:
		| @@ -0,0 +1,125 @@ | ||||
| package androidx.appcompat.widget; | ||||
|  | ||||
| import android.R; | ||||
| import android.graphics.Bitmap; | ||||
| import android.graphics.BitmapShader; | ||||
| import android.graphics.Shader; | ||||
| import android.graphics.drawable.AnimationDrawable; | ||||
| import android.graphics.drawable.BitmapDrawable; | ||||
| import android.graphics.drawable.ClipDrawable; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.graphics.drawable.LayerDrawable; | ||||
| import android.graphics.drawable.ShapeDrawable; | ||||
| import android.graphics.drawable.shapes.RoundRectShape; | ||||
| import android.graphics.drawable.shapes.Shape; | ||||
| import android.os.Build; | ||||
| import android.util.AttributeSet; | ||||
| import android.widget.ProgressBar; | ||||
| import androidx.core.graphics.drawable.WrappedDrawable; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class AppCompatProgressBarHelper { | ||||
|     private static final int[] TINT_ATTRS = {R.attr.indeterminateDrawable, R.attr.progressDrawable}; | ||||
|     private Bitmap mSampleTile; | ||||
|     private final ProgressBar mView; | ||||
|  | ||||
|     Bitmap getSampleTile() { | ||||
|         return this.mSampleTile; | ||||
|     } | ||||
|  | ||||
|     AppCompatProgressBarHelper(ProgressBar progressBar) { | ||||
|         this.mView = progressBar; | ||||
|     } | ||||
|  | ||||
|     void loadFromAttributes(AttributeSet attributeSet, int i) { | ||||
|         TintTypedArray obtainStyledAttributes = TintTypedArray.obtainStyledAttributes(this.mView.getContext(), attributeSet, TINT_ATTRS, i, 0); | ||||
|         Drawable drawableIfKnown = obtainStyledAttributes.getDrawableIfKnown(0); | ||||
|         if (drawableIfKnown != null) { | ||||
|             this.mView.setIndeterminateDrawable(tileifyIndeterminate(drawableIfKnown)); | ||||
|         } | ||||
|         Drawable drawableIfKnown2 = obtainStyledAttributes.getDrawableIfKnown(1); | ||||
|         if (drawableIfKnown2 != null) { | ||||
|             this.mView.setProgressDrawable(tileify(drawableIfKnown2, false)); | ||||
|         } | ||||
|         obtainStyledAttributes.recycle(); | ||||
|     } | ||||
|  | ||||
|     /* JADX WARN: Multi-variable type inference failed */ | ||||
|     Drawable tileify(Drawable drawable, boolean z) { | ||||
|         if (drawable instanceof WrappedDrawable) { | ||||
|             WrappedDrawable wrappedDrawable = (WrappedDrawable) drawable; | ||||
|             Drawable wrappedDrawable2 = wrappedDrawable.getWrappedDrawable(); | ||||
|             if (wrappedDrawable2 != null) { | ||||
|                 wrappedDrawable.setWrappedDrawable(tileify(wrappedDrawable2, z)); | ||||
|             } | ||||
|         } else { | ||||
|             if (drawable instanceof LayerDrawable) { | ||||
|                 LayerDrawable layerDrawable = (LayerDrawable) drawable; | ||||
|                 int numberOfLayers = layerDrawable.getNumberOfLayers(); | ||||
|                 Drawable[] drawableArr = new Drawable[numberOfLayers]; | ||||
|                 for (int i = 0; i < numberOfLayers; i++) { | ||||
|                     int id = layerDrawable.getId(i); | ||||
|                     drawableArr[i] = tileify(layerDrawable.getDrawable(i), id == 16908301 || id == 16908303); | ||||
|                 } | ||||
|                 LayerDrawable layerDrawable2 = new LayerDrawable(drawableArr); | ||||
|                 for (int i2 = 0; i2 < numberOfLayers; i2++) { | ||||
|                     layerDrawable2.setId(i2, layerDrawable.getId(i2)); | ||||
|                     if (Build.VERSION.SDK_INT >= 23) { | ||||
|                         Api23Impl.transferLayerProperties(layerDrawable, layerDrawable2, i2); | ||||
|                     } | ||||
|                 } | ||||
|                 return layerDrawable2; | ||||
|             } | ||||
|             if (drawable instanceof BitmapDrawable) { | ||||
|                 BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; | ||||
|                 Bitmap bitmap = bitmapDrawable.getBitmap(); | ||||
|                 if (this.mSampleTile == null) { | ||||
|                     this.mSampleTile = bitmap; | ||||
|                 } | ||||
|                 ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape()); | ||||
|                 shapeDrawable.getPaint().setShader(new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP)); | ||||
|                 shapeDrawable.getPaint().setColorFilter(bitmapDrawable.getPaint().getColorFilter()); | ||||
|                 return z ? new ClipDrawable(shapeDrawable, 3, 1) : shapeDrawable; | ||||
|             } | ||||
|         } | ||||
|         return drawable; | ||||
|     } | ||||
|  | ||||
|     private Drawable tileifyIndeterminate(Drawable drawable) { | ||||
|         if (!(drawable instanceof AnimationDrawable)) { | ||||
|             return drawable; | ||||
|         } | ||||
|         AnimationDrawable animationDrawable = (AnimationDrawable) drawable; | ||||
|         int numberOfFrames = animationDrawable.getNumberOfFrames(); | ||||
|         AnimationDrawable animationDrawable2 = new AnimationDrawable(); | ||||
|         animationDrawable2.setOneShot(animationDrawable.isOneShot()); | ||||
|         for (int i = 0; i < numberOfFrames; i++) { | ||||
|             Drawable tileify = tileify(animationDrawable.getFrame(i), true); | ||||
|             tileify.setLevel(10000); | ||||
|             animationDrawable2.addFrame(tileify, animationDrawable.getDuration(i)); | ||||
|         } | ||||
|         animationDrawable2.setLevel(10000); | ||||
|         return animationDrawable2; | ||||
|     } | ||||
|  | ||||
|     private Shape getDrawableShape() { | ||||
|         return new RoundRectShape(new float[]{5.0f, 5.0f, 5.0f, 5.0f, 5.0f, 5.0f, 5.0f, 5.0f}, null, null); | ||||
|     } | ||||
|  | ||||
|     private static class Api23Impl { | ||||
|         private Api23Impl() { | ||||
|         } | ||||
|  | ||||
|         public static void transferLayerProperties(LayerDrawable layerDrawable, LayerDrawable layerDrawable2, int i) { | ||||
|             layerDrawable2.setLayerGravity(i, layerDrawable.getLayerGravity(i)); | ||||
|             layerDrawable2.setLayerWidth(i, layerDrawable.getLayerWidth(i)); | ||||
|             layerDrawable2.setLayerHeight(i, layerDrawable.getLayerHeight(i)); | ||||
|             layerDrawable2.setLayerInsetLeft(i, layerDrawable.getLayerInsetLeft(i)); | ||||
|             layerDrawable2.setLayerInsetRight(i, layerDrawable.getLayerInsetRight(i)); | ||||
|             layerDrawable2.setLayerInsetTop(i, layerDrawable.getLayerInsetTop(i)); | ||||
|             layerDrawable2.setLayerInsetBottom(i, layerDrawable.getLayerInsetBottom(i)); | ||||
|             layerDrawable2.setLayerInsetStart(i, layerDrawable.getLayerInsetStart(i)); | ||||
|             layerDrawable2.setLayerInsetEnd(i, layerDrawable.getLayerInsetEnd(i)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user