156 lines
4.7 KiB
Java
156 lines
4.7 KiB
Java
package androidx.appcompat.view.menu;
|
|
|
|
import android.content.Context;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import androidx.appcompat.view.menu.MenuPresenter;
|
|
import androidx.appcompat.view.menu.MenuView;
|
|
import java.util.ArrayList;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class BaseMenuPresenter implements MenuPresenter {
|
|
protected Context a;
|
|
protected Context b;
|
|
protected MenuBuilder c;
|
|
protected LayoutInflater d;
|
|
private MenuPresenter.Callback e;
|
|
private int f;
|
|
private int g;
|
|
protected MenuView h;
|
|
|
|
public BaseMenuPresenter(Context context, int i, int i2) {
|
|
this.a = context;
|
|
this.d = LayoutInflater.from(context);
|
|
this.f = i;
|
|
this.g = i2;
|
|
}
|
|
|
|
public void a(int i) {
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public void a(Context context, MenuBuilder menuBuilder) {
|
|
this.b = context;
|
|
LayoutInflater.from(this.b);
|
|
this.c = menuBuilder;
|
|
}
|
|
|
|
public abstract void a(MenuItemImpl menuItemImpl, MenuView.ItemView itemView);
|
|
|
|
public abstract boolean a(int i, MenuItemImpl menuItemImpl);
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public boolean a(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
|
|
return false;
|
|
}
|
|
|
|
public MenuView b(ViewGroup viewGroup) {
|
|
if (this.h == null) {
|
|
this.h = (MenuView) this.d.inflate(this.f, viewGroup, false);
|
|
this.h.a(this.c);
|
|
a(true);
|
|
}
|
|
return this.h;
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public boolean b(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
|
|
return false;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public void a(boolean z) {
|
|
ViewGroup viewGroup = (ViewGroup) this.h;
|
|
if (viewGroup == null) {
|
|
return;
|
|
}
|
|
MenuBuilder menuBuilder = this.c;
|
|
int i = 0;
|
|
if (menuBuilder != null) {
|
|
menuBuilder.b();
|
|
ArrayList<MenuItemImpl> n = this.c.n();
|
|
int size = n.size();
|
|
int i2 = 0;
|
|
for (int i3 = 0; i3 < size; i3++) {
|
|
MenuItemImpl menuItemImpl = n.get(i3);
|
|
if (a(i2, menuItemImpl)) {
|
|
View childAt = viewGroup.getChildAt(i2);
|
|
MenuItemImpl itemData = childAt instanceof MenuView.ItemView ? ((MenuView.ItemView) childAt).getItemData() : null;
|
|
View a = a(menuItemImpl, childAt, viewGroup);
|
|
if (menuItemImpl != itemData) {
|
|
a.setPressed(false);
|
|
a.jumpDrawablesToCurrentState();
|
|
}
|
|
if (a != childAt) {
|
|
a(a, i2);
|
|
}
|
|
i2++;
|
|
}
|
|
}
|
|
i = i2;
|
|
}
|
|
while (i < viewGroup.getChildCount()) {
|
|
if (!a(viewGroup, i)) {
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void a(View view, int i) {
|
|
ViewGroup viewGroup = (ViewGroup) view.getParent();
|
|
if (viewGroup != null) {
|
|
viewGroup.removeView(view);
|
|
}
|
|
((ViewGroup) this.h).addView(view, i);
|
|
}
|
|
|
|
protected boolean a(ViewGroup viewGroup, int i) {
|
|
viewGroup.removeViewAt(i);
|
|
return true;
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public void a(MenuPresenter.Callback callback) {
|
|
this.e = callback;
|
|
}
|
|
|
|
public MenuPresenter.Callback a() {
|
|
return this.e;
|
|
}
|
|
|
|
public MenuView.ItemView a(ViewGroup viewGroup) {
|
|
return (MenuView.ItemView) this.d.inflate(this.g, viewGroup, false);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public View a(MenuItemImpl menuItemImpl, View view, ViewGroup viewGroup) {
|
|
MenuView.ItemView itemView;
|
|
if (view instanceof MenuView.ItemView) {
|
|
itemView = (MenuView.ItemView) view;
|
|
} else {
|
|
itemView = a(viewGroup);
|
|
}
|
|
a(menuItemImpl, itemView);
|
|
return (View) itemView;
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public void a(MenuBuilder menuBuilder, boolean z) {
|
|
MenuPresenter.Callback callback = this.e;
|
|
if (callback != null) {
|
|
callback.a(menuBuilder, z);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public boolean a(SubMenuBuilder subMenuBuilder) {
|
|
MenuPresenter.Callback callback = this.e;
|
|
if (callback != null) {
|
|
return callback.a(subMenuBuilder);
|
|
}
|
|
return false;
|
|
}
|
|
}
|