package c.k.b;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Parcelable;
import android.text.TextUtils;
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.activity.result.ActivityResultRegistry;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import c.f.b.b;
import c.l.j;
import c.o.b;
import java.io.FileDescriptor;
import java.io.PrintWriter;

/* JADX INFO: compiled from: FragmentActivity.java */
/* JADX INFO: loaded from: classes.dex */
public class l extends ComponentActivity implements b.d {
    public static final String FRAGMENTS_TAG = "android:support:fragments";
    public boolean mCreated;
    public final c.l.o mFragmentLifecycleRegistry;
    public final t mFragments;
    public boolean mResumed;
    public boolean mStopped;

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

        @Override // c.o.b.InterfaceC0024b
        public Bundle a() {
            Bundle bundle = new Bundle();
            l.this.markFragmentsCreated();
            l.this.mFragmentLifecycleRegistry.f(j.a.ON_STOP);
            Parcelable parcelableA0 = l.this.mFragments.a.f1742g.a0();
            if (parcelableA0 != null) {
                bundle.putParcelable(l.FRAGMENTS_TAG, parcelableA0);
            }
            return bundle;
        }
    }

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

        @Override // c.a.l.b
        public void a(Context context) {
            v<?> vVar = l.this.mFragments.a;
            vVar.f1742g.b(vVar, vVar, null);
            Bundle bundleA = l.this.getSavedStateRegistry().a(l.FRAGMENTS_TAG);
            if (bundleA != null) {
                Parcelable parcelable = bundleA.getParcelable(l.FRAGMENTS_TAG);
                v<?> vVar2 = l.this.mFragments.a;
                if (!(vVar2 instanceof c.l.h0)) {
                    throw new IllegalStateException("Your FragmentHostCallback must implement ViewModelStoreOwner to call restoreSaveState(). Call restoreAllState()  if you're still using retainNestedNonConfig().");
                }
                vVar2.f1742g.Z(parcelable);
            }
        }
    }

    /* JADX INFO: compiled from: FragmentActivity.java */
    public class c extends v<l> implements c.l.h0, c.a.k, c.a.m.c, a0 {
        public c() {
            super(l.this);
        }

        @Override // c.k.b.a0
        public void a(FragmentManager fragmentManager, Fragment fragment) {
            l.this.onAttachFragment(fragment);
        }

        @Override // c.k.b.r
        public View b(int i2) {
            return l.this.findViewById(i2);
        }

        @Override // c.k.b.r
        public boolean c() {
            Window window = l.this.getWindow();
            return (window == null || window.peekDecorView() == null) ? false : true;
        }

        @Override // c.k.b.v
        public l d() {
            return l.this;
        }

        @Override // c.k.b.v
        public LayoutInflater e() {
            return l.this.getLayoutInflater().cloneInContext(l.this);
        }

        @Override // c.k.b.v
        public boolean f(Fragment fragment) {
            return !l.this.isFinishing();
        }

        @Override // c.k.b.v
        public boolean g(String str) {
            l lVar = l.this;
            int i2 = c.f.b.b.f1274b;
            if (c.f.b.h.s() || !TextUtils.equals("android.permission.POST_NOTIFICATIONS", str)) {
                return b.c.c(lVar, str);
            }
            return false;
        }

        @Override // c.a.m.c
        public ActivityResultRegistry getActivityResultRegistry() {
            return l.this.getActivityResultRegistry();
        }

        @Override // c.l.n
        public c.l.j getLifecycle() {
            return l.this.mFragmentLifecycleRegistry;
        }

        @Override // c.a.k
        public OnBackPressedDispatcher getOnBackPressedDispatcher() {
            return l.this.getOnBackPressedDispatcher();
        }

        @Override // c.l.h0
        public c.l.g0 getViewModelStore() {
            return l.this.getViewModelStore();
        }

        @Override // c.k.b.v
        public void h() {
            l.this.supportInvalidateOptionsMenu();
        }
    }

    public l() {
        c cVar = new c();
        c.f.b.h.f(cVar, "callbacks == null");
        this.mFragments = new t(cVar);
        this.mFragmentLifecycleRegistry = new c.l.o(this);
        this.mStopped = true;
        init();
    }

    private void init() {
        getSavedStateRegistry().c(FRAGMENTS_TAG, new a());
        addOnContextAvailableListener(new b());
    }

    private static boolean markState(FragmentManager fragmentManager, j.b bVar) {
        boolean zMarkState = false;
        for (Fragment fragment : fragmentManager.f336c.i()) {
            if (fragment != null) {
                if (fragment.getHost() != null) {
                    zMarkState |= markState(fragment.getChildFragmentManager(), bVar);
                }
                p0 p0Var = fragment.mViewLifecycleOwner;
                if (p0Var != null) {
                    p0Var.b();
                    if (p0Var.f1711e.f1778b.isAtLeast(j.b.STARTED)) {
                        c.l.o oVar = fragment.mViewLifecycleOwner.f1711e;
                        oVar.e("setCurrentState");
                        oVar.h(bVar);
                        zMarkState = true;
                    }
                }
                if (fragment.mLifecycleRegistry.f1778b.isAtLeast(j.b.STARTED)) {
                    c.l.o oVar2 = fragment.mLifecycleRegistry;
                    oVar2.e("setCurrentState");
                    oVar2.h(bVar);
                    zMarkState = true;
                }
            }
        }
        return zMarkState;
    }

    public final View dispatchFragmentsOnCreateView(View view, String str, Context context, AttributeSet attributeSet) {
        return this.mFragments.a.f1742g.f339f.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);
        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) {
            c.m.a.a.b(this).a(str2, fileDescriptor, printWriter, strArr);
        }
        this.mFragments.a.f1742g.y(str, fileDescriptor, printWriter, strArr);
    }

    public FragmentManager getSupportFragmentManager() {
        return this.mFragments.a.f1742g;
    }

    @Deprecated
    public c.m.a.a getSupportLoaderManager() {
        return c.m.a.a.b(this);
    }

    public void markFragmentsCreated() {
        while (markState(getSupportFragmentManager(), j.b.CREATED)) {
        }
    }

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

    @Deprecated
    public void onAttachFragment(Fragment fragment) {
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity, android.content.ComponentCallbacks
    public void onConfigurationChanged(Configuration configuration) {
        this.mFragments.a();
        super.onConfigurationChanged(configuration);
        this.mFragments.a.f1742g.k(configuration);
    }

    @Override // androidx.activity.ComponentActivity, c.f.b.i, android.app.Activity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.mFragmentLifecycleRegistry.f(j.a.ON_CREATE);
        this.mFragments.a.f1742g.m();
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity, android.view.Window.Callback
    public boolean onCreatePanelMenu(int i2, Menu menu) {
        if (i2 != 0) {
            return super.onCreatePanelMenu(i2, menu);
        }
        boolean zOnCreatePanelMenu = super.onCreatePanelMenu(i2, menu);
        t tVar = this.mFragments;
        return zOnCreatePanelMenu | tVar.a.f1742g.n(menu, getMenuInflater());
    }

    @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.f1742g.o();
        this.mFragmentLifecycleRegistry.f(j.a.ON_DESTROY);
    }

    @Override // android.app.Activity, android.content.ComponentCallbacks
    public void onLowMemory() {
        super.onLowMemory();
        this.mFragments.a.f1742g.p();
    }

    @Override // androidx.activity.ComponentActivity, 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.mFragments.a.f1742g.r(menuItem);
        }
        if (i2 != 6) {
            return false;
        }
        return this.mFragments.a.f1742g.l(menuItem);
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void onMultiWindowModeChanged(boolean z) {
        this.mFragments.a.f1742g.q(z);
    }

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

    @Override // androidx.activity.ComponentActivity, android.app.Activity, android.view.Window.Callback
    public void onPanelClosed(int i2, Menu menu) {
        if (i2 == 0) {
            this.mFragments.a.f1742g.s(menu);
        }
        super.onPanelClosed(i2, menu);
    }

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

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void onPictureInPictureModeChanged(boolean z) {
        this.mFragments.a.f1742g.u(z);
    }

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

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

    @Override // androidx.activity.ComponentActivity, android.app.Activity, android.view.Window.Callback
    public boolean onPreparePanel(int i2, View view, Menu menu) {
        return i2 == 0 ? onPrepareOptionsPanel(view, menu) | this.mFragments.a.f1742g.v(menu) : super.onPreparePanel(i2, view, menu);
    }

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

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

    public void onResumeFragments() {
        this.mFragmentLifecycleRegistry.f(j.a.ON_RESUME);
        FragmentManager fragmentManager = this.mFragments.a.f1742g;
        fragmentManager.B = false;
        fragmentManager.C = false;
        fragmentManager.J.f1753j = false;
        fragmentManager.w(7);
    }

    @Override // android.app.Activity
    public void onStart() {
        this.mFragments.a();
        super.onStart();
        this.mStopped = false;
        if (!this.mCreated) {
            this.mCreated = true;
            FragmentManager fragmentManager = this.mFragments.a.f1742g;
            fragmentManager.B = false;
            fragmentManager.C = false;
            fragmentManager.J.f1753j = false;
            fragmentManager.w(4);
        }
        this.mFragments.a.f1742g.C(true);
        this.mFragmentLifecycleRegistry.f(j.a.ON_START);
        FragmentManager fragmentManager2 = this.mFragments.a.f1742g;
        fragmentManager2.B = false;
        fragmentManager2.C = false;
        fragmentManager2.J.f1753j = false;
        fragmentManager2.w(5);
    }

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

    @Override // android.app.Activity
    public void onStop() {
        super.onStop();
        this.mStopped = true;
        markFragmentsCreated();
        FragmentManager fragmentManager = this.mFragments.a.f1742g;
        fragmentManager.C = true;
        fragmentManager.J.f1753j = true;
        fragmentManager.w(4);
        this.mFragmentLifecycleRegistry.f(j.a.ON_STOP);
    }

    public void setEnterSharedElementCallback(c.f.b.n nVar) {
        int i2 = c.f.b.b.f1274b;
        b.C0009b.c(this, null);
    }

    public void setExitSharedElementCallback(c.f.b.n nVar) {
        int i2 = c.f.b.b.f1274b;
        b.C0009b.d(this, null);
    }

    public void startActivityFromFragment(Fragment fragment, @SuppressLint({"UnknownNullness"}) Intent intent, int i2, Bundle bundle) {
        if (i2 != -1) {
            fragment.startActivityForResult(intent, i2, bundle);
        } else {
            int i3 = c.f.b.b.f1274b;
            b.a.b(this, intent, -1, bundle);
        }
    }

    @Deprecated
    public void startIntentSenderFromFragment(Fragment fragment, @SuppressLint({"UnknownNullness"}) IntentSender intentSender, int i2, Intent intent, int i3, int i4, int i5, Bundle bundle) throws IntentSender.SendIntentException {
        if (i2 != -1) {
            fragment.startIntentSenderForResult(intentSender, i2, intent, i3, i4, i5, bundle);
        } else {
            int i6 = c.f.b.b.f1274b;
            b.a.c(this, intentSender, i2, intent, i3, i4, i5, bundle);
        }
    }

    public void supportFinishAfterTransition() {
        int i2 = c.f.b.b.f1274b;
        b.C0009b.a(this);
    }

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

    public void supportPostponeEnterTransition() {
        int i2 = c.f.b.b.f1274b;
        b.C0009b.b(this);
    }

    public void supportStartPostponedEnterTransition() {
        int i2 = c.f.b.b.f1274b;
        b.C0009b.e(this);
    }

    @Override // c.f.b.b.d
    @Deprecated
    public final void validateRequestPermissionsRequestCode(int i2) {
    }

    @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(Fragment fragment, @SuppressLint({"UnknownNullness"}) Intent intent, int i2) {
        startActivityFromFragment(fragment, intent, i2, (Bundle) null);
    }

    public l(int i2) {
        super(i2);
        c cVar = new c();
        c.f.b.h.f(cVar, "callbacks == null");
        this.mFragments = new t(cVar);
        this.mFragmentLifecycleRegistry = new c.l.o(this);
        this.mStopped = true;
        init();
    }
}
