package androidx.fragment.app;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import androidx.activity.ComponentActivity;
import androidx.activity.OnBackPressedDispatcher;
import androidx.core.app.a;
import androidx.lifecycle.f;
import androidx.savedstate.SavedStateRegistry;
import java.io.FileDescriptor;
import java.io.PrintWriter;

/* JADX INFO: compiled from: FragmentActivity.java */
/* JADX INFO: loaded from: classes.dex */
public class d extends ComponentActivity implements a.b, a.d {
    boolean p;
    boolean q;
    final h n = h.b(new c());
    final androidx.lifecycle.m o = new androidx.lifecycle.m(this);
    boolean r = true;

    /* JADX INFO: compiled from: FragmentActivity.java */
    class a implements SavedStateRegistry.b {
        a() {
        }

        @Override // androidx.savedstate.SavedStateRegistry.b
        public Bundle a() {
            Bundle bundle = new Bundle();
            d.this.u();
            d.this.o.h(f.b.ON_STOP);
            Parcelable parcelableX = d.this.n.x();
            if (parcelableX != null) {
                bundle.putParcelable("android:support:fragments", parcelableX);
            }
            return bundle;
        }
    }

    /* JADX INFO: compiled from: FragmentActivity.java */
    class b implements androidx.activity.d.b {
        b() {
        }

        @Override // androidx.activity.d.b
        public void a(Context context) {
            d.this.n.a(null);
            Bundle bundleA = d.this.d().a("android:support:fragments");
            if (bundleA != null) {
                d.this.n.w(bundleA.getParcelable("android:support:fragments"));
            }
        }
    }

    /* JADX INFO: compiled from: FragmentActivity.java */
    class c extends j<d> implements androidx.lifecycle.z, androidx.activity.c, androidx.activity.result.e, q {
        public c() {
            super(d.this);
        }

        @Override // androidx.lifecycle.l
        public androidx.lifecycle.f a() {
            return d.this.o;
        }

        @Override // androidx.fragment.app.q
        public void b(m mVar, Fragment fragment) {
            d.this.w(fragment);
        }

        @Override // androidx.activity.c
        public OnBackPressedDispatcher c() {
            return d.this.c();
        }

        @Override // androidx.fragment.app.j, androidx.fragment.app.f
        public View f(int i2) {
            return d.this.findViewById(i2);
        }

        @Override // androidx.fragment.app.j, androidx.fragment.app.f
        public boolean g() {
            Window window = d.this.getWindow();
            return (window == null || window.peekDecorView() == null) ? false : true;
        }

        @Override // androidx.activity.result.e
        public androidx.activity.result.d h() {
            return d.this.h();
        }

        @Override // androidx.lifecycle.z
        public androidx.lifecycle.y j() {
            return d.this.j();
        }

        @Override // androidx.fragment.app.j
        public LayoutInflater n() {
            return d.this.getLayoutInflater().cloneInContext(d.this);
        }

        @Override // androidx.fragment.app.j
        public boolean o(Fragment fragment) {
            return !d.this.isFinishing();
        }

        @Override // androidx.fragment.app.j
        public void q() {
            d.this.z();
        }

        @Override // androidx.fragment.app.j
        /* JADX INFO: renamed from: r, reason: merged with bridge method [inline-methods] */
        public d m() {
            return d.this;
        }
    }

    public d() {
        t();
    }

    private void t() {
        d().d("android:support:fragments", new a());
        m(new b());
    }

    private static boolean v(m mVar, f.c cVar) {
        boolean zV = false;
        for (Fragment fragment : mVar.r0()) {
            if (fragment != null) {
                if (fragment.x() != null) {
                    zV |= v(fragment.p(), cVar);
                }
                z zVar = fragment.W;
                if (zVar != null && zVar.a().b().isAtLeast(f.c.STARTED)) {
                    fragment.W.i(cVar);
                    zV = true;
                }
                if (fragment.V.b().isAtLeast(f.c.STARTED)) {
                    fragment.V.o(cVar);
                    zV = true;
                }
            }
        }
        return zV;
    }

    @Override // androidx.core.app.a.d
    @Deprecated
    public final void b(int i2) {
    }

    @Override // android.app.Activity
    public void dump(String str, FileDescriptor fileDescriptor, PrintWriter printWriter, String[] strArr) {
        super.dump(str, fileDescriptor, printWriter, 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.p);
        printWriter.print(" mResumed=");
        printWriter.print(this.q);
        printWriter.print(" mStopped=");
        printWriter.print(this.r);
        if (getApplication() != null) {
            c.k.a.a.b(this).a(str2, fileDescriptor, printWriter, strArr);
        }
        this.n.t().W(str, fileDescriptor, printWriter, strArr);
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    protected void onActivityResult(int i2, int i3, Intent intent) {
        this.n.u();
        super.onActivityResult(i2, i3, intent);
    }

    @Override // android.app.Activity, android.content.ComponentCallbacks
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        this.n.u();
        this.n.d(configuration);
    }

    @Override // androidx.activity.ComponentActivity, androidx.core.app.d, android.app.Activity
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.o.h(f.b.ON_CREATE);
        this.n.f();
    }

    @Override // android.app.Activity, android.view.Window.Callback
    public boolean onCreatePanelMenu(int i2, Menu menu) {
        return i2 == 0 ? super.onCreatePanelMenu(i2, menu) | this.n.g(menu, getMenuInflater()) : super.onCreatePanelMenu(i2, menu);
    }

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

    @Override // android.app.Activity
    protected void onDestroy() {
        super.onDestroy();
        this.n.h();
        this.o.h(f.b.ON_DESTROY);
    }

    @Override // android.app.Activity, android.content.ComponentCallbacks
    public void onLowMemory() {
        super.onLowMemory();
        this.n.i();
    }

    @Override // android.app.Activity, android.view.Window.Callback
    public boolean onMenuItemSelected(int i2, MenuItem menuItem) {
        if (super.onMenuItemSelected(i2, menuItem)) {
            return true;
        }
        if (i2 == 0) {
            return this.n.k(menuItem);
        }
        if (i2 != 6) {
            return false;
        }
        return this.n.e(menuItem);
    }

    @Override // android.app.Activity
    public void onMultiWindowModeChanged(boolean z) {
        this.n.j(z);
    }

    @Override // android.app.Activity
    protected void onNewIntent(@SuppressLint({"UnknownNullness"}) Intent intent) {
        super.onNewIntent(intent);
        this.n.u();
    }

    @Override // android.app.Activity, android.view.Window.Callback
    public void onPanelClosed(int i2, Menu menu) {
        if (i2 == 0) {
            this.n.l(menu);
        }
        super.onPanelClosed(i2, menu);
    }

    @Override // android.app.Activity
    protected void onPause() {
        super.onPause();
        this.q = false;
        this.n.m();
        this.o.h(f.b.ON_PAUSE);
    }

    @Override // android.app.Activity
    public void onPictureInPictureModeChanged(boolean z) {
        this.n.n(z);
    }

    @Override // android.app.Activity
    protected void onPostResume() {
        super.onPostResume();
        y();
    }

    @Override // android.app.Activity, android.view.Window.Callback
    public boolean onPreparePanel(int i2, View view, Menu menu) {
        return i2 == 0 ? x(view, menu) | this.n.o(menu) : super.onPreparePanel(i2, view, menu);
    }

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

    @Override // android.app.Activity
    protected void onResume() {
        super.onResume();
        this.q = true;
        this.n.u();
        this.n.s();
    }

    @Override // android.app.Activity
    protected void onStart() {
        super.onStart();
        this.r = false;
        if (!this.p) {
            this.p = true;
            this.n.c();
        }
        this.n.u();
        this.n.s();
        this.o.h(f.b.ON_START);
        this.n.q();
    }

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

    @Override // android.app.Activity
    protected void onStop() {
        super.onStop();
        this.r = true;
        u();
        this.n.r();
        this.o.h(f.b.ON_STOP);
    }

    final View r(View view, String str, Context context, AttributeSet attributeSet) {
        return this.n.v(view, str, context, attributeSet);
    }

    public m s() {
        return this.n.t();
    }

    void u() {
        while (v(s(), f.c.CREATED)) {
        }
    }

    @Deprecated
    public void w(Fragment fragment) {
    }

    @Deprecated
    protected boolean x(View view, Menu menu) {
        return super.onPreparePanel(0, view, menu);
    }

    protected void y() {
        this.o.h(f.b.ON_RESUME);
        this.n.p();
    }

    @Deprecated
    public void z() {
        invalidateOptionsMenu();
    }

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