package androidx.fragment.app;

import android.util.Log;
import java.io.PrintWriter;
import java.lang.reflect.Modifier;
import java.util.ArrayList;

/* JADX INFO: renamed from: androidx.fragment.app.a, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1037a extends r0 implements InterfaceC1046e0 {

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

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public boolean f11556q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public int f11557r;

    public C1037a(AbstractC1050g0 abstractC1050g0) {
        abstractC1050g0.E();
        S s6 = abstractC1050g0.f11623u;
        if (s6 != null) {
            s6.f11540b.getClassLoader();
        }
        this.f11704a = new ArrayList();
        this.f11717o = false;
        this.f11557r = -1;
        this.f11555p = abstractC1050g0;
    }

    @Override // androidx.fragment.app.InterfaceC1046e0
    public final boolean a(ArrayList arrayList, ArrayList arrayList2) {
        if (AbstractC1050g0.H(2)) {
            Log.v("FragmentManager", "Run: " + this);
        }
        arrayList.add(this);
        arrayList2.add(Boolean.FALSE);
        if (!this.f11710g) {
            return true;
        }
        AbstractC1050g0 abstractC1050g0 = this.f11555p;
        if (abstractC1050g0.f11607d == null) {
            abstractC1050g0.f11607d = new ArrayList();
        }
        abstractC1050g0.f11607d.add(this);
        return true;
    }

    @Override // androidx.fragment.app.r0
    public final void c(int i6, G g6, String str) {
        String str2 = g6.mPreviousWho;
        if (str2 != null) {
            X1.d.c(g6, str2);
        }
        Class<?> cls = g6.getClass();
        int modifiers = cls.getModifiers();
        if (cls.isAnonymousClass() || !Modifier.isPublic(modifiers) || (cls.isMemberClass() && !Modifier.isStatic(modifiers))) {
            throw new IllegalStateException("Fragment " + cls.getCanonicalName() + " must be a public static class to be  properly recreated from instance state.");
        }
        if (str != null) {
            String str3 = g6.mTag;
            if (str3 != null && !str.equals(str3)) {
                throw new IllegalStateException("Can't change tag of fragment " + g6 + ": was " + g6.mTag + " now " + str);
            }
            g6.mTag = str;
        }
        if (i6 != 0) {
            if (i6 == -1) {
                throw new IllegalArgumentException("Can't add fragment " + g6 + " with tag " + str + " to container view with no id");
            }
            int i7 = g6.mFragmentId;
            if (i7 != 0 && i7 != i6) {
                throw new IllegalStateException("Can't change container ID of fragment " + g6 + ": was " + g6.mFragmentId + " now " + i6);
            }
            g6.mFragmentId = i6;
            g6.mContainerId = i6;
        }
        b(new q0(g6, 1));
        g6.mFragmentManager = this.f11555p;
    }

    public final void d(int i6) {
        if (this.f11710g) {
            if (AbstractC1050g0.H(2)) {
                Log.v("FragmentManager", "Bump nesting in " + this + " by " + i6);
            }
            ArrayList arrayList = this.f11704a;
            int size = arrayList.size();
            for (int i7 = 0; i7 < size; i7++) {
                q0 q0Var = (q0) arrayList.get(i7);
                G g6 = q0Var.f11695b;
                if (g6 != null) {
                    g6.mBackStackNesting += i6;
                    if (AbstractC1050g0.H(2)) {
                        Log.v("FragmentManager", "Bump nesting of " + q0Var.f11695b + " to " + q0Var.f11695b.mBackStackNesting);
                    }
                }
            }
        }
    }

    public final int e(boolean z6) {
        if (this.f11556q) {
            throw new IllegalStateException("commit already called");
        }
        if (AbstractC1050g0.H(2)) {
            Log.v("FragmentManager", "Commit: " + this);
            PrintWriter printWriter = new PrintWriter(new B0());
            f("  ", printWriter, true);
            printWriter.close();
        }
        this.f11556q = true;
        boolean z7 = this.f11710g;
        AbstractC1050g0 abstractC1050g0 = this.f11555p;
        if (z7) {
            this.f11557r = abstractC1050g0.f11612i.getAndIncrement();
        } else {
            this.f11557r = -1;
        }
        abstractC1050g0.v(this, z6);
        return this.f11557r;
    }

    public final void f(String str, PrintWriter printWriter, boolean z6) {
        String str2;
        if (z6) {
            printWriter.print(str);
            printWriter.print("mName=");
            printWriter.print(this.f11711h);
            printWriter.print(" mIndex=");
            printWriter.print(this.f11557r);
            printWriter.print(" mCommitted=");
            printWriter.println(this.f11556q);
            if (this.f11709f != 0) {
                printWriter.print(str);
                printWriter.print("mTransition=#");
                printWriter.print(Integer.toHexString(this.f11709f));
            }
            if (this.f11705b != 0 || this.f11706c != 0) {
                printWriter.print(str);
                printWriter.print("mEnterAnim=#");
                printWriter.print(Integer.toHexString(this.f11705b));
                printWriter.print(" mExitAnim=#");
                printWriter.println(Integer.toHexString(this.f11706c));
            }
            if (this.f11707d != 0 || this.f11708e != 0) {
                printWriter.print(str);
                printWriter.print("mPopEnterAnim=#");
                printWriter.print(Integer.toHexString(this.f11707d));
                printWriter.print(" mPopExitAnim=#");
                printWriter.println(Integer.toHexString(this.f11708e));
            }
            if (this.f11712i != 0 || this.f11713j != null) {
                printWriter.print(str);
                printWriter.print("mBreadCrumbTitleRes=#");
                printWriter.print(Integer.toHexString(this.f11712i));
                printWriter.print(" mBreadCrumbTitleText=");
                printWriter.println(this.f11713j);
            }
            if (this.f11714k != 0 || this.l != null) {
                printWriter.print(str);
                printWriter.print("mBreadCrumbShortTitleRes=#");
                printWriter.print(Integer.toHexString(this.f11714k));
                printWriter.print(" mBreadCrumbShortTitleText=");
                printWriter.println(this.l);
            }
        }
        ArrayList arrayList = this.f11704a;
        if (arrayList.isEmpty()) {
            return;
        }
        printWriter.print(str);
        printWriter.println("Operations:");
        int size = arrayList.size();
        for (int i6 = 0; i6 < size; i6++) {
            q0 q0Var = (q0) arrayList.get(i6);
            switch (q0Var.f11694a) {
                case 0:
                    str2 = "NULL";
                    break;
                case 1:
                    str2 = "ADD";
                    break;
                case 2:
                    str2 = "REPLACE";
                    break;
                case 3:
                    str2 = "REMOVE";
                    break;
                case 4:
                    str2 = "HIDE";
                    break;
                case 5:
                    str2 = "SHOW";
                    break;
                case 6:
                    str2 = "DETACH";
                    break;
                case 7:
                    str2 = "ATTACH";
                    break;
                case 8:
                    str2 = "SET_PRIMARY_NAV";
                    break;
                case 9:
                    str2 = "UNSET_PRIMARY_NAV";
                    break;
                case 10:
                    str2 = "OP_SET_MAX_LIFECYCLE";
                    break;
                default:
                    str2 = "cmd=" + q0Var.f11694a;
                    break;
            }
            printWriter.print(str);
            printWriter.print("  Op #");
            printWriter.print(i6);
            printWriter.print(": ");
            printWriter.print(str2);
            printWriter.print(" ");
            printWriter.println(q0Var.f11695b);
            if (z6) {
                if (q0Var.f11697d != 0 || q0Var.f11698e != 0) {
                    printWriter.print(str);
                    printWriter.print("enterAnim=#");
                    printWriter.print(Integer.toHexString(q0Var.f11697d));
                    printWriter.print(" exitAnim=#");
                    printWriter.println(Integer.toHexString(q0Var.f11698e));
                }
                if (q0Var.f11699f != 0 || q0Var.f11700g != 0) {
                    printWriter.print(str);
                    printWriter.print("popEnterAnim=#");
                    printWriter.print(Integer.toHexString(q0Var.f11699f));
                    printWriter.print(" popExitAnim=#");
                    printWriter.println(Integer.toHexString(q0Var.f11700g));
                }
            }
        }
    }

    public final String toString() {
        StringBuilder sb = new StringBuilder(128);
        sb.append("BackStackEntry{");
        sb.append(Integer.toHexString(System.identityHashCode(this)));
        if (this.f11557r >= 0) {
            sb.append(" #");
            sb.append(this.f11557r);
        }
        if (this.f11711h != null) {
            sb.append(" ");
            sb.append(this.f11711h);
        }
        sb.append("}");
        return sb.toString();
    }
}
