package androidx.fragment.app; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; /* loaded from: classes.dex */ public class DialogFragment extends Fragment implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { int a = 0; int b = 0; boolean c = true; boolean d = true; int e = -1; Dialog f; boolean g; boolean h; boolean i; public Dialog a(Bundle bundle) { throw null; } public void a(FragmentManager fragmentManager, String str) { this.h = false; this.i = true; FragmentTransaction a = fragmentManager.a(); a.a(this, str); a.a(); } public Dialog b() { return this.f; } @Override // androidx.fragment.app.Fragment public void onActivityCreated(Bundle bundle) { Bundle bundle2; super.onActivityCreated(bundle); if (this.d) { View view = getView(); if (view != null) { if (view.getParent() != null) { throw new IllegalStateException("DialogFragment can not be attached to a container view"); } this.f.setContentView(view); } FragmentActivity activity = getActivity(); if (activity != null) { this.f.setOwnerActivity(activity); } this.f.setCancelable(this.c); this.f.setOnCancelListener(this); this.f.setOnDismissListener(this); if (bundle == null || (bundle2 = bundle.getBundle("android:savedDialogState")) == null) { return; } this.f.onRestoreInstanceState(bundle2); } } @Override // androidx.fragment.app.Fragment public void onAttach(Context context) { super.onAttach(context); if (this.i) { return; } this.h = false; } @Override // android.content.DialogInterface.OnCancelListener public void onCancel(DialogInterface dialogInterface) { } @Override // androidx.fragment.app.Fragment public void onCreate(Bundle bundle) { super.onCreate(bundle); this.d = this.mContainerId == 0; if (bundle != null) { this.a = bundle.getInt("android:style", 0); this.b = bundle.getInt("android:theme", 0); this.c = bundle.getBoolean("android:cancelable", true); this.d = bundle.getBoolean("android:showsDialog", this.d); this.e = bundle.getInt("android:backStackId", -1); } } @Override // androidx.fragment.app.Fragment public void onDestroyView() { super.onDestroyView(); Dialog dialog = this.f; if (dialog != null) { this.g = true; dialog.dismiss(); this.f = null; } } @Override // androidx.fragment.app.Fragment public void onDetach() { super.onDetach(); if (this.i || this.h) { return; } this.h = true; } @Override // android.content.DialogInterface.OnDismissListener public void onDismiss(DialogInterface dialogInterface) { if (this.g) { return; } a(true); } @Override // androidx.fragment.app.Fragment public LayoutInflater onGetLayoutInflater(Bundle bundle) { if (!this.d) { return super.onGetLayoutInflater(bundle); } this.f = a(bundle); Dialog dialog = this.f; if (dialog == null) { return (LayoutInflater) this.mHost.c().getSystemService("layout_inflater"); } a(dialog, this.a); return (LayoutInflater) this.f.getContext().getSystemService("layout_inflater"); } @Override // androidx.fragment.app.Fragment public void onSaveInstanceState(Bundle bundle) { Bundle onSaveInstanceState; super.onSaveInstanceState(bundle); Dialog dialog = this.f; if (dialog != null && (onSaveInstanceState = dialog.onSaveInstanceState()) != null) { bundle.putBundle("android:savedDialogState", onSaveInstanceState); } int i = this.a; if (i != 0) { bundle.putInt("android:style", i); } int i2 = this.b; if (i2 != 0) { bundle.putInt("android:theme", i2); } boolean z = this.c; if (!z) { bundle.putBoolean("android:cancelable", z); } boolean z2 = this.d; if (!z2) { bundle.putBoolean("android:showsDialog", z2); } int i3 = this.e; if (i3 != -1) { bundle.putInt("android:backStackId", i3); } } @Override // androidx.fragment.app.Fragment public void onStart() { super.onStart(); Dialog dialog = this.f; if (dialog != null) { this.g = false; dialog.show(); } } @Override // androidx.fragment.app.Fragment public void onStop() { super.onStop(); Dialog dialog = this.f; if (dialog != null) { dialog.hide(); } } public void b(boolean z) { this.d = z; } void a(boolean z) { if (this.h) { return; } this.h = true; this.i = false; Dialog dialog = this.f; if (dialog != null) { dialog.dismiss(); } this.g = true; if (this.e >= 0) { getFragmentManager().a(this.e, 1); this.e = -1; return; } FragmentTransaction a = getFragmentManager().a(); a.d(this); if (z) { a.b(); } else { a.a(); } } public void a(Dialog dialog, int i) { if (i != 1 && i != 2) { if (i != 3) { return; } else { dialog.getWindow().addFlags(24); } } dialog.requestWindowFeature(1); } }