package c.b.f;

import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.ColorStateList;
import android.content.res.XmlResourceParser;
import android.graphics.PorterDuff;
import android.util.Log;
import android.util.Xml;
import android.view.InflateException;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import c.b.f.d.g;
import c.b.f.d.h;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import org.xmlpull.v1.XmlPullParserException;

/* JADX INFO: loaded from: classes.dex */
public class b extends MenuInflater {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final Class<?>[] f4768a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final Class<?>[] f4769b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Object[] f4770c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Object[] f4771d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public Context f4772e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public Object f4773f;

    public static class a implements MenuItem.OnMenuItemClickListener {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public static final Class<?>[] f4774a = {MenuItem.class};

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public Object f4775b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public Method f4776c;

        public a(Object obj, String str) {
            this.f4775b = obj;
            Class<?> cls = obj.getClass();
            try {
                this.f4776c = cls.getMethod(str, f4774a);
            } catch (Exception e2) {
                InflateException inflateException = new InflateException("Couldn't resolve menu item onClick handler " + str + " in class " + cls.getName());
                inflateException.initCause(e2);
                throw inflateException;
            }
        }

        @Override // android.view.MenuItem.OnMenuItemClickListener
        public boolean onMenuItemClick(MenuItem menuItem) {
            try {
                if (this.f4776c.getReturnType() == Boolean.TYPE) {
                    return ((Boolean) this.f4776c.invoke(this.f4775b, menuItem)).booleanValue();
                }
                this.f4776c.invoke(this.f4775b, menuItem);
                return true;
            } catch (Exception e2) {
                throw new RuntimeException(e2);
            }
        }
    }

    /* JADX INFO: renamed from: c.b.f.b$b, reason: collision with other inner class name */
    public class C0059b {
        public c.e.i.b A;
        public CharSequence B;
        public CharSequence C;

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

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

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

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        public int f4786j;
        public CharSequence k;
        public CharSequence l;
        public int m;
        public char n;
        public int o;
        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 String z;
        public ColorStateList D = null;
        public PorterDuff.Mode E = null;

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

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

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

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

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

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

        public C0059b(Menu menu) {
            this.f4777a = menu;
        }

        public SubMenu a() {
            this.f4784h = true;
            SubMenu subMenuAddSubMenu = this.f4777a.addSubMenu(this.f4778b, this.f4785i, this.f4786j, this.k);
            c(subMenuAddSubMenu.getItem());
            return subMenuAddSubMenu;
        }

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

        public final void c(MenuItem menuItem) {
            boolean z = false;
            menuItem.setChecked(this.s).setVisible(this.t).setEnabled(this.u).setCheckable(this.r >= 1).setTitleCondensed(this.l).setIcon(this.m);
            int i2 = this.v;
            if (i2 >= 0) {
                menuItem.setShowAsAction(i2);
            }
            if (this.z != null) {
                if (b.this.f4772e.isRestricted()) {
                    throw new IllegalStateException("The android:onClick attribute cannot be used within a restricted context");
                }
                b bVar = b.this;
                if (bVar.f4773f == null) {
                    bVar.f4773f = bVar.a(bVar.f4772e);
                }
                menuItem.setOnMenuItemClickListener(new a(bVar.f4773f, this.z));
            }
            if (this.r >= 2) {
                if (menuItem instanceof g) {
                    g gVar = (g) menuItem;
                    gVar.x = (gVar.x & (-5)) | 4;
                } else if (menuItem instanceof h) {
                    h hVar = (h) menuItem;
                    try {
                        if (hVar.f4863e == null) {
                            hVar.f4863e = hVar.f4862d.getClass().getDeclaredMethod("setExclusiveCheckable", Boolean.TYPE);
                        }
                        hVar.f4863e.invoke(hVar.f4862d, Boolean.TRUE);
                    } catch (Exception e2) {
                        Log.w("MenuItemWrapper", "Error while calling setExclusiveCheckable", e2);
                    }
                }
            }
            String str = this.x;
            if (str != null) {
                menuItem.setActionView((View) b(str, b.f4768a, b.this.f4770c));
                z = true;
            }
            int i3 = this.w;
            if (i3 > 0) {
                if (z) {
                    Log.w("SupportMenuInflater", "Ignoring attribute 'itemActionViewLayout'. Action view already specified.");
                } else {
                    menuItem.setActionView(i3);
                }
            }
            c.e.i.b bVar2 = this.A;
            if (bVar2 != null) {
                if (menuItem instanceof c.e.e.a.b) {
                    ((c.e.e.a.b) menuItem).a(bVar2);
                } else {
                    Log.w("MenuItemCompat", "setActionProvider: item does not implement SupportMenuItem; ignoring");
                }
            }
            CharSequence charSequence = this.B;
            boolean z2 = menuItem instanceof c.e.e.a.b;
            if (z2) {
                ((c.e.e.a.b) menuItem).setContentDescription(charSequence);
            } else {
                menuItem.setContentDescription(charSequence);
            }
            CharSequence charSequence2 = this.C;
            if (z2) {
                ((c.e.e.a.b) menuItem).setTooltipText(charSequence2);
            } else {
                menuItem.setTooltipText(charSequence2);
            }
            char c2 = this.n;
            int i4 = this.o;
            if (z2) {
                ((c.e.e.a.b) menuItem).setAlphabeticShortcut(c2, i4);
            } else {
                menuItem.setAlphabeticShortcut(c2, i4);
            }
            char c3 = this.p;
            int i5 = this.q;
            if (z2) {
                ((c.e.e.a.b) menuItem).setNumericShortcut(c3, i5);
            } else {
                menuItem.setNumericShortcut(c3, i5);
            }
            PorterDuff.Mode mode = this.E;
            if (mode != null) {
                if (z2) {
                    ((c.e.e.a.b) menuItem).setIconTintMode(mode);
                } else {
                    menuItem.setIconTintMode(mode);
                }
            }
            ColorStateList colorStateList = this.D;
            if (colorStateList != null) {
                if (z2) {
                    ((c.e.e.a.b) menuItem).setIconTintList(colorStateList);
                } else {
                    menuItem.setIconTintList(colorStateList);
                }
            }
        }
    }

    static {
        Class<?>[] clsArr = {Context.class};
        f4768a = clsArr;
        f4769b = clsArr;
    }

    public b(Context context) {
        super(context);
        this.f4772e = context;
        Object[] objArr = {context};
        this.f4770c = objArr;
        this.f4771d = objArr;
    }

    public final Object a(Object obj) {
        return (!(obj instanceof Activity) && (obj instanceof ContextWrapper)) ? a(((ContextWrapper) obj).getBaseContext()) : obj;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:45:0x00e4 A[PHI: r9
      0x00e4: PHI (r9v2 boolean) = 
      (r9v1 boolean)
      (r9v1 boolean)
      (r9v1 boolean)
      (r9v1 boolean)
      (r9v1 boolean)
      (r9v4 boolean)
      (r9v1 boolean)
      (r9v1 boolean)
      (r9v1 boolean)
      (r9v1 boolean)
     binds: [B:40:0x00a4, B:80:0x0209, B:44:0x00b3, B:17:0x0045, B:38:0x00a0, B:39:0x00a2, B:30:0x0078, B:36:0x0088, B:35:0x0084, B:26:0x0062] A[DONT_GENERATE, DONT_INLINE]] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void b(org.xmlpull.v1.XmlPullParser r17, android.util.AttributeSet r18, android.view.Menu r19) throws org.xmlpull.v1.XmlPullParserException, java.io.IOException {
        /*
            Method dump skipped, instruction units count: 571
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: c.b.f.b.b(org.xmlpull.v1.XmlPullParser, android.util.AttributeSet, android.view.Menu):void");
    }

    @Override // android.view.MenuInflater
    public void inflate(int i2, Menu menu) {
        if (!(menu instanceof c.e.e.a.a)) {
            super.inflate(i2, menu);
            return;
        }
        XmlResourceParser layout = null;
        try {
            try {
                try {
                    layout = this.f4772e.getResources().getLayout(i2);
                    b(layout, Xml.asAttributeSet(layout), menu);
                    layout.close();
                } catch (XmlPullParserException e2) {
                    throw new InflateException("Error inflating menu XML", e2);
                }
            } catch (IOException e3) {
                throw new InflateException("Error inflating menu XML", e3);
            }
        } catch (Throwable th) {
            if (layout != null) {
                layout.close();
            }
            throw th;
        }
    }
}
