package o;

import android.content.Context;
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 java.lang.reflect.Constructor;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Cb0 {
    public CharSequence A;
    public CharSequence B;
    public final /* synthetic */ Db0 E;
    public final Menu a;
    public boolean h;
    public int i;
    public int j;
    public CharSequence k;
    public CharSequence l;
    public int m;
    public char n;

    /* renamed from: o, reason: collision with root package name */
    public int f69o;
    public char p;
    public int q;
    public int r;
    public boolean s;
    public boolean t;
    public boolean u;
    public int v;
    public int w;
    public String x;
    public String y;
    public MO z;
    public ColorStateList C = null;
    public PorterDuff.Mode D = null;
    public int b = 0;
    public int c = 0;
    public int d = 0;
    public int e = 0;
    public boolean f = true;
    public boolean g = true;

    public Cb0(Db0 db0, Menu menu) {
        this.E = db0;
        this.a = menu;
    }

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

    public final void b(MenuItem menuItem) {
        Db0 db0 = this.E;
        Context context = db0.c;
        boolean z = false;
        menuItem.setChecked(this.s).setVisible(this.t).setEnabled(this.u).setCheckable(this.r >= 1).setTitleCondensed(this.l).setIcon(this.m);
        int i = this.v;
        if (i >= 0) {
            menuItem.setShowAsAction(i);
        }
        if (this.y != null) {
            if (context.isRestricted()) {
                throw new IllegalStateException("The android:onClick attribute cannot be used within a restricted context");
            }
            if (db0.d == null) {
                db0.d = Db0.a(context);
            }
            Object obj = db0.d;
            String str = this.y;
            Bb0 bb0 = new Bb0();
            bb0.b = obj;
            Class<?> cls = obj.getClass();
            try {
                bb0.c = cls.getMethod(str, Bb0.d);
                menuItem.setOnMenuItemClickListener(bb0);
            } catch (Exception e) {
                InflateException inflateException = new InflateException("Couldn't resolve menu item onClick handler " + str + " in class " + cls.getName());
                inflateException.initCause(e);
                throw inflateException;
            }
        }
        if (this.r >= 2) {
            if (menuItem instanceof LO) {
                LO lo = (LO) menuItem;
                lo.x = (lo.x & (-5)) | 4;
            } else if (menuItem instanceof PO) {
                PO po = (PO) menuItem;
                Eb0 eb0 = po.c;
                try {
                    if (po.d == null) {
                        po.d = eb0.getClass().getDeclaredMethod("setExclusiveCheckable", Boolean.TYPE);
                    }
                    po.d.invoke(eb0, Boolean.TRUE);
                } catch (Exception unused) {
                }
            }
        }
        String str2 = this.x;
        if (str2 != null) {
            menuItem.setActionView((View) a(str2, Db0.e, db0.a));
            z = true;
        }
        int i2 = this.w;
        if (i2 > 0 && !z) {
            menuItem.setActionView(i2);
        }
        MO mo = this.z;
        if (mo != null && (menuItem instanceof Eb0)) {
            ((Eb0) menuItem).b(mo);
        }
        CharSequence charSequence = this.A;
        boolean z2 = menuItem instanceof Eb0;
        if (z2) {
            ((Eb0) menuItem).setContentDescription(charSequence);
        } else if (Build.VERSION.SDK_INT >= 26) {
            AbstractC1456i7.n(menuItem, charSequence);
        }
        CharSequence charSequence2 = this.B;
        if (z2) {
            ((Eb0) menuItem).setTooltipText(charSequence2);
        } else if (Build.VERSION.SDK_INT >= 26) {
            AbstractC1456i7.v(menuItem, charSequence2);
        }
        char c = this.n;
        int i3 = this.f69o;
        if (z2) {
            ((Eb0) menuItem).setAlphabeticShortcut(c, i3);
        } else if (Build.VERSION.SDK_INT >= 26) {
            AbstractC1456i7.l(menuItem, c, i3);
        }
        char c2 = this.p;
        int i4 = this.q;
        if (z2) {
            ((Eb0) menuItem).setNumericShortcut(c2, i4);
        } else if (Build.VERSION.SDK_INT >= 26) {
            AbstractC1456i7.r(menuItem, c2, i4);
        }
        PorterDuff.Mode mode = this.D;
        if (mode != null) {
            if (z2) {
                ((Eb0) menuItem).setIconTintMode(mode);
            } else if (Build.VERSION.SDK_INT >= 26) {
                AbstractC1456i7.q(menuItem, mode);
            }
        }
        ColorStateList colorStateList = this.C;
        if (colorStateList != null) {
            if (z2) {
                ((Eb0) menuItem).setIconTintList(colorStateList);
            } else if (Build.VERSION.SDK_INT >= 26) {
                AbstractC1456i7.p(menuItem, colorStateList);
            }
        }
    }
}
