package p138.p145.p146.p170;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.util.Log;
import com.bumptech.glide.load.engine.GlideException;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Executor;
import p138.p139.p143.p144.C2803;
import p138.p145.p146.C2810;
import p138.p145.p146.EnumC2812;
import p138.p145.p146.p151.EnumC2840;
import p138.p145.p146.p151.p154.C2909;
import p138.p145.p146.p151.p154.InterfaceC2932;
import p138.p145.p146.p151.p160.p163.C3131;
import p138.p145.p146.p170.p171.InterfaceC3216;
import p138.p145.p146.p170.p171.InterfaceC3217;
import p138.p145.p146.p170.p172.C3221;
import p138.p145.p146.p170.p172.InterfaceC3224;
import p138.p145.p146.p174.C3236;
import p138.p145.p146.p174.C3240;
import p138.p145.p146.p174.p175.AbstractC3250;

/* JADX INFO: renamed from: ދ.ؠ.֏.ސ.ބ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C3205<R> implements InterfaceC3200, InterfaceC3216, InterfaceC3204 {

    /* JADX INFO: renamed from: ޛ, reason: contains not printable characters */
    public static final boolean f9505 = Log.isLoggable("Request", 2);

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

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

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final Object f9508;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final InterfaceC3202<R> f9509;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final InterfaceC3201 f9510;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final Context f9511;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final C2810 f9512;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final Object f9513;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public final Class<R> f9514;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public final AbstractC3199<?> f9515;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public final int f9516;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public final int f9517;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public final EnumC2812 f9518;

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public final InterfaceC3217<R> f9519;

    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    public final List<InterfaceC3202<R>> f9520;

    /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
    public final InterfaceC3224<? super R> f9521;

    /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
    public final Executor f9522;

    /* JADX INFO: renamed from: ޏ, reason: contains not printable characters */
    public InterfaceC2932<R> f9523;

    /* JADX INFO: renamed from: ސ, reason: contains not printable characters */
    public C2909.C2915 f9524;

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

    /* JADX INFO: renamed from: ޒ, reason: contains not printable characters */
    public volatile C2909 f9526;

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

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

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

    /* JADX INFO: renamed from: ޖ, reason: contains not printable characters */
    public Drawable f9530;

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

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

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

    /* JADX INFO: renamed from: ޚ, reason: contains not printable characters */
    public RuntimeException f9534;

    /* JADX INFO: renamed from: ދ.ؠ.֏.ސ.ބ$֏, reason: contains not printable characters */
    public enum EnumC3206 {
        PENDING,
        RUNNING,
        WAITING_FOR_SIZE,
        COMPLETE,
        FAILED,
        CLEARED
    }

    public C3205(Context context, C2810 c2810, Object obj, Object obj2, Class<R> cls, AbstractC3199<?> abstractC3199, int i, int i2, EnumC2812 enumC2812, InterfaceC3217<R> interfaceC3217, InterfaceC3202<R> interfaceC3202, List<InterfaceC3202<R>> list, InterfaceC3201 interfaceC3201, C2909 c2909, InterfaceC3224<? super R> interfaceC3224, Executor executor) {
        this.f9506 = f9505 ? String.valueOf(super.hashCode()) : null;
        this.f9507 = new AbstractC3250.C3252();
        this.f9508 = obj;
        this.f9511 = context;
        this.f9512 = c2810;
        this.f9513 = obj2;
        this.f9514 = cls;
        this.f9515 = abstractC3199;
        this.f9516 = i;
        this.f9517 = i2;
        this.f9518 = enumC2812;
        this.f9519 = interfaceC3217;
        this.f9509 = interfaceC3202;
        this.f9520 = list;
        this.f9510 = interfaceC3201;
        this.f9526 = c2909;
        this.f9521 = interfaceC3224;
        this.f9522 = executor;
        this.f9527 = EnumC3206.PENDING;
        if (this.f9534 == null && c2810.f8665) {
            this.f9534 = new RuntimeException("Glide request origin trace");
        }
    }

    @Override // p138.p145.p146.p170.InterfaceC3200
    public void clear() {
        synchronized (this.f9508) {
            m5289();
            this.f9507.mo5344();
            if (this.f9527 == EnumC3206.CLEARED) {
                return;
            }
            m5289();
            this.f9507.mo5344();
            this.f9519.mo5296((InterfaceC3216) this);
            C2909.C2915 c2915 = this.f9524;
            InterfaceC2932<R> interfaceC2932 = null;
            if (c2915 != null) {
                c2915.m5049();
                this.f9524 = null;
            }
            if (this.f9523 != null) {
                InterfaceC2932<R> interfaceC29322 = this.f9523;
                this.f9523 = null;
                interfaceC2932 = interfaceC29322;
            }
            InterfaceC3201 interfaceC3201 = this.f9510;
            if (interfaceC3201 == null || interfaceC3201.m5280(this)) {
                this.f9519.mo5221(m5291());
            }
            this.f9527 = EnumC3206.CLEARED;
            if (interfaceC2932 != null) {
                this.f9526.m5046(interfaceC2932);
            }
        }
    }

    @Override // p138.p145.p146.p170.InterfaceC3200
    public boolean isRunning() {
        boolean z;
        synchronized (this.f9508) {
            z = this.f9527 == EnumC3206.RUNNING || this.f9527 == EnumC3206.WAITING_FOR_SIZE;
        }
        return z;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Drawable m5283(int i) {
        Resources.Theme theme = this.f9515.f9499;
        if (theme == null) {
            theme = this.f9511.getTheme();
        }
        C2810 c2810 = this.f9512;
        return C3131.m5206(c2810, c2810, i, theme);
    }

    @Override // p138.p145.p146.p170.p171.InterfaceC3216
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void mo5284(int i, int i2) throws Throwable {
        Object obj;
        int iRound = i;
        this.f9507.mo5344();
        Object obj2 = this.f9508;
        synchronized (obj2) {
            try {
                if (f9505) {
                    m5286("Got onSizeReady in " + C3236.m5319(this.f9525));
                }
                if (this.f9527 == EnumC3206.WAITING_FOR_SIZE) {
                    this.f9527 = EnumC3206.RUNNING;
                    float f = this.f9515.f9480;
                    if (iRound != Integer.MIN_VALUE) {
                        iRound = Math.round(iRound * f);
                    }
                    this.f9531 = iRound;
                    this.f9532 = i2 == Integer.MIN_VALUE ? i2 : Math.round(f * i2);
                    if (f9505) {
                        m5286("finished setup for calling load in " + C3236.m5319(this.f9525));
                    }
                    obj = obj2;
                    try {
                        try {
                            this.f9524 = this.f9526.m5040(this.f9512, this.f9513, this.f9515.f9490, this.f9531, this.f9532, this.f9515.f9497, this.f9514, this.f9518, this.f9515.f9481, this.f9515.f9496, this.f9515.f9491, this.f9515.f9503, this.f9515.f9495, this.f9515.f9487, this.f9515.f9501, this.f9515.f9504, this.f9515.f9502, this, this.f9522);
                            if (this.f9527 != EnumC3206.RUNNING) {
                                this.f9524 = null;
                            }
                            if (f9505) {
                                m5286("finished onSizeReady in " + C3236.m5319(this.f9525));
                            }
                        } catch (Throwable th) {
                            th = th;
                            while (true) {
                                try {
                                    throw th;
                                } catch (Throwable th2) {
                                    th = th2;
                                }
                            }
                        }
                    } catch (Throwable th3) {
                        th = th3;
                    }
                }
            } catch (Throwable th4) {
                th = th4;
                obj = obj2;
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m5285(GlideException glideException, int i) {
        boolean zM5281;
        this.f9507.mo5344();
        synchronized (this.f9508) {
            if (glideException == null) {
                throw null;
            }
            int i2 = this.f9512.f8666;
            if (i2 <= i) {
                Log.w("Glide", "Load failed for " + this.f9513 + " with size [" + this.f9531 + "x" + this.f9532 + "]", glideException);
                if (i2 <= 4) {
                    glideException.m1042("Glide");
                }
            }
            this.f9524 = null;
            this.f9527 = EnumC3206.FAILED;
            boolean z = true;
            this.f9533 = true;
            try {
                if (this.f9520 != null) {
                    Iterator<InterfaceC3202<R>> it = this.f9520.iterator();
                    zM5281 = false;
                    while (it.hasNext()) {
                        zM5281 |= it.next().m5281(glideException, this.f9513, this.f9519, m5292());
                    }
                } else {
                    zM5281 = false;
                }
                if (this.f9509 == null || !this.f9509.m5281(glideException, this.f9513, this.f9519, m5292())) {
                    z = false;
                }
                if (!(zM5281 | z)) {
                    m5293();
                }
                this.f9533 = false;
                InterfaceC3201 interfaceC3201 = this.f9510;
                if (interfaceC3201 != null) {
                    interfaceC3201.m5274(this);
                }
            } catch (Throwable th) {
                this.f9533 = false;
                throw th;
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m5286(String str) {
        StringBuilder sbM4897 = C2803.m4897(str, " this: ");
        sbM4897.append(this.f9506);
        Log.v("Request", sbM4897.toString());
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m5287(InterfaceC2932<R> interfaceC2932, R r, EnumC2840 enumC2840) {
        boolean zM5282;
        boolean zM5292 = m5292();
        this.f9527 = EnumC3206.COMPLETE;
        this.f9523 = interfaceC2932;
        if (this.f9512.f8666 <= 3) {
            StringBuilder sbM4889 = C2803.m4889("Finished loading ");
            sbM4889.append(r.getClass().getSimpleName());
            sbM4889.append(" from ");
            sbM4889.append(enumC2840);
            sbM4889.append(" for ");
            sbM4889.append(this.f9513);
            sbM4889.append(" with size [");
            sbM4889.append(this.f9531);
            sbM4889.append("x");
            sbM4889.append(this.f9532);
            sbM4889.append("] in ");
            sbM4889.append(C3236.m5319(this.f9525));
            sbM4889.append(" ms");
            Log.d("Glide", sbM4889.toString());
        }
        boolean z = true;
        this.f9533 = true;
        try {
            if (this.f9520 != null) {
                Iterator<InterfaceC3202<R>> it = this.f9520.iterator();
                zM5282 = false;
                while (it.hasNext()) {
                    zM5282 |= it.next().m5282(r, this.f9513, this.f9519, enumC2840, zM5292);
                }
            } else {
                zM5282 = false;
            }
            if (this.f9509 == null || !this.f9509.m5282(r, this.f9513, this.f9519, enumC2840, zM5292)) {
                z = false;
            }
            if (!(z | zM5282)) {
                if (((C3221.C3222) this.f9521) == null) {
                    throw null;
                }
                this.f9519.mo4924(r, C3221.f9562);
            }
            this.f9533 = false;
            InterfaceC3201 interfaceC3201 = this.f9510;
            if (interfaceC3201 != null) {
                interfaceC3201.m5279(this);
            }
        } catch (Throwable th) {
            this.f9533 = false;
            throw th;
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void m5288(InterfaceC2932<?> interfaceC2932, EnumC2840 enumC2840) {
        this.f9507.mo5344();
        InterfaceC2932<?> interfaceC29322 = null;
        try {
            synchronized (this.f9508) {
                try {
                    this.f9524 = null;
                    if (interfaceC2932 == null) {
                        m5285(new GlideException("Expected to receive a Resource<R> with an object of " + this.f9514 + " inside, but instead got null."), 5);
                        return;
                    }
                    Object obj = interfaceC2932.get();
                    try {
                        if (obj != null && this.f9514.isAssignableFrom(obj.getClass())) {
                            InterfaceC3201 interfaceC3201 = this.f9510;
                            if (interfaceC3201 == null || interfaceC3201.m5278(this)) {
                                m5287(interfaceC2932, obj, enumC2840);
                                return;
                            }
                            this.f9523 = null;
                            this.f9527 = EnumC3206.COMPLETE;
                            this.f9526.m5046(interfaceC2932);
                            return;
                        }
                        this.f9523 = null;
                        StringBuilder sb = new StringBuilder();
                        sb.append("Expected to receive an object of ");
                        sb.append(this.f9514);
                        sb.append(" but instead got ");
                        sb.append(obj != null ? obj.getClass() : "");
                        sb.append("{");
                        sb.append(obj);
                        sb.append("} inside Resource{");
                        sb.append(interfaceC2932);
                        sb.append("}.");
                        sb.append(obj != null ? "" : " To indicate failure return a null Resource object, rather than a Resource object containing null data.");
                        m5285(new GlideException(sb.toString()), 5);
                        this.f9526.m5046(interfaceC2932);
                    } catch (Throwable th) {
                        interfaceC29322 = interfaceC2932;
                        th = th;
                        throw th;
                    }
                } catch (Throwable th2) {
                    th = th2;
                }
            }
        } catch (Throwable th3) {
            if (interfaceC29322 != null) {
                this.f9526.m5046(interfaceC29322);
            }
            throw th3;
        }
    }

    @Override // p138.p145.p146.p170.InterfaceC3200
    /* JADX INFO: renamed from: ֏ */
    public boolean mo5269() {
        boolean z;
        synchronized (this.f9508) {
            z = this.f9527 == EnumC3206.CLEARED;
        }
        return z;
    }

    @Override // p138.p145.p146.p170.InterfaceC3200
    /* JADX INFO: renamed from: ֏ */
    public boolean mo5270(InterfaceC3200 interfaceC3200) {
        int i;
        int i2;
        Object obj;
        Class<R> cls;
        AbstractC3199<?> abstractC3199;
        EnumC2812 enumC2812;
        int size;
        int i3;
        int i4;
        Object obj2;
        Class<R> cls2;
        AbstractC3199<?> abstractC31992;
        EnumC2812 enumC28122;
        int size2;
        if (!(interfaceC3200 instanceof C3205)) {
            return false;
        }
        synchronized (this.f9508) {
            i = this.f9516;
            i2 = this.f9517;
            obj = this.f9513;
            cls = this.f9514;
            abstractC3199 = this.f9515;
            enumC2812 = this.f9518;
            size = this.f9520 != null ? this.f9520.size() : 0;
        }
        C3205 c3205 = (C3205) interfaceC3200;
        synchronized (c3205.f9508) {
            i3 = c3205.f9516;
            i4 = c3205.f9517;
            obj2 = c3205.f9513;
            cls2 = c3205.f9514;
            abstractC31992 = c3205.f9515;
            enumC28122 = c3205.f9518;
            size2 = c3205.f9520 != null ? c3205.f9520.size() : 0;
        }
        return i == i3 && i2 == i4 && C3240.m5337(obj, obj2) && cls.equals(cls2) && abstractC3199.equals(abstractC31992) && enumC2812 == enumC28122 && size == size2;
    }

    @Override // p138.p145.p146.p170.InterfaceC3200
    /* JADX INFO: renamed from: ؠ */
    public void mo5271() {
        synchronized (this.f9508) {
            m5289();
            this.f9507.mo5344();
            this.f9525 = C3236.m5320();
            if (this.f9513 == null) {
                if (C3240.m5336(this.f9516, this.f9517)) {
                    this.f9531 = this.f9516;
                    this.f9532 = this.f9517;
                }
                m5285(new GlideException("Received null model"), m5290() == null ? 5 : 3);
                return;
            }
            if (this.f9527 == EnumC3206.RUNNING) {
                throw new IllegalArgumentException("Cannot restart a running request");
            }
            if (this.f9527 == EnumC3206.COMPLETE) {
                m5288((InterfaceC2932<?>) this.f9523, EnumC2840.MEMORY_CACHE);
                return;
            }
            this.f9527 = EnumC3206.WAITING_FOR_SIZE;
            if (C3240.m5336(this.f9516, this.f9517)) {
                mo5284(this.f9516, this.f9517);
            } else {
                this.f9519.mo5299(this);
            }
            if (this.f9527 == EnumC3206.RUNNING || this.f9527 == EnumC3206.WAITING_FOR_SIZE) {
                InterfaceC3201 interfaceC3201 = this.f9510;
                if (interfaceC3201 == null || interfaceC3201.m5277(this)) {
                    this.f9519.mo5298(m5291());
                }
            }
            if (f9505) {
                m5286("finished run method in " + C3236.m5319(this.f9525));
            }
        }
    }

    @Override // p138.p145.p146.p170.InterfaceC3200
    /* JADX INFO: renamed from: ހ */
    public boolean mo5272() {
        boolean z;
        synchronized (this.f9508) {
            z = this.f9527 == EnumC3206.COMPLETE;
        }
        return z;
    }

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final void m5289() {
        if (this.f9533) {
            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.");
        }
    }

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final Drawable m5290() {
        int i;
        if (this.f9530 == null) {
            AbstractC3199<?> abstractC3199 = this.f9515;
            Drawable drawable = abstractC3199.f9493;
            this.f9530 = drawable;
            if (drawable == null && (i = abstractC3199.f9494) > 0) {
                this.f9530 = m5283(i);
            }
        }
        return this.f9530;
    }

    @Override // p138.p145.p146.p170.InterfaceC3200
    /* JADX INFO: renamed from: ރ */
    public void mo5273() {
        synchronized (this.f9508) {
            if (isRunning()) {
                clear();
            }
        }
    }

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final Drawable m5291() {
        int i;
        if (this.f9529 == null) {
            AbstractC3199<?> abstractC3199 = this.f9515;
            Drawable drawable = abstractC3199.f9485;
            this.f9529 = drawable;
            if (drawable == null && (i = abstractC3199.f9486) > 0) {
                this.f9529 = m5283(i);
            }
        }
        return this.f9529;
    }

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final boolean m5292() {
        InterfaceC3201 interfaceC3201 = this.f9510;
        return interfaceC3201 == null || !interfaceC3201.m5276().m5275();
    }

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public final void m5293() {
        int i;
        InterfaceC3201 interfaceC3201 = this.f9510;
        if (interfaceC3201 == null || interfaceC3201.m5277(this)) {
            Drawable drawableM5290 = this.f9513 == null ? m5290() : null;
            if (drawableM5290 == null) {
                if (this.f9528 == null) {
                    AbstractC3199<?> abstractC3199 = this.f9515;
                    Drawable drawable = abstractC3199.f9483;
                    this.f9528 = drawable;
                    if (drawable == null && (i = abstractC3199.f9484) > 0) {
                        this.f9528 = m5283(i);
                    }
                }
                drawableM5290 = this.f9528;
            }
            if (drawableM5290 == null) {
                drawableM5290 = m5291();
            }
            this.f9519.mo4923(drawableM5290);
        }
    }
}
