Rabbit-R1/original r1/java/sources/androidx/appcompat/view/menu/ExpandedMenuView.java

61 lines
2.3 KiB
Java
Raw Normal View History

2024-05-21 21:08:36 +00:00
package androidx.appcompat.view.menu;
import android.R;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import androidx.appcompat.view.menu.MenuBuilder;
import androidx.appcompat.widget.TintTypedArray;
/* loaded from: classes.dex */
public final class ExpandedMenuView extends ListView implements MenuBuilder.ItemInvoker, MenuView, AdapterView.OnItemClickListener {
private static final int[] TINT_ATTRS = {R.attr.background, R.attr.divider};
private int mAnimations;
private MenuBuilder mMenu;
@Override // androidx.appcompat.view.menu.MenuView
public int getWindowAnimations() {
return this.mAnimations;
}
@Override // androidx.appcompat.view.menu.MenuView
public void initialize(MenuBuilder menuBuilder) {
this.mMenu = menuBuilder;
}
public ExpandedMenuView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, R.attr.listViewStyle);
}
public ExpandedMenuView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet);
setOnItemClickListener(this);
TintTypedArray obtainStyledAttributes = TintTypedArray.obtainStyledAttributes(context, attributeSet, TINT_ATTRS, i, 0);
if (obtainStyledAttributes.hasValue(0)) {
setBackgroundDrawable(obtainStyledAttributes.getDrawable(0));
}
if (obtainStyledAttributes.hasValue(1)) {
setDivider(obtainStyledAttributes.getDrawable(1));
}
obtainStyledAttributes.recycle();
}
@Override // android.widget.ListView, android.widget.AbsListView, android.widget.AdapterView, android.view.ViewGroup, android.view.View
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
setChildrenDrawingCacheEnabled(false);
}
@Override // androidx.appcompat.view.menu.MenuBuilder.ItemInvoker
public boolean invokeItem(MenuItemImpl menuItemImpl) {
return this.mMenu.performItemAction(menuItemImpl, 0);
}
@Override // android.widget.AdapterView.OnItemClickListener
public void onItemClick(AdapterView adapterView, View view, int i, long j) {
invokeItem((MenuItemImpl) getAdapter().getItem(i));
}
}