package X6FRs_4.KQgRr5e_0.LGe8pk_15;

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.util.AttributeSet;
import android.widget.ProgressBar;
/* compiled from: AppCompatProgressBarHelper.java */
/* loaded from: classes.dex */
public class Xgtqvk_8 {
    public static final int[] KQgRr5e_0 = {16843067, 16843068};

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public Bitmap f779KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final ProgressBar f780KQgRr5e_0;

    public Xgtqvk_8(ProgressBar progressBar) {
        this.f780KQgRr5e_0 = progressBar;
    }

    public void KQgRr5e_0(AttributeSet attributeSet, int i) {
        NzhupJ_29 KQgRr5e_02 = NzhupJ_29.KQgRr5e_0(this.f780KQgRr5e_0.getContext(), attributeSet, KQgRr5e_0, i, 0);
        Drawable QxJ9d_1 = KQgRr5e_02.QxJ9d_1(0);
        if (QxJ9d_1 != null) {
            this.f780KQgRr5e_0.setIndeterminateDrawable(KQgRr5e_0(QxJ9d_1));
        }
        Drawable QxJ9d_12 = KQgRr5e_02.QxJ9d_1(1);
        if (QxJ9d_12 != null) {
            this.f780KQgRr5e_0.setProgressDrawable(KQgRr5e_0(QxJ9d_12, false));
        }
        KQgRr5e_02.KQgRr5e_0();
    }

    public final Drawable KQgRr5e_0(Drawable drawable, boolean z) {
        if (drawable instanceof X6FRs_4.IMuAHx_6.IFxWkV_5.XnFJ5_9.PGPF6hQ_2) {
            X6FRs_4.IMuAHx_6.IFxWkV_5.XnFJ5_9.PGPF6hQ_2 pGPF6hQ_2 = (X6FRs_4.IMuAHx_6.IFxWkV_5.XnFJ5_9.PGPF6hQ_2) drawable;
            Drawable KQgRr5e_02 = pGPF6hQ_2.KQgRr5e_0();
            if (KQgRr5e_02 != null) {
                pGPF6hQ_2.KQgRr5e_0(KQgRr5e_0(KQgRr5e_02, 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] = KQgRr5e_0(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));
            }
            return layerDrawable2;
        } else if (drawable instanceof BitmapDrawable) {
            BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
            Bitmap bitmap = bitmapDrawable.getBitmap();
            if (this.f779KQgRr5e_0 == null) {
                this.f779KQgRr5e_0 = bitmap;
            }
            ShapeDrawable shapeDrawable = new ShapeDrawable(m445KQgRr5e_0());
            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;
    }

    public final Drawable KQgRr5e_0(Drawable drawable) {
        if (drawable instanceof AnimationDrawable) {
            AnimationDrawable animationDrawable = (AnimationDrawable) drawable;
            int numberOfFrames = animationDrawable.getNumberOfFrames();
            AnimationDrawable animationDrawable2 = new AnimationDrawable();
            animationDrawable2.setOneShot(animationDrawable.isOneShot());
            for (int i = 0; i < numberOfFrames; i++) {
                Drawable KQgRr5e_02 = KQgRr5e_0(animationDrawable.getFrame(i), true);
                KQgRr5e_02.setLevel(10000);
                animationDrawable2.addFrame(KQgRr5e_02, animationDrawable.getDuration(i));
            }
            animationDrawable2.setLevel(10000);
            return animationDrawable2;
        }
        return drawable;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public final Shape m445KQgRr5e_0() {
        return new RoundRectShape(new float[]{5.0f, 5.0f, 5.0f, 5.0f, 5.0f, 5.0f, 5.0f, 5.0f}, null, null);
    }

    public Bitmap KQgRr5e_0() {
        return this.f779KQgRr5e_0;
    }
}
