package X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9;

import android.content.Context;
import android.view.MenuItem;
import android.view.SubMenu;
import java.util.Iterator;
import java.util.Map;
/* compiled from: BaseMenuWrapper.java */
/* loaded from: classes.dex */
public abstract class PGPF6hQ_2<T> extends Mqv2r_3<T> {
    public final Context KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public Map<X6FRs_4.IMuAHx_6.IMuAHx_6.KQgRr5e_0.QxJ9d_1, MenuItem> f909KQgRr5e_0;
    public Map<X6FRs_4.IMuAHx_6.IMuAHx_6.KQgRr5e_0.PGPF6hQ_2, SubMenu> QxJ9d_1;

    public PGPF6hQ_2(Context context, T t) {
        super(t);
        this.KQgRr5e_0 = context;
    }

    public final MenuItem KQgRr5e_0(MenuItem menuItem) {
        if (menuItem instanceof X6FRs_4.IMuAHx_6.IMuAHx_6.KQgRr5e_0.QxJ9d_1) {
            X6FRs_4.IMuAHx_6.IMuAHx_6.KQgRr5e_0.QxJ9d_1 qxJ9d_1 = (X6FRs_4.IMuAHx_6.IMuAHx_6.KQgRr5e_0.QxJ9d_1) menuItem;
            if (this.f909KQgRr5e_0 == null) {
                this.f909KQgRr5e_0 = new X6FRs_4.Mqv2r_3.KQgRr5e_0();
            }
            MenuItem menuItem2 = this.f909KQgRr5e_0.get(menuItem);
            if (menuItem2 == null) {
                MenuItem KQgRr5e_0 = JZJr_16.KQgRr5e_0(this.KQgRr5e_0, qxJ9d_1);
                this.f909KQgRr5e_0.put(qxJ9d_1, KQgRr5e_0);
                return KQgRr5e_0;
            }
            return menuItem2;
        }
        return menuItem;
    }

    public final void QxJ9d_1(int i) {
        Map<X6FRs_4.IMuAHx_6.IMuAHx_6.KQgRr5e_0.QxJ9d_1, MenuItem> map = this.f909KQgRr5e_0;
        if (map == null) {
            return;
        }
        Iterator<X6FRs_4.IMuAHx_6.IMuAHx_6.KQgRr5e_0.QxJ9d_1> it = map.keySet().iterator();
        while (it.hasNext()) {
            if (i == it.next().getItemId()) {
                it.remove();
                return;
            }
        }
    }

    public final SubMenu KQgRr5e_0(SubMenu subMenu) {
        if (subMenu instanceof X6FRs_4.IMuAHx_6.IMuAHx_6.KQgRr5e_0.PGPF6hQ_2) {
            X6FRs_4.IMuAHx_6.IMuAHx_6.KQgRr5e_0.PGPF6hQ_2 pGPF6hQ_2 = (X6FRs_4.IMuAHx_6.IMuAHx_6.KQgRr5e_0.PGPF6hQ_2) subMenu;
            if (this.QxJ9d_1 == null) {
                this.QxJ9d_1 = new X6FRs_4.Mqv2r_3.KQgRr5e_0();
            }
            SubMenu subMenu2 = this.QxJ9d_1.get(pGPF6hQ_2);
            if (subMenu2 == null) {
                SubMenu KQgRr5e_0 = JZJr_16.KQgRr5e_0(this.KQgRr5e_0, pGPF6hQ_2);
                this.QxJ9d_1.put(pGPF6hQ_2, KQgRr5e_0);
                return KQgRr5e_0;
            }
            return subMenu2;
        }
        return subMenu;
    }

    public final void KQgRr5e_0() {
        Map<X6FRs_4.IMuAHx_6.IMuAHx_6.KQgRr5e_0.QxJ9d_1, MenuItem> map = this.f909KQgRr5e_0;
        if (map != null) {
            map.clear();
        }
        Map<X6FRs_4.IMuAHx_6.IMuAHx_6.KQgRr5e_0.PGPF6hQ_2, SubMenu> map2 = this.QxJ9d_1;
        if (map2 != null) {
            map2.clear();
        }
    }

    public final void KQgRr5e_0(int i) {
        Map<X6FRs_4.IMuAHx_6.IMuAHx_6.KQgRr5e_0.QxJ9d_1, MenuItem> map = this.f909KQgRr5e_0;
        if (map == null) {
            return;
        }
        Iterator<X6FRs_4.IMuAHx_6.IMuAHx_6.KQgRr5e_0.QxJ9d_1> it = map.keySet().iterator();
        while (it.hasNext()) {
            if (i == it.next().getGroupId()) {
                it.remove();
            }
        }
    }
}
