package k;

import D.L;
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 java.lang.reflect.Constructor;
import l.i;
import p0.AbstractC0928a;

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public int f8586o;
    public char p;
    public int q;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public d(e eVar, Menu menu) {
        this.f8572D = eVar;
        this.f8573a = menu;
    }

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

    public final void b(MenuItem menuItem) {
        boolean z5 = false;
        menuItem.setChecked(this.f8588s).setVisible(this.f8589t).setEnabled(this.f8590u).setCheckable(this.f8587r >= 1).setTitleCondensed(this.f8583l).setIcon(this.f8584m);
        int i = this.f8591v;
        if (i >= 0) {
            menuItem.setShowAsAction(i);
        }
        String str = this.f8594y;
        e eVar = this.f8572D;
        if (str != null) {
            if (eVar.f8600c.isRestricted()) {
                throw new IllegalStateException("The android:onClick attribute cannot be used within a restricted context");
            }
            if (eVar.f8601d == null) {
                eVar.f8601d = e.a(eVar.f8600c);
            }
            Object obj = eVar.f8601d;
            String str2 = this.f8594y;
            c cVar = new c();
            cVar.f8567a = obj;
            Class<?> cls = obj.getClass();
            try {
                cVar.f8568b = cls.getMethod(str2, c.f8566c);
                menuItem.setOnMenuItemClickListener(cVar);
            } catch (Exception e2) {
                StringBuilder sbN = AbstractC0928a.n("Couldn't resolve menu item onClick handler ", str2, " in class ");
                sbN.append(cls.getName());
                InflateException inflateException = new InflateException(sbN.toString());
                inflateException.initCause(e2);
                throw inflateException;
            }
        }
        if (this.f8587r >= 2 && (menuItem instanceof i)) {
            i iVar = (i) menuItem;
            iVar.f8748x = (iVar.f8748x & (-5)) | 4;
        }
        String str3 = this.f8593x;
        if (str3 != null) {
            menuItem.setActionView((View) a(str3, e.f8596e, eVar.f8598a));
            z5 = true;
        }
        int i5 = this.f8592w;
        if (i5 > 0) {
            if (z5) {
                Log.w("SupportMenuInflater", "Ignoring attribute 'itemActionViewLayout'. Action view already specified.");
            } else {
                menuItem.setActionView(i5);
            }
        }
        CharSequence charSequence = this.f8595z;
        boolean z6 = menuItem instanceof i;
        if (z6) {
            ((i) menuItem).c(charSequence);
        } else if (Build.VERSION.SDK_INT >= 26) {
            L.q(menuItem, charSequence);
        }
        CharSequence charSequence2 = this.f8569A;
        if (z6) {
            ((i) menuItem).e(charSequence2);
        } else if (Build.VERSION.SDK_INT >= 26) {
            L.y(menuItem, charSequence2);
        }
        char c6 = this.f8585n;
        int i6 = this.f8586o;
        if (z6) {
            ((i) menuItem).setAlphabeticShortcut(c6, i6);
        } else if (Build.VERSION.SDK_INT >= 26) {
            L.n(menuItem, c6, i6);
        }
        char c7 = this.p;
        int i7 = this.q;
        if (z6) {
            ((i) menuItem).setNumericShortcut(c7, i7);
        } else if (Build.VERSION.SDK_INT >= 26) {
            L.u(menuItem, c7, i7);
        }
        PorterDuff.Mode mode = this.f8571C;
        if (mode != null) {
            if (z6) {
                ((i) menuItem).setIconTintMode(mode);
            } else if (Build.VERSION.SDK_INT >= 26) {
                L.t(menuItem, mode);
            }
        }
        ColorStateList colorStateList = this.f8570B;
        if (colorStateList != null) {
            if (z6) {
                ((i) menuItem).setIconTintList(colorStateList);
            } else if (Build.VERSION.SDK_INT >= 26) {
                L.s(menuItem, colorStateList);
            }
        }
    }
}
