95 lines
2.6 KiB
Java
95 lines
2.6 KiB
Java
package androidx.appcompat.view.menu;
|
|
|
|
import android.content.Context;
|
|
import android.view.MenuItem;
|
|
import android.view.SubMenu;
|
|
import androidx.collection.ArrayMap;
|
|
import androidx.core.internal.view.SupportMenuItem;
|
|
import androidx.core.internal.view.SupportSubMenu;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
abstract class BaseMenuWrapper<T> extends BaseWrapper<T> {
|
|
final Context b;
|
|
private Map<SupportMenuItem, MenuItem> c;
|
|
private Map<SupportSubMenu, SubMenu> d;
|
|
|
|
BaseMenuWrapper(Context context, T t) {
|
|
super(t);
|
|
this.b = context;
|
|
}
|
|
|
|
final MenuItem a(MenuItem menuItem) {
|
|
if (!(menuItem instanceof SupportMenuItem)) {
|
|
return menuItem;
|
|
}
|
|
SupportMenuItem supportMenuItem = (SupportMenuItem) menuItem;
|
|
if (this.c == null) {
|
|
this.c = new ArrayMap();
|
|
}
|
|
MenuItem menuItem2 = this.c.get(menuItem);
|
|
if (menuItem2 != null) {
|
|
return menuItem2;
|
|
}
|
|
MenuItem a = MenuWrapperFactory.a(this.b, supportMenuItem);
|
|
this.c.put(supportMenuItem, a);
|
|
return a;
|
|
}
|
|
|
|
final void b() {
|
|
Map<SupportMenuItem, MenuItem> map = this.c;
|
|
if (map != null) {
|
|
map.clear();
|
|
}
|
|
Map<SupportSubMenu, SubMenu> map2 = this.d;
|
|
if (map2 != null) {
|
|
map2.clear();
|
|
}
|
|
}
|
|
|
|
final void b(int i) {
|
|
Map<SupportMenuItem, MenuItem> map = this.c;
|
|
if (map == null) {
|
|
return;
|
|
}
|
|
Iterator<SupportMenuItem> it = map.keySet().iterator();
|
|
while (it.hasNext()) {
|
|
if (i == it.next().getItemId()) {
|
|
it.remove();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
final SubMenu a(SubMenu subMenu) {
|
|
if (!(subMenu instanceof SupportSubMenu)) {
|
|
return subMenu;
|
|
}
|
|
SupportSubMenu supportSubMenu = (SupportSubMenu) subMenu;
|
|
if (this.d == null) {
|
|
this.d = new ArrayMap();
|
|
}
|
|
SubMenu subMenu2 = this.d.get(supportSubMenu);
|
|
if (subMenu2 != null) {
|
|
return subMenu2;
|
|
}
|
|
SubMenu a = MenuWrapperFactory.a(this.b, supportSubMenu);
|
|
this.d.put(supportSubMenu, a);
|
|
return a;
|
|
}
|
|
|
|
final void a(int i) {
|
|
Map<SupportMenuItem, MenuItem> map = this.c;
|
|
if (map == null) {
|
|
return;
|
|
}
|
|
Iterator<SupportMenuItem> it = map.keySet().iterator();
|
|
while (it.hasNext()) {
|
|
if (i == it.next().getGroupId()) {
|
|
it.remove();
|
|
}
|
|
}
|
|
}
|
|
}
|