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;

/* JADX INFO: renamed from: ˆᵠᵗᵣ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C0870 {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final Handler f3848;

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public C1294 f3849;

    /* JADX INFO: renamed from: ˋˈ, reason: contains not printable characters */
    public int f3850;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final ArrayList f3851;

    /* JADX INFO: renamed from: ᵝᵶ, reason: contains not printable characters */
    public C1101 f3852;

    /* JADX INFO: renamed from: ᵟᵹᵙ, reason: contains not printable characters */
    public int f3853;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final InterfaceC5397 f3854;

    /* JADX INFO: renamed from: ᵪᵹᵥᵻ, reason: contains not printable characters */
    public int f3855;

    /* JADX INFO: renamed from: ᵮᵣᵗˈ, reason: contains not printable characters */
    public Bitmap f3856;

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public boolean f3857;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final C1911 f3858;

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public boolean f3859;

    /* JADX INFO: renamed from: ᵶᵥᵝ, reason: contains not printable characters */
    public C1101 f3860;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final ComponentCallbacks2C2427 f3861;

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public C1101 f3862;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public boolean f3863;

    public C0870(ComponentCallbacks2C0017 componentCallbacks2C0017, C1911 c1911, int i, int i2, Bitmap bitmap) {
        InterfaceC5397 interfaceC5397 = componentCallbacks2C0017.f999;
        C1883 c1883 = componentCallbacks2C0017.f1000;
        Context baseContext = c1883.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).");
        ComponentCallbacks2C2427 componentCallbacks2C2427M2578 = ComponentCallbacks2C0017.m801(baseContext).f1002.m2578(baseContext);
        Context baseContext2 = c1883.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).");
        ComponentCallbacks2C2427 componentCallbacks2C2427M25782 = ComponentCallbacks2C0017.m801(baseContext2).f1002.m2578(baseContext2);
        componentCallbacks2C2427M25782.getClass();
        C1294 c1294M3808 = new C1294(componentCallbacks2C2427M25782.f9457, componentCallbacks2C2427M25782, Bitmap.class, componentCallbacks2C2427M25782.f9461).mo3802(ComponentCallbacks2C2427.f9455).mo3802(((C0371) ((C0371) ((C0371) new C0371().m5571(C2999.f11543)).m5560()).m5559()).m5570(i, i2));
        this.f3851 = new ArrayList();
        this.f3861 = componentCallbacks2C2427M2578;
        Handler handler = new Handler(Looper.getMainLooper(), new C4156(1, this));
        this.f3854 = interfaceC5397;
        this.f3848 = handler;
        this.f3849 = c1294M3808;
        this.f3858 = c1911;
        m3059(C1648.f6555, bitmap);
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final void m3058(C1101 c1101) {
        this.f3859 = false;
        boolean z = this.f3857;
        Handler handler = this.f3848;
        if (z) {
            handler.obtainMessage(2, c1101).sendToTarget();
            return;
        }
        if (!this.f3863) {
            this.f3852 = c1101;
            return;
        }
        if (c1101.f4686 != null) {
            Bitmap bitmap = this.f3856;
            if (bitmap != null) {
                this.f3854.mo7363(bitmap);
                this.f3856 = null;
            }
            C1101 c11012 = this.f3862;
            this.f3862 = c1101;
            ArrayList arrayList = this.f3851;
            for (int size = arrayList.size() - 1; size >= 0; size--) {
                C1087 c1087 = (C1087) arrayList.get(size);
                Object callback = c1087.getCallback();
                while (callback instanceof Drawable) {
                    callback = ((Drawable) callback).getCallback();
                }
                if (callback == null) {
                    c1087.stop();
                    c1087.invalidateSelf();
                } else {
                    c1087.invalidateSelf();
                    C1101 c11013 = ((C0870) c1087.f4626.f1275).f3862;
                    if ((c11013 != null ? c11013.f4691 : -1) == r5.f3858.f7589.f2200 - 1) {
                        c1087.f4633++;
                    }
                    int i = c1087.f4625;
                    if (i != -1 && c1087.f4633 >= i) {
                        c1087.stop();
                    }
                }
            }
            if (c11012 != null) {
                handler.obtainMessage(2, c11012).sendToTarget();
            }
        }
        m3060();
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final void m3059(InterfaceC0214 interfaceC0214, Bitmap bitmap) {
        ᵿᵽᵤ.ːˏᵟᵯ(interfaceC0214, "Argument must not be null");
        ᵿᵽᵤ.ːˏᵟᵯ(bitmap, "Argument must not be null");
        this.f3856 = bitmap;
        this.f3849 = this.f3849.mo3802(new C0371().m5558(interfaceC0214, true));
        this.f3850 = ᵱˉˈ.ˊᵨᵧ(bitmap);
        this.f3855 = bitmap.getWidth();
        this.f3853 = bitmap.getHeight();
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final void m3060() {
        int i;
        if (!this.f3863 || this.f3859) {
            return;
        }
        C1101 c1101 = this.f3852;
        if (c1101 != null) {
            this.f3852 = null;
            m3058(c1101);
            return;
        }
        this.f3859 = true;
        C1911 c1911 = this.f3858;
        C0379 c0379 = c1911.f7589;
        int i2 = c0379.f2200;
        long jUptimeMillis = SystemClock.uptimeMillis() + ((long) ((i2 <= 0 || (i = c1911.f7594) < 0) ? 0 : (i < 0 || i >= i2) ? -1 : ((C1585) c0379.f2201.get(i)).f6371));
        int i3 = (c1911.f7594 + 1) % c1911.f7589.f2200;
        c1911.f7594 = i3;
        this.f3860 = new C1101(this.f3848, i3, jUptimeMillis);
        C1294 c1294M3813 = this.f3849.mo3802((C0371) new C0371().m5566(new C0681(Double.valueOf(Math.random())))).m3813(c1911);
        c1294M3813.m3811(this.f3860, c1294M3813);
    }
}
