package defpackage;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import com.bumptech.glide.ComponentCallbacks2C0017;
import java.util.ArrayList;

/* renamed from: ˌˀˊ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C1578 {

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

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public int f6246;

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public Bitmap f6247;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public boolean f6248;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public boolean f6249;

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

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public C1116 f6251;

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

    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public int f6253;

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public C1116 f6254;

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

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

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public boolean f6257;

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public C1116 f6258;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public C1983 f6259;

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

    public C1578(ComponentCallbacks2C0017 componentCallbacks2C0017, C2693 c2693, int i, int i2, Bitmap bitmap) {
        InterfaceC2157 interfaceC2157 = componentCallbacks2C0017.f998;
        C0520 c0520 = componentCallbacks2C0017.f1001;
        Context baseContext = c0520.getBaseContext();
        ᵼᵙᵖᵱ.ˏˋٴ(baseContext, "You cannot start a load on a not yet attached View or a Fragment where getActivity() returns null (which usually occurs when getActivity() is called before the Fragment is attached or after the Fragment is destroyed).");
        ComponentCallbacks2C3445 componentCallbacks2C3445M2231 = ComponentCallbacks2C0017.m802(baseContext).f997.m2231(baseContext);
        Context baseContext2 = c0520.getBaseContext();
        ᵼᵙᵖᵱ.ˏˋٴ(baseContext2, "You cannot start a load on a not yet attached View or a Fragment where getActivity() returns null (which usually occurs when getActivity() is called before the Fragment is attached or after the Fragment is destroyed).");
        ComponentCallbacks2C3445 componentCallbacks2C3445M22312 = ComponentCallbacks2C0017.m802(baseContext2).f997.m2231(baseContext2);
        componentCallbacks2C3445M22312.getClass();
        C1983 c1983M5488 = new C1983(componentCallbacks2C3445M22312.f12895, componentCallbacks2C3445M22312, Bitmap.class, componentCallbacks2C3445M22312.f12893).mo2734(ComponentCallbacks2C3445.f12887).mo2734(((C1905) ((C1905) ((C1905) new C1905().m2727(C3318.f12408)).m2728()).m2729()).m2737(i, i2));
        this.f6250 = new ArrayList();
        this.f6260 = componentCallbacks2C3445M2231;
        Handler handler = new Handler(Looper.getMainLooper(), new C0824(1, this));
        this.f6245 = interfaceC2157;
        this.f6256 = handler;
        this.f6259 = c1983M5488;
        this.f6252 = c2693;
        m4553(C5123.f19085, bitmap);
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final void m4553(InterfaceC3731 interfaceC3731, Bitmap bitmap) {
        ᵼᵙᵖᵱ.ˏˋٴ(interfaceC3731, "Argument must not be null");
        ᵼᵙᵖᵱ.ˏˋٴ(bitmap, "Argument must not be null");
        this.f6247 = bitmap;
        this.f6259 = this.f6259.mo2734(new C1905().m2736(interfaceC3731, true));
        this.f6253 = ˊˉʤﹳ.ᵡʠ(bitmap);
        this.f6255 = bitmap.getWidth();
        this.f6246 = bitmap.getHeight();
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final void m4554() {
        int i;
        if (!this.f6249 || this.f6248) {
            return;
        }
        C1116 c1116 = this.f6254;
        if (c1116 != null) {
            this.f6254 = null;
            m4555(c1116);
            return;
        }
        this.f6248 = true;
        C2693 c2693 = this.f6252;
        int i2 = c2693.f10432.f4849;
        long jUptimeMillis = SystemClock.uptimeMillis() + ((i2 <= 0 || (i = c2693.f10447) < 0) ? 0 : (i < 0 || i >= i2) ? -1 : ((C5332) r2.f4846.get(i)).f19966);
        int i3 = (c2693.f10447 + 1) % c2693.f10432.f4849;
        c2693.f10447 = i3;
        this.f6258 = new C1116(this.f6256, i3, jUptimeMillis);
        C1983 c1983M5485 = this.f6259.mo2734((C1905) new C1905().m2733(new C4700(Double.valueOf(Math.random())))).m5485(c2693);
        c1983M5485.m5487(this.f6258, c1983M5485);
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final void m4555(C1116 c1116) {
        this.f6248 = false;
        boolean z = this.f6257;
        Handler handler = this.f6256;
        if (z) {
            handler.obtainMessage(2, c1116).sendToTarget();
            return;
        }
        if (!this.f6249) {
            this.f6254 = c1116;
            return;
        }
        if (c1116.f4825 != null) {
            Bitmap bitmap = this.f6247;
            if (bitmap != null) {
                this.f6245.mo5786(bitmap);
                this.f6247 = null;
            }
            C1116 c11162 = this.f6251;
            this.f6251 = c1116;
            ArrayList arrayList = this.f6250;
            for (int size = arrayList.size() - 1; size >= 0; size--) {
                C3667 c3667 = (C3667) arrayList.get(size);
                Object callback = c3667.getCallback();
                while (callback instanceof Drawable) {
                    callback = ((Drawable) callback).getCallback();
                }
                if (callback == null) {
                    c3667.stop();
                    c3667.invalidateSelf();
                } else {
                    c3667.invalidateSelf();
                    C1116 c11163 = ((C1578) c3667.f13667.f17459).f6251;
                    if ((c11163 != null ? c11163.f4828 : -1) == r5.f6252.f10432.f4849 - 1) {
                        c3667.f13664++;
                    }
                    int i = c3667.f13660;
                    if (i != -1 && c3667.f13664 >= i) {
                        c3667.stop();
                    }
                }
            }
            if (c11162 != null) {
                handler.obtainMessage(2, c11162).sendToTarget();
            }
        }
        m4554();
    }
}
