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.lifecycle.g;
import g0.c;
import java.io.FileDescriptor;
import java.io.PrintWriter;

/* JADX INFO: compiled from: FragmentActivity.java */
/* JADX INFO: loaded from: classes.dex */
public class e extends ComponentActivity {

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    boolean f2294u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    boolean f2295v;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    final h f2292s = h.b(new c());

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    final androidx.lifecycle.l f2293t = new androidx.lifecycle.l(this);

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    boolean f2296w = true;

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

        @Override // g0.c.InterfaceC0065c
        public Bundle a() {
            Bundle bundle = new Bundle();
            e.this.y();
            e.this.f2293t.h(g.b.ON_STOP);
            Parcelable parcelableX = e.this.f2292s.x();
            if (parcelableX != null) {
                bundle.putParcelable("android:support:fragments", parcelableX);
            }
            return bundle;
        }
    }

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

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

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

        @Override // androidx.lifecycle.k
        public androidx.lifecycle.g a() {
            return e.this.f2293t;
        }

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

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

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

        @Override // androidx.fragment.app.j, androidx.fragment.app.g
        public View g(int i3) {
            return e.this.findViewById(i3);
        }

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

        @Override // androidx.lifecycle.d0
        public androidx.lifecycle.c0 i() {
            return e.this.i();
        }

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

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

        @Override // androidx.fragment.app.j
        public void p() {
            e.this.D();
        }

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

    public e() {
        x();
    }

    private void x() {
        d().h("android:support:fragments", new a());
        o(new b());
    }

    private static boolean z(m mVar, g.c cVar) {
        boolean z2 = false;
        for (Fragment fragment : mVar.r0()) {
            if (fragment != null) {
                if (fragment.z() != null) {
                    z2 |= z(fragment.q(), cVar);
                }
                z zVar = fragment.W;
                if (zVar != null && zVar.a().b().isAtLeast(g.c.STARTED)) {
                    fragment.W.k(cVar);
                    z2 = true;
                }
                if (fragment.V.b().isAtLeast(g.c.STARTED)) {
                    fragment.V.o(cVar);
                    z2 = true;
                }
            }
        }
        return z2;
    }

    @Deprecated
    public void A(Fragment fragment) {
    }

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

    protected void C() {
        this.f2293t.h(g.b.ON_RESUME);
        this.f2292s.p();
    }

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

    @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.f2294u);
        printWriter.print(" mResumed=");
        printWriter.print(this.f2295v);
        printWriter.print(" mStopped=");
        printWriter.print(this.f2296w);
        if (getApplication() != null) {
            androidx.loader.app.a.b(this).a(str2, fileDescriptor, printWriter, strArr);
        }
        this.f2292s.t().W(str, fileDescriptor, printWriter, strArr);
    }

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

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

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

    @Override // androidx.activity.ComponentActivity, android.app.Activity, android.view.Window.Callback
    public boolean onCreatePanelMenu(int i3, Menu menu) {
        if (i3 != 0) {
            return super.onCreatePanelMenu(i3, menu);
        }
        return this.f2292s.g(menu, getMenuInflater()) | super.onCreatePanelMenu(i3, menu);
    }

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

    @Override // android.app.Activity
    protected void onDestroy() {
        super.onDestroy();
        this.f2292s.h();
        this.f2293t.h(g.b.ON_DESTROY);
    }

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

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

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void onMultiWindowModeChanged(boolean z2) {
        this.f2292s.j(z2);
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    protected void onNewIntent(@SuppressLint({"UnknownNullness"}) Intent intent) {
        this.f2292s.u();
        super.onNewIntent(intent);
    }

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

    @Override // android.app.Activity
    protected void onPause() {
        super.onPause();
        this.f2295v = false;
        this.f2292s.m();
        this.f2293t.h(g.b.ON_PAUSE);
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void onPictureInPictureModeChanged(boolean z2) {
        this.f2292s.n(z2);
    }

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

    @Override // androidx.activity.ComponentActivity, android.app.Activity, android.view.Window.Callback
    public boolean onPreparePanel(int i3, View view, Menu menu) {
        if (i3 != 0) {
            return super.onPreparePanel(i3, view, menu);
        }
        return this.f2292s.o(menu) | B(view, menu);
    }

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

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

    @Override // android.app.Activity
    protected void onStart() {
        this.f2292s.u();
        super.onStart();
        this.f2296w = false;
        if (!this.f2294u) {
            this.f2294u = true;
            this.f2292s.c();
        }
        this.f2292s.s();
        this.f2293t.h(g.b.ON_START);
        this.f2292s.q();
    }

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

    @Override // android.app.Activity
    protected void onStop() {
        super.onStop();
        this.f2296w = true;
        y();
        this.f2292s.r();
        this.f2293t.h(g.b.ON_STOP);
    }

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

    public m w() {
        return this.f2292s.t();
    }

    void y() {
        while (z(w(), g.c.CREATED)) {
        }
    }

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