package l;

import B.h;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.os.Build;
import android.util.Log;
import android.view.InflateException;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import d5.AbstractC0844a;
import java.lang.reflect.Constructor;
import m.MenuItemC1148i;

/* JADX INFO: loaded from: classes.dex */
public final class d {

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public CharSequence f14218A;
    public final /* synthetic */ e D;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Menu f14221a;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public boolean f14228h;
    public int i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f14229j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public CharSequence f14230k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public CharSequence f14231l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f14232m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public char f14233n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public int f14234o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public char f14235p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public int f14236q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public int f14237r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public boolean f14238s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public boolean f14239t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public boolean f14240u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public int f14241v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public int f14242w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public String f14243x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public String f14244y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public CharSequence f14245z;

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public ColorStateList f14219B = null;

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public PorterDuff.Mode f14220C = null;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f14222b = 0;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f14223c = 0;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f14224d = 0;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int f14225e = 0;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public boolean f14226f = true;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public boolean f14227g = true;

    public d(e eVar, Menu menu) {
        this.D = eVar;
        this.f14221a = menu;
    }

    public final Object a(String str, Class[] clsArr, Object[] objArr) {
        try {
            Constructor<?> constructor = Class.forName(str, false, this.D.f14250c.getClassLoader()).getConstructor(clsArr);
            constructor.setAccessible(true);
            return constructor.newInstance(objArr);
        } catch (Exception e8) {
            Log.w("SupportMenuInflater", "Cannot instantiate class: " + str, e8);
            return null;
        }
    }

    public final void b(MenuItem menuItem) {
        boolean z8 = false;
        menuItem.setChecked(this.f14238s).setVisible(this.f14239t).setEnabled(this.f14240u).setCheckable(this.f14237r >= 1).setTitleCondensed(this.f14231l).setIcon(this.f14232m);
        int i = this.f14241v;
        if (i >= 0) {
            menuItem.setShowAsAction(i);
        }
        String str = this.f14244y;
        e eVar = this.D;
        if (str != null) {
            if (eVar.f14250c.isRestricted()) {
                throw new IllegalStateException("The android:onClick attribute cannot be used within a restricted context");
            }
            if (eVar.f14251d == null) {
                eVar.f14251d = e.a(eVar.f14250c);
            }
            Object obj = eVar.f14251d;
            String str2 = this.f14244y;
            MenuItemOnMenuItemClickListenerC1118c menuItemOnMenuItemClickListenerC1118c = new MenuItemOnMenuItemClickListenerC1118c();
            menuItemOnMenuItemClickListenerC1118c.f14216a = obj;
            Class<?> cls = obj.getClass();
            try {
                menuItemOnMenuItemClickListenerC1118c.f14217b = cls.getMethod(str2, MenuItemOnMenuItemClickListenerC1118c.f14215c);
                menuItem.setOnMenuItemClickListener(menuItemOnMenuItemClickListenerC1118c);
            } catch (Exception e8) {
                StringBuilder sbP = AbstractC0844a.p("Couldn't resolve menu item onClick handler ", str2, " in class ");
                sbP.append(cls.getName());
                InflateException inflateException = new InflateException(sbP.toString());
                inflateException.initCause(e8);
                throw inflateException;
            }
        }
        if (this.f14237r >= 2 && (menuItem instanceof MenuItemC1148i)) {
            MenuItemC1148i menuItemC1148i = (MenuItemC1148i) menuItem;
            menuItemC1148i.f14509x = (menuItemC1148i.f14509x & (-5)) | 4;
        }
        String str3 = this.f14243x;
        if (str3 != null) {
            menuItem.setActionView((View) a(str3, e.f14246e, eVar.f14248a));
            z8 = true;
        }
        int i5 = this.f14242w;
        if (i5 > 0) {
            if (z8) {
                Log.w("SupportMenuInflater", "Ignoring attribute 'itemActionViewLayout'. Action view already specified.");
            } else {
                menuItem.setActionView(i5);
            }
        }
        CharSequence charSequence = this.f14245z;
        boolean z9 = menuItem instanceof MenuItemC1148i;
        if (z9) {
            ((MenuItemC1148i) menuItem).c(charSequence);
        } else if (Build.VERSION.SDK_INT >= 26) {
            h.i(menuItem, charSequence);
        }
        CharSequence charSequence2 = this.f14218A;
        if (z9) {
            ((MenuItemC1148i) menuItem).e(charSequence2);
        } else if (Build.VERSION.SDK_INT >= 26) {
            h.q(menuItem, charSequence2);
        }
        char c3 = this.f14233n;
        int i8 = this.f14234o;
        if (z9) {
            ((MenuItemC1148i) menuItem).setAlphabeticShortcut(c3, i8);
        } else if (Build.VERSION.SDK_INT >= 26) {
            h.g(menuItem, c3, i8);
        }
        char c8 = this.f14235p;
        int i9 = this.f14236q;
        if (z9) {
            ((MenuItemC1148i) menuItem).setNumericShortcut(c8, i9);
        } else if (Build.VERSION.SDK_INT >= 26) {
            h.m(menuItem, c8, i9);
        }
        PorterDuff.Mode mode = this.f14220C;
        if (mode != null) {
            if (z9) {
                ((MenuItemC1148i) menuItem).setIconTintMode(mode);
            } else if (Build.VERSION.SDK_INT >= 26) {
                h.l(menuItem, mode);
            }
        }
        ColorStateList colorStateList = this.f14219B;
        if (colorStateList != null) {
            if (z9) {
                ((MenuItemC1148i) menuItem).setIconTintList(colorStateList);
            } else if (Build.VERSION.SDK_INT >= 26) {
                h.k(menuItem, colorStateList);
            }
        }
    }
}
