package o;

import android.content.DialogInterface;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class EO implements DialogInterface.OnKeyListener, DialogInterface.OnClickListener, DialogInterface.OnDismissListener, InterfaceC0998dP {
    public SubMenuC2155pb0 l;
    public DialogInterfaceC1350h2 m;
    public ML n;

    @Override // o.InterfaceC0998dP
    public final void a(CO co, boolean z) {
        DialogInterfaceC1350h2 dialogInterfaceC1350h2;
        if ((z || co == this.l) && (dialogInterfaceC1350h2 = this.m) != null) {
            dialogInterfaceC1350h2.dismiss();
        }
    }

    @Override // o.InterfaceC0998dP
    public final boolean k(CO co) {
        return false;
    }

    @Override // android.content.DialogInterface.OnClickListener
    public final void onClick(DialogInterface dialogInterface, int i) {
        SubMenuC2155pb0 subMenuC2155pb0 = this.l;
        ML ml = this.n;
        if (ml.q == null) {
            ml.q = new LL(ml);
        }
        subMenuC2155pb0.q(ml.q.getItem(i), null, 0);
    }

    @Override // android.content.DialogInterface.OnDismissListener
    public final void onDismiss(DialogInterface dialogInterface) {
        this.n.a(this.l, true);
    }

    @Override // android.content.DialogInterface.OnKeyListener
    public final boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
        Window window;
        View decorView;
        KeyEvent.DispatcherState keyDispatcherState;
        View decorView2;
        KeyEvent.DispatcherState keyDispatcherState2;
        SubMenuC2155pb0 subMenuC2155pb0 = this.l;
        if (i == 82 || i == 4) {
            if (keyEvent.getAction() == 0 && keyEvent.getRepeatCount() == 0) {
                Window window2 = this.m.getWindow();
                if (window2 != null && (decorView2 = window2.getDecorView()) != null && (keyDispatcherState2 = decorView2.getKeyDispatcherState()) != null) {
                    keyDispatcherState2.startTracking(keyEvent, this);
                    return true;
                }
            } else if (keyEvent.getAction() == 1 && !keyEvent.isCanceled() && (window = this.m.getWindow()) != null && (decorView = window.getDecorView()) != null && (keyDispatcherState = decorView.getKeyDispatcherState()) != null && keyDispatcherState.isTracking(keyEvent)) {
                subMenuC2155pb0.c(true);
                dialogInterface.dismiss();
                return true;
            }
        }
        return subMenuC2155pb0.performShortcut(i, keyEvent, 0);
    }
}
