package androidx.fragment.app;

import android.app.SharedElementCallback;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.MenuItem;
import android.view.View;
import androidx.activity.ComponentActivity;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import o.AbstractC1075e80;
import o.AbstractC1282gM;
import o.C1089eL;
import o.C1272gC;
import o.CC;
import o.InterfaceC1416hm;
import o.InterfaceC1545j40;
import o.InterfaceC2203q1;
import o.KT;
import o.UK;
import o.VB;
import o.VK;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public class FragmentActivity extends ComponentActivity implements InterfaceC2203q1 {
    static final String LIFECYCLE_TAG = "android:support:lifecycle";
    boolean mCreated;
    boolean mResumed;
    final VB mFragments = new VB(new p(this));
    final C1089eL mFragmentLifecycleRegistry = new C1089eL(this);
    boolean mStopped = true;

    public FragmentActivity() {
        getSavedStateRegistry().c("android:support:lifecycle", new InterfaceC1545j40() { // from class: androidx.fragment.app.m
            @Override // o.InterfaceC1545j40
            public final Bundle a() {
                String str = FragmentActivity.LIFECYCLE_TAG;
                FragmentActivity fragmentActivity = this.a;
                fragmentActivity.markFragmentsCreated();
                fragmentActivity.mFragmentLifecycleRegistry.f(UK.ON_STOP);
                return new Bundle();
            }
        });
        final int i = 0;
        addOnConfigurationChangedListener(new InterfaceC1416hm(this) { // from class: androidx.fragment.app.n
            public final /* synthetic */ FragmentActivity b;

            {
                this.b = this;
            }

            @Override // o.InterfaceC1416hm
            public final void accept(Object obj) {
                switch (i) {
                    case 0:
                        this.b.mFragments.a();
                        break;
                    default:
                        this.b.mFragments.a();
                        break;
                }
            }
        });
        final int i2 = 1;
        addOnNewIntentListener(new InterfaceC1416hm(this) { // from class: androidx.fragment.app.n
            public final /* synthetic */ FragmentActivity b;

            {
                this.b = this;
            }

            @Override // o.InterfaceC1416hm
            public final void accept(Object obj) {
                switch (i2) {
                    case 0:
                        this.b.mFragments.a();
                        break;
                    default:
                        this.b.mFragments.a();
                        break;
                }
            }
        });
        addOnContextAvailableListener(new KT() { // from class: androidx.fragment.app.o
            @Override // o.KT
            public final void a(ComponentActivity componentActivity) {
                p pVar = this.a.mFragments.a;
                pVar.f394o.b(pVar, pVar, null);
            }
        });
    }

    public static boolean e(s sVar) {
        boolean zE = false;
        for (l lVar : sVar.c.f()) {
            if (lVar != null) {
                if (lVar.getHost() != null) {
                    zE |= e(lVar.getChildFragmentManager());
                }
                CC cc = lVar.mViewLifecycleOwner;
                VK vk = VK.n;
                VK vk2 = VK.f372o;
                if (cc != null) {
                    cc.b();
                    if (cc.n.d.a(vk2)) {
                        C1089eL c1089eL = lVar.mViewLifecycleOwner.n;
                        c1089eL.e("setCurrentState");
                        c1089eL.g(vk);
                        zE = true;
                    }
                }
                if (lVar.mLifecycleRegistry.d.a(vk2)) {
                    C1089eL c1089eL2 = lVar.mLifecycleRegistry;
                    c1089eL2.e("setCurrentState");
                    c1089eL2.g(vk);
                    zE = true;
                }
            }
        }
        return zE;
    }

    public final View dispatchFragmentsOnCreateView(View view, String str, Context context, AttributeSet attributeSet) {
        return this.mFragments.a.f394o.f.onCreateView(view, str, context, attributeSet);
    }

    @Override // android.app.Activity
    public void dump(String str, FileDescriptor fileDescriptor, PrintWriter printWriter, String[] strArr) {
        super.dump(str, fileDescriptor, printWriter, strArr);
        if (shouldDumpInternalState(strArr)) {
            printWriter.print(str);
            printWriter.print("Local FragmentActivity ");
            printWriter.print(Integer.toHexString(System.identityHashCode(this)));
            printWriter.println(" State:");
            String str2 = str + "  ";
            printWriter.print(str2);
            printWriter.print("mCreated=");
            printWriter.print(this.mCreated);
            printWriter.print(" mResumed=");
            printWriter.print(this.mResumed);
            printWriter.print(" mStopped=");
            printWriter.print(this.mStopped);
            if (getApplication() != null) {
                AbstractC1282gM.a(this).b(str2, printWriter);
            }
            this.mFragments.a.f394o.u(str, fileDescriptor, printWriter, strArr);
        }
    }

    public s getSupportFragmentManager() {
        return this.mFragments.a.f394o;
    }

    @Deprecated
    public AbstractC1282gM getSupportLoaderManager() {
        return AbstractC1282gM.a(this);
    }

    public void markFragmentsCreated() {
        while (e(getSupportFragmentManager())) {
        }
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void onActivityResult(int i, int i2, Intent intent) {
        this.mFragments.a();
        super.onActivityResult(i, i2, intent);
    }

    @Override // androidx.activity.ComponentActivity, androidx.core.app.ComponentActivity, android.app.Activity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.mFragmentLifecycleRegistry.f(UK.ON_CREATE);
        C1272gC c1272gC = this.mFragments.a.f394o;
        c1272gC.E = false;
        c1272gC.F = false;
        c1272gC.L.g = false;
        c1272gC.t(1);
    }

    @Override // android.app.Activity, android.view.LayoutInflater.Factory2
    public View onCreateView(View view, String str, Context context, AttributeSet attributeSet) {
        View viewDispatchFragmentsOnCreateView = dispatchFragmentsOnCreateView(view, str, context, attributeSet);
        return viewDispatchFragmentsOnCreateView == null ? super.onCreateView(view, str, context, attributeSet) : viewDispatchFragmentsOnCreateView;
    }

    @Override // android.app.Activity
    public void onDestroy() {
        super.onDestroy();
        this.mFragments.a.f394o.k();
        this.mFragmentLifecycleRegistry.f(UK.ON_DESTROY);
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity, android.view.Window.Callback
    public boolean onMenuItemSelected(int i, MenuItem menuItem) {
        if (super.onMenuItemSelected(i, menuItem)) {
            return true;
        }
        if (i == 6) {
            return this.mFragments.a.f394o.i(menuItem);
        }
        return false;
    }

    @Override // android.app.Activity
    public void onPause() {
        super.onPause();
        this.mResumed = false;
        this.mFragments.a.f394o.t(5);
        this.mFragmentLifecycleRegistry.f(UK.ON_PAUSE);
    }

    @Override // android.app.Activity
    public void onPostResume() {
        super.onPostResume();
        onResumeFragments();
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        this.mFragments.a();
        super.onRequestPermissionsResult(i, strArr, iArr);
    }

    @Override // android.app.Activity
    public void onResume() {
        this.mFragments.a();
        super.onResume();
        this.mResumed = true;
        this.mFragments.a.f394o.x(true);
    }

    public void onResumeFragments() {
        this.mFragmentLifecycleRegistry.f(UK.ON_RESUME);
        C1272gC c1272gC = this.mFragments.a.f394o;
        c1272gC.E = false;
        c1272gC.F = false;
        c1272gC.L.g = false;
        c1272gC.t(7);
    }

    @Override // android.app.Activity
    public void onStart() {
        this.mFragments.a();
        super.onStart();
        this.mStopped = false;
        if (!this.mCreated) {
            this.mCreated = true;
            C1272gC c1272gC = this.mFragments.a.f394o;
            c1272gC.E = false;
            c1272gC.F = false;
            c1272gC.L.g = false;
            c1272gC.t(4);
        }
        this.mFragments.a.f394o.x(true);
        this.mFragmentLifecycleRegistry.f(UK.ON_START);
        C1272gC c1272gC2 = this.mFragments.a.f394o;
        c1272gC2.E = false;
        c1272gC2.F = false;
        c1272gC2.L.g = false;
        c1272gC2.t(5);
    }

    @Override // android.app.Activity
    public void onStateNotSaved() {
        this.mFragments.a();
    }

    @Override // android.app.Activity
    public void onStop() {
        super.onStop();
        this.mStopped = true;
        markFragmentsCreated();
        C1272gC c1272gC = this.mFragments.a.f394o;
        c1272gC.F = true;
        c1272gC.L.g = true;
        c1272gC.t(4);
        this.mFragmentLifecycleRegistry.f(UK.ON_STOP);
    }

    public void setEnterSharedElementCallback(AbstractC1075e80 abstractC1075e80) {
        setEnterSharedElementCallback((SharedElementCallback) null);
    }

    public void setExitSharedElementCallback(AbstractC1075e80 abstractC1075e80) {
        setExitSharedElementCallback((SharedElementCallback) null);
    }

    public void startActivityFromFragment(l lVar, Intent intent, int i, Bundle bundle) {
        if (i == -1) {
            startActivityForResult(intent, -1, bundle);
        } else {
            lVar.startActivityForResult(intent, i, bundle);
        }
    }

    @Deprecated
    public void startIntentSenderFromFragment(l lVar, IntentSender intentSender, int i, Intent intent, int i2, int i3, int i4, Bundle bundle) {
        if (i == -1) {
            startIntentSenderForResult(intentSender, i, intent, i2, i3, i4, bundle);
        } else {
            lVar.startIntentSenderForResult(intentSender, i, intent, i2, i3, i4, bundle);
        }
    }

    public void supportFinishAfterTransition() {
        finishAfterTransition();
    }

    public void supportPostponeEnterTransition() {
        postponeEnterTransition();
    }

    public void supportStartPostponedEnterTransition() {
        startPostponedEnterTransition();
    }

    @Override // android.app.Activity, android.view.LayoutInflater.Factory
    public View onCreateView(String str, Context context, AttributeSet attributeSet) {
        View viewDispatchFragmentsOnCreateView = dispatchFragmentsOnCreateView(null, str, context, attributeSet);
        return viewDispatchFragmentsOnCreateView == null ? super.onCreateView(str, context, attributeSet) : viewDispatchFragmentsOnCreateView;
    }

    public void startActivityFromFragment(l lVar, Intent intent, int i) {
        startActivityFromFragment(lVar, intent, i, (Bundle) null);
    }

    @Deprecated
    public void onAttachFragment(l lVar) {
    }

    @Override // o.InterfaceC2203q1
    @Deprecated
    public final void validateRequestPermissionsRequestCode(int i) {
    }
}
