package p037.p041.p045.p046;

import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.StateSet;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import p037.p041.p042.LayoutInflaterFactory2C1494;
import p037.p041.p045.p046.C1537;
import p037.p041.p045.p046.C1542;
import p037.p041.p047.C1545;
import p037.p041.p051.C1670;
import p037.p057.C1721;
import p037.p057.C1730;
import p037.p065.p070.p071.InterfaceC1872;
import p037.p119.p120.p121.C2523;
import p037.p119.p120.p121.C2530;
import p138.p139.p143.p144.C2803;

/* JADX INFO: renamed from: މ.ؠ.ފ.֏.֏, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
@SuppressLint({"RestrictedAPI"})
public class C1529 extends C1542 implements InterfaceC1872 {

    /* JADX INFO: renamed from: ޑ, reason: contains not printable characters */
    public C1532 f4854;

    /* JADX INFO: renamed from: ޒ, reason: contains not printable characters */
    public AbstractC1536 f4855;

    /* JADX INFO: renamed from: ޓ, reason: contains not printable characters */
    public int f4856;

    /* JADX INFO: renamed from: ޔ, reason: contains not printable characters */
    public int f4857;

    /* JADX INFO: renamed from: ޕ, reason: contains not printable characters */
    public boolean f4858;

    /* JADX INFO: renamed from: މ.ؠ.ފ.֏.֏$ؠ, reason: contains not printable characters */
    public static class C1531 extends AbstractC1536 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final Animatable f4859;

        public C1531(Animatable animatable) {
            super(null);
            this.f4859 = animatable;
        }

        @Override // p037.p041.p045.p046.C1529.AbstractC1536
        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public void mo3029() {
            this.f4859.start();
        }

        @Override // p037.p041.p045.p046.C1529.AbstractC1536
        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public void mo3030() {
            this.f4859.stop();
        }
    }

    /* JADX INFO: renamed from: މ.ؠ.ފ.֏.֏$ހ, reason: contains not printable characters */
    public static class C1532 extends C1542.C1543 {

        /* JADX INFO: renamed from: ޢ, reason: contains not printable characters */
        public C1721<Long> f4860;

        /* JADX INFO: renamed from: ޣ, reason: contains not printable characters */
        public C1730<Integer> f4861;

        public C1532(C1532 c1532, C1529 c1529, Resources resources) {
            super(c1532, c1529, resources);
            if (c1532 != null) {
                this.f4860 = c1532.f4860;
                this.f4861 = c1532.f4861;
            } else {
                this.f4860 = new C1721<>();
                this.f4861 = new C1730<>();
            }
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public static long m3031(int i, int i2) {
            return ((long) i2) | (((long) i) << 32);
        }

        @Override // p037.p041.p045.p046.C1542.C1543, android.graphics.drawable.Drawable.ConstantState
        public Drawable newDrawable() {
            return new C1529(this, null);
        }

        @Override // p037.p041.p045.p046.C1542.C1543, android.graphics.drawable.Drawable.ConstantState
        public Drawable newDrawable(Resources resources) {
            return new C1529(this, resources);
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public int m3032(int i, int i2, Drawable drawable, boolean z) {
            int iM3042 = super.m3042(drawable);
            long jM3031 = m3031(i, i2);
            long j = z ? 8589934592L : 0L;
            long j2 = iM3042;
            this.f4860.m3363(jM3031, Long.valueOf(j2 | j));
            if (z) {
                this.f4860.m3363(m3031(i2, i), Long.valueOf(4294967296L | j2 | j));
            }
            return iM3042;
        }

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public int m3033(int i) {
            if (i < 0) {
                return 0;
            }
            return this.f4861.m3395(i, 0).intValue();
        }

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public int m3034(int[] iArr) {
            int iM3048 = super.m3048(iArr);
            return iM3048 >= 0 ? iM3048 : super.m3048(StateSet.WILD_CARD);
        }

        @Override // p037.p041.p045.p046.C1542.C1543, p037.p041.p045.p046.C1537.AbstractC1540
        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public void mo3035() {
            this.f4860 = this.f4860.clone();
            this.f4861 = this.f4861.clone();
        }
    }

    /* JADX INFO: renamed from: މ.ؠ.ފ.֏.֏$ށ, reason: contains not printable characters */
    public static class C1533 extends AbstractC1536 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final C2523 f4862;

        public C1533(C2523 c2523) {
            super(null);
            this.f4862 = c2523;
        }

        @Override // p037.p041.p045.p046.C1529.AbstractC1536
        /* JADX INFO: renamed from: ހ */
        public void mo3029() {
            this.f4862.start();
        }

        @Override // p037.p041.p045.p046.C1529.AbstractC1536
        /* JADX INFO: renamed from: ށ */
        public void mo3030() {
            this.f4862.stop();
        }
    }

    /* JADX INFO: renamed from: މ.ؠ.ފ.֏.֏$ނ, reason: contains not printable characters */
    public static class C1534 extends AbstractC1536 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final ObjectAnimator f4863;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final boolean f4864;

        public C1534(AnimationDrawable animationDrawable, boolean z, boolean z2) {
            super(null);
            int numberOfFrames = animationDrawable.getNumberOfFrames();
            int i = z ? numberOfFrames - 1 : 0;
            int i2 = z ? 0 : numberOfFrames - 1;
            C1535 c1535 = new C1535(animationDrawable, z);
            ObjectAnimator objectAnimatorOfInt = ObjectAnimator.ofInt(animationDrawable, "currentIndex", i, i2);
            objectAnimatorOfInt.setAutoCancel(true);
            objectAnimatorOfInt.setDuration(c1535.f4867);
            objectAnimatorOfInt.setInterpolator(c1535);
            this.f4864 = z2;
            this.f4863 = objectAnimatorOfInt;
        }

        @Override // p037.p041.p045.p046.C1529.AbstractC1536
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public boolean mo3036() {
            return this.f4864;
        }

        @Override // p037.p041.p045.p046.C1529.AbstractC1536
        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public void mo3037() {
            this.f4863.reverse();
        }

        @Override // p037.p041.p045.p046.C1529.AbstractC1536
        /* JADX INFO: renamed from: ހ */
        public void mo3029() {
            this.f4863.start();
        }

        @Override // p037.p041.p045.p046.C1529.AbstractC1536
        /* JADX INFO: renamed from: ށ */
        public void mo3030() {
            this.f4863.cancel();
        }
    }

    /* JADX INFO: renamed from: މ.ؠ.ފ.֏.֏$ރ, reason: contains not printable characters */
    public static class C1535 implements TimeInterpolator {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public int[] f4865;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public int f4866;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public int f4867;

        public C1535(AnimationDrawable animationDrawable, boolean z) {
            int numberOfFrames = animationDrawable.getNumberOfFrames();
            this.f4866 = numberOfFrames;
            int[] iArr = this.f4865;
            if (iArr == null || iArr.length < numberOfFrames) {
                this.f4865 = new int[numberOfFrames];
            }
            int[] iArr2 = this.f4865;
            int i = 0;
            for (int i2 = 0; i2 < numberOfFrames; i2++) {
                int duration = animationDrawable.getDuration(z ? (numberOfFrames - i2) - 1 : i2);
                iArr2[i2] = duration;
                i += duration;
            }
            this.f4867 = i;
        }

        @Override // android.animation.TimeInterpolator
        public float getInterpolation(float f) {
            int i = (int) ((f * this.f4867) + 0.5f);
            int i2 = this.f4866;
            int[] iArr = this.f4865;
            int i3 = 0;
            while (i3 < i2 && i >= iArr[i3]) {
                i -= iArr[i3];
                i3++;
            }
            return (i3 / i2) + (i3 < i2 ? i / this.f4867 : 0.0f);
        }
    }

    /* JADX INFO: renamed from: މ.ؠ.ފ.֏.֏$ބ, reason: contains not printable characters */
    public static abstract class AbstractC1536 {
        public /* synthetic */ AbstractC1536(C1530 c1530) {
        }

        /* JADX INFO: renamed from: ֏ */
        public boolean mo3036() {
            return false;
        }

        /* JADX INFO: renamed from: ؠ */
        public void mo3037() {
        }

        /* JADX INFO: renamed from: ހ */
        public abstract void mo3029();

        /* JADX INFO: renamed from: ށ */
        public abstract void mo3030();
    }

    public C1529() {
        this(null, null);
    }

    public C1529(C1532 c1532, Resources resources) {
        super(null);
        this.f4856 = -1;
        this.f4857 = -1;
        C1532 c15322 = new C1532(c1532, this, resources);
        super.mo3028(c15322);
        this.f4854 = c15322;
        onStateChange(getState());
        jumpToCurrentState();
    }

    /* JADX WARN: Code restructure failed: missing block: B:82:0x01e7, code lost:
    
        r5.onStateChange(r5.getState());
     */
    /* JADX WARN: Code restructure failed: missing block: B:83:0x01ee, code lost:
    
        return r5;
     */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static C1529 m3026(Context context, Resources resources, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme) throws XmlPullParserException, IOException {
        int depth;
        Drawable drawable;
        int next;
        int next2;
        String name = xmlPullParser.getName();
        if (!name.equals("animated-selector")) {
            throw new XmlPullParserException(xmlPullParser.getPositionDescription() + ": invalid animated-selector tag " + name);
        }
        Drawable drawableCreateFromXmlInner = null;
        C1529 c1529 = new C1529(null, null);
        TypedArray typedArrayM2894 = LayoutInflaterFactory2C1494.C1505.m2894(resources, theme, attributeSet, C1545.AnimatedStateListDrawableCompat);
        int i = 1;
        c1529.setVisible(typedArrayM2894.getBoolean(C1545.AnimatedStateListDrawableCompat_android_visible, true), true);
        C1532 c1532 = c1529.f4854;
        c1532.f4885 |= typedArrayM2894.getChangingConfigurations();
        c1532.f4890 = typedArrayM2894.getBoolean(C1545.AnimatedStateListDrawableCompat_android_variablePadding, c1532.f4890);
        c1532.f4893 = typedArrayM2894.getBoolean(C1545.AnimatedStateListDrawableCompat_android_constantSize, c1532.f4893);
        c1532.f4908 = typedArrayM2894.getInt(C1545.AnimatedStateListDrawableCompat_android_enterFadeDuration, c1532.f4908);
        c1532.f4909 = typedArrayM2894.getInt(C1545.AnimatedStateListDrawableCompat_android_exitFadeDuration, c1532.f4909);
        c1529.setDither(typedArrayM2894.getBoolean(C1545.AnimatedStateListDrawableCompat_android_dither, c1532.f4905));
        c1529.f4868.m3044(resources);
        typedArrayM2894.recycle();
        int depth2 = xmlPullParser.getDepth() + 1;
        while (true) {
            int next3 = xmlPullParser.next();
            if (next3 == i || ((depth = xmlPullParser.getDepth()) < depth2 && next3 == 3)) {
                break;
            }
            if (next3 == 2 && depth <= depth2) {
                if (xmlPullParser.getName().equals("item")) {
                    TypedArray typedArrayM28942 = LayoutInflaterFactory2C1494.C1505.m2894(resources, theme, attributeSet, C1545.AnimatedStateListDrawableItem);
                    int resourceId = typedArrayM28942.getResourceId(C1545.AnimatedStateListDrawableItem_android_id, 0);
                    int resourceId2 = typedArrayM28942.getResourceId(C1545.AnimatedStateListDrawableItem_android_drawable, -1);
                    if (resourceId2 > 0) {
                        drawableCreateFromXmlInner = C1670.m3261().m3273(context, resourceId2);
                    }
                    typedArrayM28942.recycle();
                    int attributeCount = attributeSet.getAttributeCount();
                    int[] iArr = new int[attributeCount];
                    int i2 = 0;
                    for (int i3 = 0; i3 < attributeCount; i3++) {
                        int attributeNameResource = attributeSet.getAttributeNameResource(i3);
                        if (attributeNameResource != 0 && attributeNameResource != 16842960 && attributeNameResource != 16843161) {
                            int i4 = i2 + 1;
                            if (!attributeSet.getAttributeBooleanValue(i3, false)) {
                                attributeNameResource = -attributeNameResource;
                            }
                            iArr[i2] = attributeNameResource;
                            i2 = i4;
                        }
                    }
                    int[] iArrTrimStateSet = StateSet.trimStateSet(iArr, i2);
                    if (drawableCreateFromXmlInner == null) {
                        do {
                            next2 = xmlPullParser.next();
                        } while (next2 == 4);
                        if (next2 != 2) {
                            throw new XmlPullParserException(C2803.m4886(xmlPullParser, new StringBuilder(), ": <item> tag requires a 'drawable' attribute or child tag defining a drawable"));
                        }
                        drawableCreateFromXmlInner = xmlPullParser.getName().equals("vector") ? C2530.createFromXmlInner(resources, xmlPullParser, attributeSet, theme) : Drawable.createFromXmlInner(resources, xmlPullParser, attributeSet, theme);
                    }
                    if (drawableCreateFromXmlInner == null) {
                        throw new XmlPullParserException(C2803.m4886(xmlPullParser, new StringBuilder(), ": <item> tag requires a 'drawable' attribute or child tag defining a drawable"));
                    }
                    C1532 c15322 = c1529.f4854;
                    int iM3042 = c15322.m3042(drawableCreateFromXmlInner);
                    c15322.f4920[iM3042] = iArrTrimStateSet;
                    c15322.f4861.m3398(iM3042, Integer.valueOf(resourceId));
                } else {
                    if (xmlPullParser.getName().equals("transition")) {
                        TypedArray typedArrayM28943 = LayoutInflaterFactory2C1494.C1505.m2894(resources, theme, attributeSet, C1545.AnimatedStateListDrawableTransition);
                        int resourceId3 = typedArrayM28943.getResourceId(C1545.AnimatedStateListDrawableTransition_android_fromId, -1);
                        int resourceId4 = typedArrayM28943.getResourceId(C1545.AnimatedStateListDrawableTransition_android_toId, -1);
                        int resourceId5 = typedArrayM28943.getResourceId(C1545.AnimatedStateListDrawableTransition_android_drawable, -1);
                        Drawable drawableM3273 = resourceId5 > 0 ? C1670.m3261().m3273(context, resourceId5) : null;
                        boolean z = typedArrayM28943.getBoolean(C1545.AnimatedStateListDrawableTransition_android_reversible, false);
                        typedArrayM28943.recycle();
                        if (drawableM3273 == null) {
                            do {
                                next = xmlPullParser.next();
                            } while (next == 4);
                            if (next != 2) {
                                throw new XmlPullParserException(C2803.m4886(xmlPullParser, new StringBuilder(), ": <transition> tag requires a 'drawable' attribute or child tag defining a drawable"));
                            }
                            if (xmlPullParser.getName().equals("animated-vector")) {
                                drawable = null;
                                drawableM3273 = new C2523(context, null, null);
                                drawableM3273.inflate(resources, xmlPullParser, attributeSet, theme);
                            } else {
                                drawable = null;
                                drawableM3273 = Drawable.createFromXmlInner(resources, xmlPullParser, attributeSet, theme);
                            }
                        } else {
                            drawable = null;
                        }
                        if (drawableM3273 == null) {
                            throw new XmlPullParserException(C2803.m4886(xmlPullParser, new StringBuilder(), ": <transition> tag requires a 'drawable' attribute or child tag defining a drawable"));
                        }
                        if (resourceId3 == -1 || resourceId4 == -1) {
                            break;
                        }
                        c1529.f4854.m3032(resourceId3, resourceId4, drawableM3273, z);
                        drawableCreateFromXmlInner = drawable;
                    }
                    i = 1;
                }
                drawableCreateFromXmlInner = null;
                i = 1;
            }
        }
        throw new XmlPullParserException(C2803.m4886(xmlPullParser, new StringBuilder(), ": <transition> tag requires 'fromId' & 'toId' attributes"));
    }

    @Override // p037.p041.p045.p046.C1542, android.graphics.drawable.Drawable
    public boolean isStateful() {
        return true;
    }

    @Override // p037.p041.p045.p046.C1537, android.graphics.drawable.Drawable
    public void jumpToCurrentState() {
        super.jumpToCurrentState();
        AbstractC1536 abstractC1536 = this.f4855;
        if (abstractC1536 != null) {
            abstractC1536.mo3030();
            this.f4855 = null;
            m3041(this.f4856);
            this.f4856 = -1;
            this.f4857 = -1;
        }
    }

    @Override // p037.p041.p045.p046.C1542, p037.p041.p045.p046.C1537, android.graphics.drawable.Drawable
    public Drawable mutate() {
        if (!this.f4858) {
            super.mutate();
            if (this == this) {
                this.f4854.mo3035();
                this.f4858 = true;
            }
        }
        return this;
    }

    /* JADX WARN: Removed duplicated region for block: B:22:0x0067  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x00e2  */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00e8  */
    @Override // p037.p041.p045.p046.C1542, android.graphics.drawable.Drawable
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public boolean onStateChange(int[] iArr) {
        C1532 c1532;
        int iM3033;
        int iM30332;
        boolean z;
        int iLongValue;
        AbstractC1536 c1531;
        int iM3034 = this.f4854.m3034(iArr);
        int i = this.f4874;
        boolean z2 = false;
        if (iM3034 != i) {
            AbstractC1536 abstractC1536 = this.f4855;
            if (abstractC1536 == null) {
                this.f4855 = null;
                this.f4857 = -1;
                this.f4856 = -1;
                c1532 = this.f4854;
                iM3033 = c1532.m3033(i);
                iM30332 = c1532.m3033(iM3034);
                if (iM30332 != 0 && iM3033 != 0) {
                    iLongValue = (int) c1532.f4860.m3364(C1532.m3031(iM3033, iM30332), -1L).longValue();
                    if (iLongValue >= 0) {
                        boolean z3 = (c1532.f4860.m3364(C1532.m3031(iM3033, iM30332), -1L).longValue() & 8589934592L) != 0;
                        m3041(iLongValue);
                        Object obj = this.f4870;
                        if (obj instanceof AnimationDrawable) {
                            c1531 = new C1534((AnimationDrawable) obj, (c1532.f4860.m3364(C1532.m3031(iM3033, iM30332), -1L).longValue() & 4294967296L) != 0, z3);
                        } else if (obj instanceof C2523) {
                            c1531 = new C1533((C2523) obj);
                        } else if (obj instanceof Animatable) {
                            c1531 = new C1531((Animatable) obj);
                        }
                        c1531.mo3029();
                        this.f4855 = c1531;
                        this.f4857 = i;
                        this.f4856 = iM3034;
                        z = true;
                        if (!z || m3041(iM3034)) {
                            z2 = true;
                        }
                    }
                }
                z = false;
                if (!z) {
                    z2 = true;
                }
            } else {
                if (iM3034 != this.f4856) {
                    if (iM3034 == this.f4857 && abstractC1536.mo3036()) {
                        abstractC1536.mo3037();
                        this.f4856 = this.f4857;
                        this.f4857 = iM3034;
                    } else {
                        i = this.f4856;
                        abstractC1536.mo3030();
                        this.f4855 = null;
                        this.f4857 = -1;
                        this.f4856 = -1;
                        c1532 = this.f4854;
                        iM3033 = c1532.m3033(i);
                        iM30332 = c1532.m3033(iM3034);
                        if (iM30332 != 0) {
                            iLongValue = (int) c1532.f4860.m3364(C1532.m3031(iM3033, iM30332), -1L).longValue();
                            if (iLongValue >= 0) {
                            }
                        }
                        z = false;
                        if (!z) {
                        }
                    }
                }
                z = true;
                if (!z) {
                }
            }
        }
        Drawable drawable = this.f4870;
        return drawable != null ? z2 | drawable.setState(iArr) : z2;
    }

    @Override // p037.p041.p045.p046.C1537, android.graphics.drawable.Drawable
    public boolean setVisible(boolean z, boolean z2) {
        boolean visible = super.setVisible(z, z2);
        if (this.f4855 != null && (visible || z2)) {
            if (z) {
                this.f4855.mo3029();
            } else {
                jumpToCurrentState();
            }
        }
        return visible;
    }

    @Override // p037.p041.p045.p046.C1542, p037.p041.p045.p046.C1537
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public C1537.AbstractC1540 mo3027() {
        return new C1532(this.f4854, this, null);
    }

    @Override // p037.p041.p045.p046.C1542, p037.p041.p045.p046.C1537
    /* JADX INFO: renamed from: ֏ */
    public C1542.C1543 mo3027() {
        return new C1532(this.f4854, this, null);
    }

    @Override // p037.p041.p045.p046.C1542, p037.p041.p045.p046.C1537
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void mo3028(C1537.AbstractC1540 abstractC1540) {
        super.mo3028(abstractC1540);
        if (abstractC1540 instanceof C1532) {
            this.f4854 = (C1532) abstractC1540;
        }
    }
}
