package com.bumptech.glide.c.b;

import android.os.Handler.Callback;
import android.os.Message;
import com.bumptech.glide.f.f;
import com.tencent.matrix.trace.core.AppMethodBeat;

class k$b implements Callback {
    k$b() {
    }

    public final boolean handleMessage(Message message) {
        AppMethodBeat.i(91822);
        k kVar = (k) message.obj;
        IllegalStateException illegalStateException;
        switch (message.what) {
            case 1:
                kVar.aAq.oq();
                if (!kVar.isCancelled) {
                    if (!kVar.aBH.isEmpty()) {
                        if (!kVar.aBL) {
                            kVar.aBP = new o(kVar.azR, kVar.azQ, true);
                            kVar.aBL = true;
                            kVar.aBP.acquire();
                            kVar.aBz.a(kVar, kVar.azP, kVar.aBP);
                            int size = kVar.aBH.size();
                            for (int i = 0; i < size; i++) {
                                f fVar = (f) kVar.aBH.get(i);
                                if (!kVar.b(fVar)) {
                                    kVar.aBP.acquire();
                                    fVar.c(kVar.aBP, kVar.aAL);
                                }
                            }
                            kVar.aBP.release();
                            kVar.mI();
                            break;
                        }
                        illegalStateException = new IllegalStateException("Already have resource");
                        AppMethodBeat.o(91822);
                        throw illegalStateException;
                    }
                    illegalStateException = new IllegalStateException("Received a resource without any callbacks to notify");
                    AppMethodBeat.o(91822);
                    throw illegalStateException;
                }
                kVar.azR.recycle();
                kVar.mI();
                break;
            case 2:
                kVar.mJ();
                break;
            case 3:
                kVar.aAq.oq();
                if (kVar.isCancelled) {
                    kVar.aBz.a(kVar, kVar.azP);
                    kVar.mI();
                    break;
                }
                illegalStateException = new IllegalStateException("Not cancelled");
                AppMethodBeat.o(91822);
                throw illegalStateException;
            default:
                illegalStateException = new IllegalStateException("Unrecognized message: " + message.what);
                AppMethodBeat.o(91822);
                throw illegalStateException;
        }
        AppMethodBeat.o(91822);
        return true;
    }
}
