package android.support.v4.app;

import android.arch.lifecycle.c;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Parcelable;
import android.support.v4.app.a;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import okhttp3.internal.http2.Settings;

/* JADX INFO: compiled from: FragmentActivity.java */
/* JADX INFO: loaded from: classes.dex */
public class f extends c0 implements android.arch.lifecycle.q {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private android.arch.lifecycle.p f530e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    boolean f531f;
    boolean g;
    boolean i;
    boolean j;
    int k;
    a.b.c.f.l<String> l;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    final Handler f528c = new a();

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    final h f529d = h.b(new b());
    boolean h = true;

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

        @Override // android.os.Handler
        public void handleMessage(Message message) {
            if (message.what != 2) {
                super.handleMessage(message);
            } else {
                f.this.o();
                f.this.f529d.s();
            }
        }
    }

    /* JADX INFO: compiled from: FragmentActivity.java */
    class b extends i<f> {
        public b() {
            super(f.this);
        }

        @Override // android.support.v4.app.g
        public View b(int i) {
            return f.this.findViewById(i);
        }

        @Override // android.support.v4.app.g
        public boolean c() {
            Window window = f.this.getWindow();
            return (window == null || window.peekDecorView() == null) ? false : true;
        }

        @Override // android.support.v4.app.i
        public void h(e eVar) {
            f.this.m(eVar);
        }

        @Override // android.support.v4.app.i
        public void i(String str, FileDescriptor fileDescriptor, PrintWriter printWriter, String[] strArr) {
            f.this.dump(str, fileDescriptor, printWriter, strArr);
        }

        @Override // android.support.v4.app.i
        public LayoutInflater j() {
            return f.this.getLayoutInflater().cloneInContext(f.this);
        }

        @Override // android.support.v4.app.i
        public int k() {
            Window window = f.this.getWindow();
            if (window == null) {
                return 0;
            }
            return window.getAttributes().windowAnimations;
        }

        @Override // android.support.v4.app.i
        public boolean l() {
            return f.this.getWindow() != null;
        }

        @Override // android.support.v4.app.i
        public boolean m(e eVar) {
            return !f.this.isFinishing();
        }

        @Override // android.support.v4.app.i
        public void n() {
            f.this.q();
        }
    }

    /* JADX INFO: compiled from: FragmentActivity.java */
    static final class c {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        Object f534a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        android.arch.lifecycle.p f535b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        l f536c;

        c() {
        }
    }

    static void h(int i) {
        if ((i & (-65536)) != 0) {
            throw new IllegalArgumentException("Can only use lower 16 bits for requestCode");
        }
    }

    private void k() {
        while (l(j(), c.b.CREATED)) {
        }
    }

    private static boolean l(j jVar, c.b bVar) {
        boolean zL = false;
        for (e eVar : jVar.b()) {
            if (eVar != null) {
                if (eVar.a().b().isAtLeast(c.b.STARTED)) {
                    eVar.T.k(bVar);
                    zL = true;
                }
                j jVarS0 = eVar.s0();
                if (jVarS0 != null) {
                    zL |= l(jVarS0, bVar);
                }
            }
        }
        return zL;
    }

    @Override // android.support.v4.app.c0, android.arch.lifecycle.e
    public android.arch.lifecycle.c a() {
        return super.a();
    }

    @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.f531f);
        printWriter.print(" mResumed=");
        printWriter.print(this.g);
        printWriter.print(" mStopped=");
        printWriter.print(this.h);
        if (getApplication() != null) {
            s.b(this).a(str2, fileDescriptor, printWriter, strArr);
        }
        this.f529d.u().a(str, fileDescriptor, printWriter, strArr);
    }

    @Override // android.arch.lifecycle.q
    public android.arch.lifecycle.p f() {
        if (getApplication() == null) {
            throw new IllegalStateException("Your activity is not yet attached to the Application instance. You can't request ViewModel before onCreate call.");
        }
        if (this.f530e == null) {
            c cVar = (c) getLastNonConfigurationInstance();
            if (cVar != null) {
                this.f530e = cVar.f535b;
            }
            if (this.f530e == null) {
                this.f530e = new android.arch.lifecycle.p();
            }
        }
        return this.f530e;
    }

    final View i(View view, String str, Context context, AttributeSet attributeSet) {
        return this.f529d.w(view, str, context, attributeSet);
    }

    public j j() {
        return this.f529d.u();
    }

    public void m(e eVar) {
    }

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

    protected void o() {
        this.f529d.p();
    }

    @Override // android.app.Activity
    protected void onActivityResult(int i, int i2, Intent intent) {
        this.f529d.v();
        int i3 = i >> 16;
        if (i3 == 0) {
            a.InterfaceC0018a interfaceC0018aE = android.support.v4.app.a.e();
            if (interfaceC0018aE == null || !interfaceC0018aE.a(this, i, i2, intent)) {
                super.onActivityResult(i, i2, intent);
                return;
            }
            return;
        }
        int i4 = i3 - 1;
        String strF = this.l.f(i4);
        this.l.j(i4);
        if (strF == null) {
            Log.w("FragmentActivity", "Activity result delivered for unknown Fragment.");
            return;
        }
        e eVarT = this.f529d.t(strF);
        if (eVarT != null) {
            eVarT.N(i & Settings.DEFAULT_INITIAL_WINDOW_SIZE, i2, intent);
            return;
        }
        Log.w("FragmentActivity", "Activity result no fragment exists for who: " + strF);
    }

    @Override // android.app.Activity
    public void onBackPressed() {
        j jVarU = this.f529d.u();
        boolean zC = jVarU.c();
        if (!zC || Build.VERSION.SDK_INT > 25) {
            if (zC || !jVarU.d()) {
                super.onBackPressed();
            }
        }
    }

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

    @Override // android.support.v4.app.c0, android.app.Activity
    protected void onCreate(Bundle bundle) {
        android.arch.lifecycle.p pVar;
        this.f529d.a(null);
        super.onCreate(bundle);
        c cVar = (c) getLastNonConfigurationInstance();
        if (cVar != null && (pVar = cVar.f535b) != null && this.f530e == null) {
            this.f530e = pVar;
        }
        if (bundle != null) {
            this.f529d.x(bundle.getParcelable("android:support:fragments"), cVar != null ? cVar.f536c : null);
            if (bundle.containsKey("android:support:next_request_index")) {
                this.k = bundle.getInt("android:support:next_request_index");
                int[] intArray = bundle.getIntArray("android:support:request_indicies");
                String[] stringArray = bundle.getStringArray("android:support:request_fragment_who");
                if (intArray == null || stringArray == null || intArray.length != stringArray.length) {
                    Log.w("FragmentActivity", "Invalid requestCode mapping in savedInstanceState.");
                } else {
                    this.l = new a.b.c.f.l<>(intArray.length);
                    for (int i = 0; i < intArray.length; i++) {
                        this.l.i(intArray[i], stringArray[i]);
                    }
                }
            }
        }
        if (this.l == null) {
            this.l = new a.b.c.f.l<>();
            this.k = 0;
        }
        this.f529d.f();
    }

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

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

    @Override // android.app.Activity
    protected void onDestroy() {
        super.onDestroy();
        if (this.f530e != null && !isChangingConfigurations()) {
            this.f530e.a();
        }
        this.f529d.h();
    }

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

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

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

    @Override // android.app.Activity
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        this.f529d.v();
    }

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

    @Override // android.app.Activity
    protected void onPause() {
        super.onPause();
        this.g = false;
        if (this.f528c.hasMessages(2)) {
            this.f528c.removeMessages(2);
            o();
        }
        this.f529d.m();
    }

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

    @Override // android.app.Activity
    protected void onPostResume() {
        super.onPostResume();
        this.f528c.removeMessages(2);
        o();
        this.f529d.s();
    }

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

    @Override // android.app.Activity
    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        this.f529d.v();
        int i2 = (i >> 16) & Settings.DEFAULT_INITIAL_WINDOW_SIZE;
        if (i2 != 0) {
            int i3 = i2 - 1;
            String strF = this.l.f(i3);
            this.l.j(i3);
            if (strF == null) {
                Log.w("FragmentActivity", "Activity result delivered for unknown Fragment.");
                return;
            }
            e eVarT = this.f529d.t(strF);
            if (eVarT != null) {
                eVarT.l0(i & Settings.DEFAULT_INITIAL_WINDOW_SIZE, strArr, iArr);
                return;
            }
            Log.w("FragmentActivity", "Activity result no fragment exists for who: " + strF);
        }
    }

    @Override // android.app.Activity
    protected void onResume() {
        super.onResume();
        this.f528c.sendEmptyMessage(2);
        this.g = true;
        this.f529d.s();
    }

    @Override // android.app.Activity
    public final Object onRetainNonConfigurationInstance() {
        Object objP = p();
        l lVarY = this.f529d.y();
        if (lVarY == null && this.f530e == null && objP == null) {
            return null;
        }
        c cVar = new c();
        cVar.f534a = objP;
        cVar.f535b = this.f530e;
        cVar.f536c = lVarY;
        return cVar;
    }

    @Override // android.support.v4.app.c0, android.app.Activity
    protected void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        k();
        Parcelable parcelableZ = this.f529d.z();
        if (parcelableZ != null) {
            bundle.putParcelable("android:support:fragments", parcelableZ);
        }
        if (this.l.k() > 0) {
            bundle.putInt("android:support:next_request_index", this.k);
            int[] iArr = new int[this.l.k()];
            String[] strArr = new String[this.l.k()];
            for (int i = 0; i < this.l.k(); i++) {
                iArr[i] = this.l.h(i);
                strArr[i] = this.l.l(i);
            }
            bundle.putIntArray("android:support:request_indicies", iArr);
            bundle.putStringArray("android:support:request_fragment_who", strArr);
        }
    }

    @Override // android.app.Activity
    protected void onStart() {
        super.onStart();
        this.h = false;
        if (!this.f531f) {
            this.f531f = true;
            this.f529d.c();
        }
        this.f529d.v();
        this.f529d.s();
        this.f529d.q();
    }

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

    @Override // android.app.Activity
    protected void onStop() {
        super.onStop();
        this.h = true;
        k();
        this.f529d.r();
    }

    public Object p() {
        return null;
    }

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

    @Override // android.app.Activity
    public void startActivityForResult(Intent intent, int i) {
        if (!this.j && i != -1) {
            h(i);
        }
        super.startActivityForResult(intent, i);
    }

    @Override // android.app.Activity
    public void startIntentSenderForResult(IntentSender intentSender, int i, Intent intent, int i2, int i3, int i4) throws IntentSender.SendIntentException {
        if (!this.i && i != -1) {
            h(i);
        }
        super.startIntentSenderForResult(intentSender, i, intent, i2, i3, i4);
    }

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

    @Override // android.app.Activity
    public void startActivityForResult(Intent intent, int i, Bundle bundle) {
        if (!this.j && i != -1) {
            h(i);
        }
        super.startActivityForResult(intent, i, bundle);
    }

    @Override // android.app.Activity
    public void startIntentSenderForResult(IntentSender intentSender, int i, Intent intent, int i2, int i3, int i4, Bundle bundle) throws IntentSender.SendIntentException {
        if (!this.i && i != -1) {
            h(i);
        }
        super.startIntentSenderForResult(intentSender, i, intent, i2, i3, i4, bundle);
    }
}
