package androidx.loader.app;

import android.os.Bundle;
import android.os.Looper;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.p;
import androidx.lifecycle.y0;
import java.io.FileDescriptor;
import java.io.PrintWriter;

/* JADX INFO: loaded from: classes.dex */
public final class f extends b {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final p f2728a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final LoaderManagerImpl$LoaderViewModel f2729b;

    public f(p pVar, y0 y0Var) {
        this.f2728a = pVar;
        this.f2729b = LoaderManagerImpl$LoaderViewModel.getInstance(y0Var);
    }

    @NonNull
    @MainThread
    private <D> p1.b createAndInstallLoader(int i10, @Nullable Bundle bundle, @NonNull a aVar, @Nullable p1.b bVar) {
        LoaderManagerImpl$LoaderViewModel loaderManagerImpl$LoaderViewModel = this.f2729b;
        try {
            loaderManagerImpl$LoaderViewModel.startCreatingLoader();
            aVar.a();
            throw new IllegalArgumentException("Object returned from onCreateLoader must not be null");
        } catch (Throwable th) {
            loaderManagerImpl$LoaderViewModel.finishCreatingLoader();
            throw th;
        }
    }

    public final void b(String str, FileDescriptor fileDescriptor, PrintWriter printWriter, String[] strArr) {
        this.f2729b.dump(str, fileDescriptor, printWriter, strArr);
    }

    public final void c() {
        this.f2729b.markForRedelivery();
    }

    @Override // androidx.loader.app.b
    @Nullable
    public <D> p1.b getLoader(int i10) {
        LoaderManagerImpl$LoaderViewModel loaderManagerImpl$LoaderViewModel = this.f2729b;
        if (loaderManagerImpl$LoaderViewModel.isCreatingLoader()) {
            throw new IllegalStateException("Called while creating a loader");
        }
        loaderManagerImpl$LoaderViewModel.getLoader(i10);
        return null;
    }

    @Override // androidx.loader.app.b
    @NonNull
    @MainThread
    public <D> p1.b initLoader(int i10, @Nullable Bundle bundle, @NonNull a aVar) {
        LoaderManagerImpl$LoaderViewModel loaderManagerImpl$LoaderViewModel = this.f2729b;
        if (loaderManagerImpl$LoaderViewModel.isCreatingLoader()) {
            throw new IllegalStateException("Called while creating a loader");
        }
        if (Looper.getMainLooper() != Looper.myLooper()) {
            throw new IllegalStateException("initLoader must be called on the main thread");
        }
        c loader = loaderManagerImpl$LoaderViewModel.getLoader(i10);
        if (loader == null) {
            createAndInstallLoader(i10, bundle, aVar, null);
            return null;
        }
        d dVar = new d();
        p pVar = this.f2728a;
        loader.c(pVar, dVar);
        d dVar2 = loader.f2727n;
        if (dVar2 != null) {
            loader.g(dVar2);
        }
        loader.f2726m = pVar;
        loader.f2727n = dVar;
        return null;
    }

    @Override // androidx.loader.app.b
    @NonNull
    @MainThread
    public <D> p1.b restartLoader(int i10, @Nullable Bundle bundle, @NonNull a aVar) {
        LoaderManagerImpl$LoaderViewModel loaderManagerImpl$LoaderViewModel = this.f2729b;
        if (loaderManagerImpl$LoaderViewModel.isCreatingLoader()) {
            throw new IllegalStateException("Called while creating a loader");
        }
        if (Looper.getMainLooper() != Looper.myLooper()) {
            throw new IllegalStateException("restartLoader must be called on the main thread");
        }
        if (loaderManagerImpl$LoaderViewModel.getLoader(i10) != null) {
            throw null;
        }
        createAndInstallLoader(i10, bundle, aVar, null);
        return null;
    }

    public final String toString() {
        StringBuilder sb = new StringBuilder(128);
        sb.append("LoaderManager{");
        sb.append(Integer.toHexString(System.identityHashCode(this)));
        sb.append(" in ");
        p0.b.a(sb, this.f2728a);
        sb.append("}}");
        return sb.toString();
    }
}
