package androidx.appcompat.view.menu; import android.content.DialogInterface; import android.os.IBinder; import android.view.KeyEvent; import android.view.View; import android.view.Window; import android.view.WindowManager; import androidx.appcompat.app.b; import androidx.appcompat.view.menu.j; /* loaded from: classes.dex */ class f implements DialogInterface.OnKeyListener, DialogInterface.OnClickListener, DialogInterface.OnDismissListener, j.a { /* renamed from: a, reason: collision with root package name */ private e f632a; /* renamed from: b, reason: collision with root package name */ private androidx.appcompat.app.b f633b; /* renamed from: c, reason: collision with root package name */ c f634c; /* renamed from: d, reason: collision with root package name */ private j.a f635d; public f(e eVar) { this.f632a = eVar; } public void a() { androidx.appcompat.app.b bVar = this.f633b; if (bVar != null) { bVar.dismiss(); } } @Override // androidx.appcompat.view.menu.j.a public void b(e eVar, boolean z10) { if (z10 || eVar == this.f632a) { a(); } j.a aVar = this.f635d; if (aVar != null) { aVar.b(eVar, z10); } } @Override // androidx.appcompat.view.menu.j.a public boolean c(e eVar) { j.a aVar = this.f635d; if (aVar != null) { return aVar.c(eVar); } return false; } public void d(IBinder iBinder) { e eVar = this.f632a; b.a aVar = new b.a(eVar.u()); c cVar = new c(aVar.b(), d.g.f8788j); this.f634c = cVar; cVar.g(this); this.f632a.b(this.f634c); aVar.c(this.f634c.a(), this); View y10 = eVar.y(); if (y10 != null) { aVar.e(y10); } else { aVar.f(eVar.w()).k(eVar.x()); } aVar.h(this); androidx.appcompat.app.b a10 = aVar.a(); this.f633b = a10; a10.setOnDismissListener(this); WindowManager.LayoutParams attributes = this.f633b.getWindow().getAttributes(); attributes.type = 1003; if (iBinder != null) { attributes.token = iBinder; } attributes.flags |= 131072; this.f633b.show(); } @Override // android.content.DialogInterface.OnClickListener public void onClick(DialogInterface dialogInterface, int i10) { this.f632a.L((g) this.f634c.a().getItem(i10), 0); } @Override // android.content.DialogInterface.OnDismissListener public void onDismiss(DialogInterface dialogInterface) { this.f634c.b(this.f632a, true); } @Override // android.content.DialogInterface.OnKeyListener public boolean onKey(DialogInterface dialogInterface, int i10, KeyEvent keyEvent) { Window window; View decorView; KeyEvent.DispatcherState keyDispatcherState; View decorView2; KeyEvent.DispatcherState keyDispatcherState2; if (i10 == 82 || i10 == 4) { if (keyEvent.getAction() == 0 && keyEvent.getRepeatCount() == 0) { Window window2 = this.f633b.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.f633b.getWindow()) != null && (decorView = window.getDecorView()) != null && (keyDispatcherState = decorView.getKeyDispatcherState()) != null && keyDispatcherState.isTracking(keyEvent)) { this.f632a.e(true); dialogInterface.dismiss(); return true; } } return this.f632a.performShortcut(i10, keyEvent, 0); } }