package defpackage;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import android.util.Log;
import com.bumptech.glide.load.engine.GlideException;
import j$.util.Objects;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/* renamed from: ᵖːᵦ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C2359 implements InterfaceC3230 {

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public static final boolean f9228 = Log.isLoggable("GlideRequest", 2);

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final Object f9229;

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public ᵧˉʙ f9230;

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public final List f9231;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final AbstractC0720 f9232;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final Class f9233;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final InterfaceC5190 f9234;

    /* renamed from: ˑᵱ, reason: contains not printable characters */
    public int f9235;

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final int f9236;

    /* renamed from: ᵞʡ, reason: contains not printable characters */
    public Drawable f9237;

    /* renamed from: ᵡʠ, reason: contains not printable characters */
    public volatile C3652 f9238;

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public boolean f9239;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final C4808 f9240;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public int f9241;

    /* renamed from: ᵨᵳʝ, reason: contains not printable characters */
    public Drawable f9242;

    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public final ExecutorC3609 f9243;

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public final InterfaceC5377 f9244;

    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public InterfaceC1725 f9245;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final Object f9246;

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final EnumC5505 f9247;

    /* renamed from: ᵸʓᵠ, reason: contains not printable characters */
    public Drawable f9248;

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public final InterfaceC1634 f9249;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final int f9250;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final C0520 f9251;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public int f9252;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final RuntimeException f9253;

    public C2359(Context context, C0520 c0520, Object obj, Object obj2, Class cls, AbstractC0720 abstractC0720, int i, int i2, EnumC5505 enumC5505, InterfaceC1634 interfaceC1634, ArrayList arrayList, InterfaceC5190 interfaceC5190, C3652 c3652, InterfaceC5377 interfaceC5377) {
        ExecutorC3609 executorC3609 = ᵯᵽᵦ.ᵥᵯˎ;
        if (f9228) {
            String.valueOf(hashCode());
        }
        this.f9240 = new C4808();
        this.f9246 = obj;
        this.f9251 = c0520;
        this.f9229 = obj2;
        this.f9233 = cls;
        this.f9232 = abstractC0720;
        this.f9250 = i;
        this.f9236 = i2;
        this.f9247 = enumC5505;
        this.f9249 = interfaceC1634;
        this.f9231 = arrayList;
        this.f9234 = interfaceC5190;
        this.f9238 = c3652;
        this.f9244 = interfaceC5377;
        this.f9243 = executorC3609;
        this.f9252 = 1;
        if (this.f9253 == null && ((Map) c0520.f2699.f13883).containsKey(ᵛᵾˏ.class)) {
            this.f9253 = new RuntimeException("Glide request origin trace");
        }
    }

    @Override // defpackage.InterfaceC3230
    public final void clear() {
        synchronized (this.f9246) {
            try {
                if (this.f9239) {
                    throw new IllegalStateException("You can't start or clear loads in RequestListener or Target callbacks. If you're trying to start a fallback request when a load fails, use RequestBuilder#error(RequestBuilder). Otherwise consider posting your into() or clear() calls to the main thread using a Handler instead.");
                }
                this.f9240.m10131();
                if (this.f9252 == 6) {
                    return;
                }
                m6116();
                InterfaceC1725 interfaceC1725 = this.f9245;
                if (interfaceC1725 != null) {
                    this.f9245 = null;
                } else {
                    interfaceC1725 = null;
                }
                InterfaceC5190 interfaceC5190 = this.f9234;
                if (interfaceC5190 == null || interfaceC5190.mo9003(this)) {
                    this.f9249.mo3538(m6123());
                }
                this.f9252 = 6;
                if (interfaceC1725 != null) {
                    this.f9238.getClass();
                    C3652.m8241(interfaceC1725);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // defpackage.InterfaceC3230
    public final boolean isRunning() {
        boolean z;
        synchronized (this.f9246) {
            int i = this.f9252;
            z = i == 2 || i == 3;
        }
        return z;
    }

    public final String toString() {
        Object obj;
        Class cls;
        synchronized (this.f9246) {
            obj = this.f9229;
            cls = this.f9233;
        }
        return super.toString() + "[model=" + obj + ", transcodeClass=" + cls + "]";
    }

    @Override // defpackage.InterfaceC3230
    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final void mo6112() {
        synchronized (this.f9246) {
            try {
                if (isRunning()) {
                    clear();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r1v1 */
    /* JADX WARN: Type inference failed for: r1v15 */
    /* JADX WARN: Type inference failed for: r1v2 */
    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public final void m6113(int i, int i2) {
        ?? r1;
        int i3 = i;
        this.f9240.m10131();
        Object obj = this.f9246;
        synchronized (obj) {
            try {
                try {
                    boolean z = f9228;
                    if (z) {
                        int i4 = AbstractC4846.f17991;
                        SystemClock.elapsedRealtimeNanos();
                    }
                    if (this.f9252 != 3) {
                        return;
                    }
                    this.f9252 = 2;
                    this.f9232.getClass();
                    this.f9235 = i3 == Integer.MIN_VALUE ? i3 : Math.round(i3 * 1.0f);
                    this.f9241 = i2 == Integer.MIN_VALUE ? i2 : Math.round(1.0f * i2);
                    if (z) {
                        int i5 = AbstractC4846.f17991;
                        SystemClock.elapsedRealtimeNanos();
                    }
                    C3652 c3652 = this.f9238;
                    C0520 c0520 = this.f9251;
                    Object obj2 = this.f9229;
                    AbstractC0720 abstractC0720 = this.f9232;
                    this.f9230 = c3652.m8245(c0520, obj2, abstractC0720.f3462, this.f9235, this.f9241, abstractC0720.f3466, this.f9233, this.f9247, abstractC0720.f3464, abstractC0720.f3468, abstractC0720.f3460, abstractC0720.f3469, abstractC0720.f3459, abstractC0720.f3465, abstractC0720.f3458, this, this.f9243);
                    if (this.f9252 != 2) {
                        this.f9230 = null;
                    }
                    if (z) {
                        int i6 = AbstractC4846.f17991;
                        SystemClock.elapsedRealtimeNanos();
                    }
                } catch (Throwable th) {
                    th = th;
                    r1 = obj;
                    throw th;
                }
            } catch (Throwable th2) {
                th = th2;
                r1 = i3;
            }
        }
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final void m6114(InterfaceC1725 interfaceC1725, int i) {
        this.f9240.m10131();
        InterfaceC1725 interfaceC17252 = null;
        try {
            synchronized (this.f9246) {
                try {
                    this.f9230 = null;
                    if (interfaceC1725 == null) {
                        m6115(new GlideException("Expected to receive a Resource<R> with an object of " + this.f9233 + " inside, but instead got null."), 5);
                        return;
                    }
                    Object obj = interfaceC1725.get();
                    try {
                        if (obj == null || !this.f9233.isAssignableFrom(obj.getClass())) {
                            this.f9245 = null;
                            StringBuilder sb = new StringBuilder("Expected to receive an object of ");
                            sb.append(this.f9233);
                            sb.append(" but instead got ");
                            sb.append(obj != null ? obj.getClass() : "");
                            sb.append("{");
                            sb.append(obj);
                            sb.append("} inside Resource{");
                            sb.append(interfaceC1725);
                            sb.append("}.");
                            sb.append(obj != null ? "" : " To indicate failure return a null Resource object, rather than a Resource object containing null data.");
                            m6115(new GlideException(sb.toString()), 5);
                        } else {
                            InterfaceC5190 interfaceC5190 = this.f9234;
                            if (interfaceC5190 == null || interfaceC5190.mo9005(this)) {
                                m6122(interfaceC1725, obj, i);
                                return;
                            } else {
                                this.f9245 = null;
                                this.f9252 = 4;
                            }
                        }
                        this.f9238.getClass();
                        C3652.m8241(interfaceC1725);
                    } catch (Throwable th) {
                        interfaceC17252 = interfaceC1725;
                        th = th;
                        throw th;
                    }
                } catch (Throwable th2) {
                    th = th2;
                }
            }
        } catch (Throwable th3) {
            if (interfaceC17252 != null) {
                this.f9238.getClass();
                C3652.m8241(interfaceC17252);
            }
            throw th3;
        }
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final void m6115(GlideException glideException, int i) {
        boolean zM8807;
        this.f9240.m10131();
        synchronized (this.f9246) {
            try {
                glideException.getClass();
                int i2 = this.f9251.f2695;
                if (i2 <= i) {
                    Objects.toString(this.f9229);
                    if (i2 <= 4) {
                        ArrayList arrayList = new ArrayList();
                        GlideException.m797(glideException, arrayList);
                        int size = arrayList.size();
                        int i3 = 0;
                        while (i3 < size) {
                            int i4 = i3 + 1;
                            i3 = i4;
                        }
                    }
                }
                Drawable drawableM6123 = null;
                this.f9230 = null;
                this.f9252 = 5;
                InterfaceC5190 interfaceC5190 = this.f9234;
                if (interfaceC5190 != null) {
                    interfaceC5190.mo9004(this);
                }
                boolean z = true;
                this.f9239 = true;
                try {
                    List<InterfaceC3979> list = this.f9231;
                    if (list != null) {
                        zM8807 = false;
                        for (InterfaceC3979 interfaceC3979 : list) {
                            InterfaceC5190 interfaceC51902 = this.f9234;
                            if (interfaceC51902 != null) {
                                interfaceC51902.getRoot().mo6118();
                            }
                            zM8807 |= interfaceC3979.m8807();
                        }
                    } else {
                        zM8807 = false;
                    }
                    if (!zM8807) {
                        InterfaceC5190 interfaceC51903 = this.f9234;
                        if (interfaceC51903 != null && !interfaceC51903.mo9002(this)) {
                            z = false;
                        }
                        if (z) {
                            if (this.f9229 == null) {
                                if (this.f9242 == null) {
                                    this.f9232.getClass();
                                    this.f9242 = null;
                                }
                                drawableM6123 = this.f9242;
                            }
                            if (drawableM6123 == null) {
                                if (this.f9248 == null) {
                                    this.f9248 = this.f9232.f3471;
                                }
                                drawableM6123 = this.f9248;
                            }
                            if (drawableM6123 == null) {
                                drawableM6123 = m6123();
                            }
                            this.f9249.mo3533(drawableM6123);
                        }
                    }
                } finally {
                    this.f9239 = false;
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final void m6116() {
        if (this.f9239) {
            ᵹˉᵞ.ᵳٴᵶ("You can't start or clear loads in RequestListener or Target callbacks. If you're trying to start a fallback request when a load fails, use RequestBuilder#error(RequestBuilder). Otherwise consider posting your into() or clear() calls to the main thread using a Handler instead.");
            return;
        }
        this.f9240.m10131();
        this.f9249.mo3536(this);
        ᵧˉʙ r0 = this.f9230;
        if (r0 != null) {
            synchronized (((C3652) r0.ᵾᵬ)) {
                ((C4732) r0.ᵢˇᵭ).m9990((C2359) r0.ᵿʗᵝʽ);
            }
            this.f9230 = null;
        }
    }

    @Override // defpackage.InterfaceC3230
    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final boolean mo6117() {
        boolean z;
        synchronized (this.f9246) {
            z = this.f9252 == 6;
        }
        return z;
    }

    @Override // defpackage.InterfaceC3230
    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final boolean mo6118() {
        boolean z;
        synchronized (this.f9246) {
            z = this.f9252 == 4;
        }
        return z;
    }

    @Override // defpackage.InterfaceC3230
    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final boolean mo6119(InterfaceC3230 interfaceC3230) {
        int i;
        int i2;
        Object obj;
        Class cls;
        AbstractC0720 abstractC0720;
        EnumC5505 enumC5505;
        int size;
        int i3;
        int i4;
        Object obj2;
        Class cls2;
        AbstractC0720 abstractC07202;
        EnumC5505 enumC55052;
        int size2;
        if (!(interfaceC3230 instanceof C2359)) {
            return false;
        }
        synchronized (this.f9246) {
            try {
                i = this.f9250;
                i2 = this.f9236;
                obj = this.f9229;
                cls = this.f9233;
                abstractC0720 = this.f9232;
                enumC5505 = this.f9247;
                List list = this.f9231;
                size = list != null ? list.size() : 0;
            } finally {
            }
        }
        C2359 c2359 = (C2359) interfaceC3230;
        synchronized (c2359.f9246) {
            try {
                i3 = c2359.f9250;
                i4 = c2359.f9236;
                obj2 = c2359.f9229;
                cls2 = c2359.f9233;
                abstractC07202 = c2359.f9232;
                enumC55052 = c2359.f9247;
                List list2 = c2359.f9231;
                size2 = list2 != null ? list2.size() : 0;
            } finally {
            }
        }
        if (i == i3 && i2 == i4) {
            if ((obj == null ? obj2 == null : obj.equals(obj2)) && cls.equals(cls2)) {
                if ((abstractC0720 == null ? abstractC07202 == null : abstractC0720.m2738(abstractC07202)) && enumC5505 == enumC55052 && size == size2) {
                    return true;
                }
            }
        }
        return false;
    }

    @Override // defpackage.InterfaceC3230
    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final void mo6120() {
        synchronized (this.f9246) {
            try {
                if (this.f9239) {
                    throw new IllegalStateException("You can't start or clear loads in RequestListener or Target callbacks. If you're trying to start a fallback request when a load fails, use RequestBuilder#error(RequestBuilder). Otherwise consider posting your into() or clear() calls to the main thread using a Handler instead.");
                }
                this.f9240.m10131();
                int i = AbstractC4846.f17991;
                SystemClock.elapsedRealtimeNanos();
                if (this.f9229 == null) {
                    if (ˊˉʤﹳ.ᵶʔᵢˊ(this.f9250, this.f9236)) {
                        this.f9235 = this.f9250;
                        this.f9241 = this.f9236;
                    }
                    if (this.f9242 == null) {
                        this.f9232.getClass();
                        this.f9242 = null;
                    }
                    m6115(new GlideException("Received null model"), this.f9242 == null ? 5 : 3);
                    return;
                }
                int i2 = this.f9252;
                if (i2 == 2) {
                    throw new IllegalArgumentException("Cannot restart a running request");
                }
                if (i2 == 4) {
                    m6114(this.f9245, 5);
                    return;
                }
                List<InterfaceC3979> list = this.f9231;
                if (list != null) {
                    for (InterfaceC3979 interfaceC3979 : list) {
                    }
                }
                this.f9252 = 3;
                if (ˊˉʤﹳ.ᵶʔᵢˊ(this.f9250, this.f9236)) {
                    m6113(this.f9250, this.f9236);
                } else {
                    this.f9249.mo3534(this);
                }
                int i3 = this.f9252;
                if (i3 == 2 || i3 == 3) {
                    InterfaceC5190 interfaceC5190 = this.f9234;
                    if (interfaceC5190 == null || interfaceC5190.mo9002(this)) {
                        this.f9249.mo3540(m6123());
                    }
                }
                if (f9228) {
                    SystemClock.elapsedRealtimeNanos();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // defpackage.InterfaceC3230
    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public final boolean mo6121() {
        boolean z;
        synchronized (this.f9246) {
            z = this.f9252 == 4;
        }
        return z;
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final void m6122(InterfaceC1725 interfaceC1725, Object obj, int i) {
        InterfaceC5190 interfaceC5190 = this.f9234;
        boolean z = interfaceC5190 == null || !interfaceC5190.getRoot().mo6118();
        this.f9252 = 4;
        this.f9245 = interfaceC1725;
        if (this.f9251.f2695 <= 3) {
            Objects.toString(this.f9229);
            int i2 = AbstractC4846.f17991;
            SystemClock.elapsedRealtimeNanos();
        }
        if (interfaceC5190 != null) {
            interfaceC5190.mo9006(this);
        }
        this.f9239 = true;
        try {
            List list = this.f9231;
            if (list != null) {
                Iterator it = list.iterator();
                while (it.hasNext()) {
                    ((InterfaceC3979) it.next()).m8806(obj);
                }
            }
            this.f9249.mo3537(obj, this.f9244.mo7143(i, z));
            this.f9239 = false;
        } catch (Throwable th) {
            this.f9239 = false;
            throw th;
        }
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final Drawable m6123() {
        if (this.f9237 == null) {
            this.f9232.getClass();
            this.f9237 = null;
        }
        return this.f9237;
    }
}
