package androidx.appcompat.view.menu; import android.R; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RadioButton; import android.widget.TextView; import androidx.appcompat.view.menu.k; import androidx.appcompat.widget.i2; import androidx.core.view.n0; /* loaded from: classes.dex */ public class ListMenuItemView extends LinearLayout implements k.a, AbsListView.SelectionBoundsAdjuster { /* renamed from: a, reason: collision with root package name */ private g f527a; /* renamed from: b, reason: collision with root package name */ private ImageView f528b; /* renamed from: c, reason: collision with root package name */ private RadioButton f529c; /* renamed from: d, reason: collision with root package name */ private TextView f530d; /* renamed from: e, reason: collision with root package name */ private CheckBox f531e; /* renamed from: f, reason: collision with root package name */ private TextView f532f; /* renamed from: g, reason: collision with root package name */ private ImageView f533g; /* renamed from: h, reason: collision with root package name */ private ImageView f534h; /* renamed from: i, reason: collision with root package name */ private LinearLayout f535i; /* renamed from: j, reason: collision with root package name */ private Drawable f536j; /* renamed from: k, reason: collision with root package name */ private int f537k; /* renamed from: l, reason: collision with root package name */ private Context f538l; /* renamed from: m, reason: collision with root package name */ private boolean f539m; /* renamed from: n, reason: collision with root package name */ private Drawable f540n; /* renamed from: o, reason: collision with root package name */ private boolean f541o; /* renamed from: p, reason: collision with root package name */ private LayoutInflater f542p; /* renamed from: q, reason: collision with root package name */ private boolean f543q; public ListMenuItemView(Context context, AttributeSet attributeSet) { this(context, attributeSet, d.a.f8704z); } private void a(View view) { b(view, -1); } private void b(View view, int i10) { LinearLayout linearLayout = this.f535i; if (linearLayout != null) { linearLayout.addView(view, i10); } else { addView(view, i10); } } private void c() { CheckBox checkBox = (CheckBox) getInflater().inflate(d.g.f8786h, (ViewGroup) this, false); this.f531e = checkBox; a(checkBox); } private void f() { ImageView imageView = (ImageView) getInflater().inflate(d.g.f8787i, (ViewGroup) this, false); this.f528b = imageView; b(imageView, 0); } private void g() { RadioButton radioButton = (RadioButton) getInflater().inflate(d.g.f8789k, (ViewGroup) this, false); this.f529c = radioButton; a(radioButton); } private LayoutInflater getInflater() { if (this.f542p == null) { this.f542p = LayoutInflater.from(getContext()); } return this.f542p; } private void setSubMenuArrowVisible(boolean z10) { ImageView imageView = this.f533g; if (imageView != null) { imageView.setVisibility(z10 ? 0 : 8); } } @Override // android.widget.AbsListView.SelectionBoundsAdjuster public void adjustListItemSelectionBounds(Rect rect) { ImageView imageView = this.f534h; if (imageView == null || imageView.getVisibility() != 0) { return; } LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.f534h.getLayoutParams(); rect.top += this.f534h.getHeight() + layoutParams.topMargin + layoutParams.bottomMargin; } @Override // androidx.appcompat.view.menu.k.a public boolean d() { return false; } @Override // androidx.appcompat.view.menu.k.a public void e(g gVar, int i10) { this.f527a = gVar; setVisibility(gVar.isVisible() ? 0 : 8); setTitle(gVar.i(this)); setCheckable(gVar.isCheckable()); h(gVar.A(), gVar.g()); setIcon(gVar.getIcon()); setEnabled(gVar.isEnabled()); setSubMenuArrowVisible(gVar.hasSubMenu()); setContentDescription(gVar.getContentDescription()); } @Override // androidx.appcompat.view.menu.k.a public g getItemData() { return this.f527a; } public void h(boolean z10, char c10) { int i10 = (z10 && this.f527a.A()) ? 0 : 8; if (i10 == 0) { this.f532f.setText(this.f527a.h()); } if (this.f532f.getVisibility() != i10) { this.f532f.setVisibility(i10); } } @Override // android.view.View protected void onFinishInflate() { super.onFinishInflate(); n0.q0(this, this.f536j); TextView textView = (TextView) findViewById(d.f.M); this.f530d = textView; int i10 = this.f537k; if (i10 != -1) { textView.setTextAppearance(this.f538l, i10); } this.f532f = (TextView) findViewById(d.f.F); ImageView imageView = (ImageView) findViewById(d.f.I); this.f533g = imageView; if (imageView != null) { imageView.setImageDrawable(this.f540n); } this.f534h = (ImageView) findViewById(d.f.f8770r); this.f535i = (LinearLayout) findViewById(d.f.f8764l); } @Override // android.widget.LinearLayout, android.view.View protected void onMeasure(int i10, int i11) { if (this.f528b != null && this.f539m) { ViewGroup.LayoutParams layoutParams = getLayoutParams(); LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) this.f528b.getLayoutParams(); int i12 = layoutParams.height; if (i12 > 0 && layoutParams2.width <= 0) { layoutParams2.width = i12; } } super.onMeasure(i10, i11); } public void setCheckable(boolean z10) { CompoundButton compoundButton; View view; if (!z10 && this.f529c == null && this.f531e == null) { return; } if (this.f527a.m()) { if (this.f529c == null) { g(); } compoundButton = this.f529c; view = this.f531e; } else { if (this.f531e == null) { c(); } compoundButton = this.f531e; view = this.f529c; } if (z10) { compoundButton.setChecked(this.f527a.isChecked()); if (compoundButton.getVisibility() != 0) { compoundButton.setVisibility(0); } if (view == null || view.getVisibility() == 8) { return; } view.setVisibility(8); return; } CheckBox checkBox = this.f531e; if (checkBox != null) { checkBox.setVisibility(8); } RadioButton radioButton = this.f529c; if (radioButton != null) { radioButton.setVisibility(8); } } public void setChecked(boolean z10) { CompoundButton compoundButton; if (this.f527a.m()) { if (this.f529c == null) { g(); } compoundButton = this.f529c; } else { if (this.f531e == null) { c(); } compoundButton = this.f531e; } compoundButton.setChecked(z10); } public void setForceShowIcon(boolean z10) { this.f543q = z10; this.f539m = z10; } public void setGroupDividerEnabled(boolean z10) { ImageView imageView = this.f534h; if (imageView != null) { imageView.setVisibility((this.f541o || !z10) ? 8 : 0); } } public void setIcon(Drawable drawable) { boolean z10 = this.f527a.z() || this.f543q; if (z10 || this.f539m) { ImageView imageView = this.f528b; if (imageView == null && drawable == null && !this.f539m) { return; } if (imageView == null) { f(); } if (drawable == null && !this.f539m) { this.f528b.setVisibility(8); return; } ImageView imageView2 = this.f528b; if (!z10) { drawable = null; } imageView2.setImageDrawable(drawable); if (this.f528b.getVisibility() != 0) { this.f528b.setVisibility(0); } } } public void setTitle(CharSequence charSequence) { if (charSequence == null) { if (this.f530d.getVisibility() != 8) { this.f530d.setVisibility(8); } } else { this.f530d.setText(charSequence); if (this.f530d.getVisibility() != 0) { this.f530d.setVisibility(0); } } } public ListMenuItemView(Context context, AttributeSet attributeSet, int i10) { super(context, attributeSet); i2 v10 = i2.v(getContext(), attributeSet, d.j.W1, i10, 0); this.f536j = v10.g(d.j.Y1); this.f537k = v10.n(d.j.X1, -1); this.f539m = v10.a(d.j.Z1, false); this.f538l = context; this.f540n = v10.g(d.j.f8817a2); TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(null, new int[]{R.attr.divider}, d.a.f8701w, 0); this.f541o = obtainStyledAttributes.hasValue(0); v10.w(); obtainStyledAttributes.recycle(); } }