package d.k.b;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.lifecycle.LiveData;
import com.ifpdos.udi.service.core.pc.R;
import d.k.b.a0.m;
import d.k.b.i0;
import d.k.b.m;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public class l extends m implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener {
    public Handler e0;
    public boolean n0;
    public Dialog p0;
    public boolean q0;
    public boolean r0;
    public Runnable f0 = new a();
    public DialogInterface.OnCancelListener g0 = new b();
    public DialogInterface.OnDismissListener h0 = new c();
    public int i0 = 0;
    public int j0 = 0;
    public boolean k0 = true;
    public boolean l0 = true;
    public int m0 = -1;
    public d.m.n<d.m.h> o0 = new d();
    public boolean s0 = false;

    public class a implements Runnable {
        public a() {
        }

        @Override // java.lang.Runnable
        @SuppressLint({"SyntheticAccessor"})
        public void run() {
            l lVar = l.this;
            lVar.h0.onDismiss(lVar.p0);
        }
    }

    public class b implements DialogInterface.OnCancelListener {
        public b() {
        }

        @Override // android.content.DialogInterface.OnCancelListener
        @SuppressLint({"SyntheticAccessor"})
        public void onCancel(DialogInterface dialogInterface) {
            l lVar = l.this;
            Dialog dialog = lVar.p0;
            if (dialog != null) {
                lVar.onCancel(dialog);
            }
        }
    }

    public class c implements DialogInterface.OnDismissListener {
        public c() {
        }

        @Override // android.content.DialogInterface.OnDismissListener
        @SuppressLint({"SyntheticAccessor"})
        public void onDismiss(DialogInterface dialogInterface) {
            l lVar = l.this;
            Dialog dialog = lVar.p0;
            if (dialog != null) {
                lVar.onDismiss(dialog);
            }
        }
    }

    public class d implements d.m.n<d.m.h> {
        public d() {
        }
    }

    public class e extends t {
        public final /* synthetic */ t a;

        public e(t tVar) {
            this.a = tVar;
        }

        @Override // d.k.b.t
        public View b(int i2) {
            if (this.a.c()) {
                return this.a.b(i2);
            }
            Dialog dialog = l.this.p0;
            if (dialog != null) {
                return dialog.findViewById(i2);
            }
            return null;
        }

        @Override // d.k.b.t
        public boolean c() {
            return this.a.c() || l.this.s0;
        }
    }

    @Override // d.k.b.m
    public void E(Context context) {
        super.E(context);
        d.m.m<d.m.h> mVar = this.f3037b0;
        d.m.n<d.m.h> nVar = this.o0;
        Objects.requireNonNull(mVar);
        LiveData.a("observeForever");
        LiveData.a aVar = new LiveData.a(mVar, nVar);
        LiveData<d.m.h>.b bVarD = mVar.f689c.d(nVar, aVar);
        if (bVarD instanceof LiveData.LifecycleBoundObserver) {
            throw new IllegalArgumentException("Cannot add the same observer with different lifecycles");
        }
        if (bVarD == null) {
            aVar.h(true);
        }
        this.r0 = false;
    }

    @Override // d.k.b.m
    public void H(Bundle bundle) {
        super.H(bundle);
        this.e0 = new Handler();
        this.l0 = this.I == 0;
        if (bundle != null) {
            this.i0 = bundle.getInt("android:style", 0);
            this.j0 = bundle.getInt("android:theme", 0);
            this.k0 = bundle.getBoolean("android:cancelable", true);
            this.l0 = bundle.getBoolean("android:showsDialog", this.l0);
            this.m0 = bundle.getInt("android:backStackId", -1);
        }
    }

    @Override // d.k.b.m
    public void L() {
        this.O = true;
        Dialog dialog = this.p0;
        if (dialog != null) {
            this.q0 = true;
            dialog.setOnDismissListener(null);
            this.p0.dismiss();
            if (!this.r0) {
                onDismiss(this.p0);
            }
            this.p0 = null;
            this.s0 = false;
        }
    }

    @Override // d.k.b.m
    public void M() {
        this.O = true;
        if (!this.r0) {
            this.r0 = true;
        }
        this.f3037b0.f(this.o0);
    }

    /* JADX WARN: Removed duplicated region for block: B:26:0x0046 A[Catch: all -> 0x006b, TryCatch #0 {all -> 0x006b, blocks: (B:12:0x001a, B:14:0x0026, B:24:0x003e, B:26:0x0046, B:27:0x004d, B:20:0x0030, B:22:0x0036, B:23:0x003b, B:28:0x0065), top: B:48:0x001a }] */
    @Override // d.k.b.m
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public android.view.LayoutInflater N(android.os.Bundle r8) {
        /*
            Method dump skipped, instruction units count: 211
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: d.k.b.l.N(android.os.Bundle):android.view.LayoutInflater");
    }

    @Override // d.k.b.m
    public void V(Bundle bundle) {
        Dialog dialog = this.p0;
        if (dialog != null) {
            Bundle bundleOnSaveInstanceState = dialog.onSaveInstanceState();
            bundleOnSaveInstanceState.putBoolean("android:dialogShowing", false);
            bundle.putBundle("android:savedDialogState", bundleOnSaveInstanceState);
        }
        int i2 = this.i0;
        if (i2 != 0) {
            bundle.putInt("android:style", i2);
        }
        int i3 = this.j0;
        if (i3 != 0) {
            bundle.putInt("android:theme", i3);
        }
        boolean z2 = this.k0;
        if (!z2) {
            bundle.putBoolean("android:cancelable", z2);
        }
        boolean z3 = this.l0;
        if (!z3) {
            bundle.putBoolean("android:showsDialog", z3);
        }
        int i4 = this.m0;
        if (i4 != -1) {
            bundle.putInt("android:backStackId", i4);
        }
    }

    @Override // d.k.b.m
    public void W() {
        this.O = true;
        Dialog dialog = this.p0;
        if (dialog != null) {
            this.q0 = false;
            dialog.show();
            View decorView = this.p0.getWindow().getDecorView();
            decorView.setTag(R.id.view_tree_lifecycle_owner, this);
            decorView.setTag(R.id.view_tree_view_model_store_owner, this);
            decorView.setTag(R.id.view_tree_saved_state_registry_owner, this);
        }
    }

    @Override // d.k.b.m
    public void X() {
        this.O = true;
        Dialog dialog = this.p0;
        if (dialog != null) {
            dialog.hide();
        }
    }

    @Override // d.k.b.m
    public void Z(Bundle bundle) {
        Bundle bundle2;
        this.O = true;
        if (this.p0 == null || bundle == null || (bundle2 = bundle.getBundle("android:savedDialogState")) == null) {
            return;
        }
        this.p0.onRestoreInstanceState(bundle2);
    }

    @Override // d.k.b.m
    public t a() {
        return new e(new m.a());
    }

    @Override // d.k.b.m
    public void b0(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        Bundle bundle2;
        super.b0(layoutInflater, viewGroup, bundle);
        if (this.Q != null || this.p0 == null || bundle == null || (bundle2 = bundle.getBundle("android:savedDialogState")) == null) {
            return;
        }
        this.p0.onRestoreInstanceState(bundle2);
    }

    @Override // android.content.DialogInterface.OnCancelListener
    public void onCancel(DialogInterface dialogInterface) {
    }

    @Override // android.content.DialogInterface.OnDismissListener
    public void onDismiss(DialogInterface dialogInterface) {
        if (this.q0) {
            return;
        }
        if (a0.M(3)) {
            Log.d("FragmentManager", "onDismiss called for DialogFragment " + this);
        }
        r0(true, true);
    }

    public final void r0(boolean z2, boolean z3) {
        if (this.r0) {
            return;
        }
        this.r0 = true;
        Dialog dialog = this.p0;
        if (dialog != null) {
            dialog.setOnDismissListener(null);
            this.p0.dismiss();
            if (!z3) {
                if (Looper.myLooper() == this.e0.getLooper()) {
                    onDismiss(this.p0);
                } else {
                    this.e0.post(this.f0);
                }
            }
        }
        this.q0 = true;
        if (this.m0 >= 0) {
            a0 a0VarO = o();
            int i2 = this.m0;
            if (i2 < 0) {
                throw new IllegalArgumentException(g.a.a.a.a.l("Bad id: ", i2));
            }
            a0VarO.A(a0VarO.new m(null, i2, 1), false);
            this.m0 = -1;
            return;
        }
        d.k.b.a aVar = new d.k.b.a(o());
        a0 a0Var = this.D;
        if (a0Var != null && a0Var != aVar.f2888p) {
            StringBuilder sbF = g.a.a.a.a.F("Cannot remove Fragment attached to a different FragmentManager. Fragment ");
            sbF.append(toString());
            sbF.append(" is already attached to a FragmentManager.");
            throw new IllegalStateException(sbF.toString());
        }
        aVar.b(new i0.a(3, this));
        if (z2) {
            aVar.d(true);
        } else {
            aVar.d(false);
        }
    }

    public Dialog s0(Bundle bundle) {
        if (a0.M(3)) {
            Log.d("FragmentManager", "onCreateDialog called for DialogFragment " + this);
        }
        return new Dialog(g0(), this.j0);
    }

    public final Dialog t0() {
        Dialog dialog = this.p0;
        if (dialog != null) {
            return dialog;
        }
        throw new IllegalStateException("DialogFragment " + this + " does not have a Dialog.");
    }
}
