package j;

import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.os.Build;
import android.view.InflateException;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import androidx.core.app.a0;
import androidx.core.view.b0;
import com.google.android.gms.measurement.internal.u1;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import k.r;
import k.w;

/* JADX INFO: loaded from: classes.dex */
public final class j {
    public CharSequence A;
    public CharSequence B;
    public final /* synthetic */ k E;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public androidx.core.view.e f28482z;
    public ColorStateList C = null;
    public PorterDuff.Mode D = null;

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

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

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

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

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

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

    public j(k kVar, Menu menu) {
        this.E = kVar;
        this.f28457a = menu;
    }

    public final Object a(String str, Class[] clsArr, Object[] objArr) {
        try {
            Constructor<?> constructor = Class.forName(str, false, this.E.f28487c.getClassLoader()).getConstructor(clsArr);
            constructor.setAccessible(true);
            return constructor.newInstance(objArr);
        } catch (Exception unused) {
            return null;
        }
    }

    public final void b(MenuItem menuItem) {
        boolean z10 = false;
        menuItem.setChecked(this.f28475s).setVisible(this.f28476t).setEnabled(this.f28477u).setCheckable(this.f28474r >= 1).setTitleCondensed(this.f28468l).setIcon(this.f28469m);
        int i10 = this.f28478v;
        if (i10 >= 0) {
            menuItem.setShowAsAction(i10);
        }
        String str = this.f28481y;
        k kVar = this.E;
        if (str != null) {
            if (kVar.f28487c.isRestricted()) {
                throw new IllegalStateException("The android:onClick attribute cannot be used within a restricted context");
            }
            if (kVar.f28488d == null) {
                kVar.f28488d = k.a(kVar.f28487c);
            }
            Object obj = kVar.f28488d;
            String str2 = this.f28481y;
            i iVar = new i();
            iVar.f28455a = obj;
            Class<?> cls = obj.getClass();
            try {
                iVar.f28456b = cls.getMethod(str2, i.f28454c);
                menuItem.setOnMenuItemClickListener(iVar);
            } catch (Exception e10) {
                StringBuilder sbN = u1.n("Couldn't resolve menu item onClick handler ", str2, " in class ");
                sbN.append(cls.getName());
                InflateException inflateException = new InflateException(sbN.toString());
                inflateException.initCause(e10);
                throw inflateException;
            }
        }
        if (this.f28474r >= 2) {
            if (menuItem instanceof r) {
                ((r) menuItem).e(true);
            } else if (menuItem instanceof w) {
                w wVar = (w) menuItem;
                try {
                    Method method = wVar.f28943e;
                    l0.b bVar = wVar.f28942d;
                    if (method == null) {
                        wVar.f28943e = bVar.getClass().getDeclaredMethod("setExclusiveCheckable", Boolean.TYPE);
                    }
                    wVar.f28943e.invoke(bVar, Boolean.TRUE);
                } catch (Exception unused) {
                }
            }
        }
        String str3 = this.f28480x;
        if (str3 != null) {
            menuItem.setActionView((View) a(str3, k.f28483e, kVar.f28485a));
            z10 = true;
        }
        int i11 = this.f28479w;
        if (i11 > 0 && !z10) {
            menuItem.setActionView(i11);
        }
        androidx.core.view.e eVar = this.f28482z;
        if (eVar != null) {
            b0.setActionProvider(menuItem, eVar);
        }
        b0.setContentDescription(menuItem, this.A);
        b0.setTooltipText(menuItem, this.B);
        char c6 = this.f28470n;
        int i12 = this.f28471o;
        boolean z11 = menuItem instanceof l0.b;
        if (z11) {
            ((l0.b) menuItem).setAlphabeticShortcut(c6, i12);
        } else if (Build.VERSION.SDK_INT >= 26) {
            a0.H(menuItem, c6, i12);
        }
        char c10 = this.f28472p;
        int i13 = this.f28473q;
        if (z11) {
            ((l0.b) menuItem).setNumericShortcut(c10, i13);
        } else if (Build.VERSION.SDK_INT >= 26) {
            a0.O(menuItem, c10, i13);
        }
        PorterDuff.Mode mode = this.D;
        if (mode != null) {
            b0.setIconTintMode(menuItem, mode);
        }
        ColorStateList colorStateList = this.C;
        if (colorStateList != null) {
            b0.setIconTintList(menuItem, colorStateList);
        }
    }
}
