package androidx.appcompat.view.menu;

import android.content.Context;
import android.content.res.Resources;
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.ViewConfiguration;
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 ar.tvplayer.tv.R;
import defpackage.AbstractC0430;
import defpackage.C1578;
import defpackage.C5398;
import defpackage.InterfaceC5060;
import defpackage.MenuC3271;

/* JADX INFO: loaded from: classes3.dex */
public class ListMenuItemView extends LinearLayout implements InterfaceC5060, AbsListView.SelectionBoundsAdjuster {

    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    public final int f53;

    /* JADX INFO: renamed from: ˀᵭ, reason: contains not printable characters */
    public final boolean f54;

    /* JADX INFO: renamed from: ˁˌᵩ, reason: contains not printable characters */
    public final Drawable f55;

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public ImageView f56;

    /* JADX INFO: renamed from: ˉᵵᵜ, reason: contains not printable characters */
    public boolean f57;

    /* JADX INFO: renamed from: ˊᵡᵗʨ, reason: contains not printable characters */
    public boolean f58;

    /* JADX INFO: renamed from: ˊᵾʽʼ, reason: contains not printable characters */
    public LayoutInflater f59;

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public C1578 f60;

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public ImageView f61;

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public final Drawable f62;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public RadioButton f63;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public ImageView f64;

    /* JADX INFO: renamed from: ᵠˏˏ, reason: contains not printable characters */
    public final Context f65;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public TextView f66;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public CheckBox f67;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public TextView f68;

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public LinearLayout f69;

    public ListMenuItemView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, R.attr._3rv_res_0x7f0403f2);
    }

    public ListMenuItemView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet);
        C5398 c5398M11010 = C5398.m11010(getContext(), attributeSet, AbstractC0430.f2379, i);
        this.f62 = c5398M11010.m11017(5);
        TypedArray typedArray = (TypedArray) c5398M11010.f20483;
        this.f53 = typedArray.getResourceId(1, -1);
        this.f57 = typedArray.getBoolean(7, false);
        this.f65 = context;
        this.f55 = c5398M11010.m11017(8);
        TypedArray typedArrayObtainStyledAttributes = context.getTheme().obtainStyledAttributes(null, new int[]{android.R.attr.divider}, R.attr._4m8_res_0x7f04021c, 0);
        this.f54 = typedArrayObtainStyledAttributes.hasValue(0);
        c5398M11010.m11012();
        typedArrayObtainStyledAttributes.recycle();
    }

    private LayoutInflater getInflater() {
        if (this.f59 == null) {
            this.f59 = LayoutInflater.from(getContext());
        }
        return this.f59;
    }

    private void setSubMenuArrowVisible(boolean z) {
        ImageView imageView = this.f56;
        if (imageView != null) {
            imageView.setVisibility(z ? 0 : 8);
        }
    }

    @Override // android.widget.AbsListView.SelectionBoundsAdjuster
    public final void adjustListItemSelectionBounds(Rect rect) {
        ImageView imageView = this.f61;
        if (imageView == null || imageView.getVisibility() != 0) {
            return;
        }
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.f61.getLayoutParams();
        rect.top = this.f61.getHeight() + layoutParams.topMargin + layoutParams.bottomMargin + rect.top;
    }

    @Override // defpackage.InterfaceC5060
    public C1578 getItemData() {
        return this.f60;
    }

    @Override // android.view.View
    public final void onFinishInflate() {
        super.onFinishInflate();
        setBackground(this.f62);
        TextView textView = (TextView) findViewById(R.id.title);
        this.f66 = textView;
        int i = this.f53;
        if (i != -1) {
            textView.setTextAppearance(this.f65, i);
        }
        this.f68 = (TextView) findViewById(R.id._2nn_res_0x7f0b0361);
        ImageView imageView = (ImageView) findViewById(R.id._25r_res_0x7f0b038e);
        this.f56 = imageView;
        if (imageView != null) {
            imageView.setImageDrawable(this.f55);
        }
        this.f61 = (ImageView) findViewById(R.id._70_res_0x7f0b01bc);
        this.f69 = (LinearLayout) findViewById(R.id._3vs_res_0x7f0b00f8);
    }

    @Override // android.widget.LinearLayout, android.view.View
    public final void onMeasure(int i, int i2) {
        if (this.f64 != null && this.f57) {
            ViewGroup.LayoutParams layoutParams = getLayoutParams();
            LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) this.f64.getLayoutParams();
            int i3 = layoutParams.height;
            if (i3 > 0 && layoutParams2.width <= 0) {
                layoutParams2.width = i3;
            }
        }
        super.onMeasure(i, i2);
    }

    public void setCheckable(boolean z) {
        CompoundButton compoundButton;
        View view;
        if (!z && this.f63 == null && this.f67 == null) {
            return;
        }
        if ((this.f60.f6329 & 4) != 0) {
            if (this.f63 == null) {
                RadioButton radioButton = (RadioButton) getInflater().inflate(R.layout._3fe_res_0x7f0e0011, (ViewGroup) this, false);
                this.f63 = radioButton;
                LinearLayout linearLayout = this.f69;
                if (linearLayout != null) {
                    linearLayout.addView(radioButton, -1);
                } else {
                    addView(radioButton, -1);
                }
            }
            compoundButton = this.f63;
            view = this.f67;
        } else {
            if (this.f67 == null) {
                CheckBox checkBox = (CheckBox) getInflater().inflate(R.layout._3qu_res_0x7f0e000e, (ViewGroup) this, false);
                this.f67 = checkBox;
                LinearLayout linearLayout2 = this.f69;
                if (linearLayout2 != null) {
                    linearLayout2.addView(checkBox, -1);
                } else {
                    addView(checkBox, -1);
                }
            }
            compoundButton = this.f67;
            view = this.f63;
        }
        if (z) {
            compoundButton.setChecked(this.f60.isChecked());
            if (compoundButton.getVisibility() != 0) {
                compoundButton.setVisibility(0);
            }
            if (view == null || view.getVisibility() == 8) {
                return;
            }
            view.setVisibility(8);
            return;
        }
        CheckBox checkBox2 = this.f67;
        if (checkBox2 != null) {
            checkBox2.setVisibility(8);
        }
        RadioButton radioButton2 = this.f63;
        if (radioButton2 != null) {
            radioButton2.setVisibility(8);
        }
    }

    public void setChecked(boolean z) {
        CompoundButton compoundButton;
        if ((this.f60.f6329 & 4) != 0) {
            if (this.f63 == null) {
                RadioButton radioButton = (RadioButton) getInflater().inflate(R.layout._3fe_res_0x7f0e0011, (ViewGroup) this, false);
                this.f63 = radioButton;
                LinearLayout linearLayout = this.f69;
                if (linearLayout != null) {
                    linearLayout.addView(radioButton, -1);
                } else {
                    addView(radioButton, -1);
                }
            }
            compoundButton = this.f63;
        } else {
            if (this.f67 == null) {
                CheckBox checkBox = (CheckBox) getInflater().inflate(R.layout._3qu_res_0x7f0e000e, (ViewGroup) this, false);
                this.f67 = checkBox;
                LinearLayout linearLayout2 = this.f69;
                if (linearLayout2 != null) {
                    linearLayout2.addView(checkBox, -1);
                } else {
                    addView(checkBox, -1);
                }
            }
            compoundButton = this.f67;
        }
        compoundButton.setChecked(z);
    }

    public void setForceShowIcon(boolean z) {
        this.f58 = z;
        this.f57 = z;
    }

    public void setGroupDividerEnabled(boolean z) {
        ImageView imageView = this.f61;
        if (imageView != null) {
            imageView.setVisibility((this.f54 || !z) ? 8 : 0);
        }
    }

    public void setIcon(Drawable drawable) {
        MenuC3271 menuC3271 = this.f60.f6324;
        boolean z = this.f58;
        if (z || this.f57) {
            ImageView imageView = this.f64;
            if (imageView == null && drawable == null && !this.f57) {
                return;
            }
            if (imageView == null) {
                ImageView imageView2 = (ImageView) getInflater().inflate(R.layout._13g_res_0x7f0e000f, (ViewGroup) this, false);
                this.f64 = imageView2;
                LinearLayout linearLayout = this.f69;
                if (linearLayout != null) {
                    linearLayout.addView(imageView2, 0);
                } else {
                    addView(imageView2, 0);
                }
            }
            if (drawable == null && !this.f57) {
                this.f64.setVisibility(8);
                return;
            }
            ImageView imageView3 = this.f64;
            if (!z) {
                drawable = null;
            }
            imageView3.setImageDrawable(drawable);
            if (this.f64.getVisibility() != 0) {
                this.f64.setVisibility(0);
            }
        }
    }

    public void setTitle(CharSequence charSequence) {
        TextView textView = this.f66;
        if (charSequence == null) {
            if (textView.getVisibility() != 8) {
                this.f66.setVisibility(8);
            }
        } else {
            textView.setText(charSequence);
            if (this.f66.getVisibility() != 0) {
                this.f66.setVisibility(0);
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:14:0x0035  */
    /* JADX WARN: Removed duplicated region for block: B:25:0x0053  */
    @Override // defpackage.InterfaceC5060
    /* JADX INFO: renamed from: ᵲᵶᵳˈ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void mo4(C1578 c1578) {
        boolean z;
        String string;
        this.f60 = c1578;
        boolean zIsVisible = c1578.isVisible();
        MenuC3271 menuC3271 = c1578.f6324;
        int i = 0;
        setVisibility(zIsVisible ? 0 : 8);
        setTitle(c1578.f6333);
        setCheckable(c1578.isCheckable());
        if (menuC3271.mo4529()) {
            if ((menuC3271.mo4526() ? c1578.f6339 : c1578.f6323) != 0) {
                z = true;
            }
        } else {
            z = false;
        }
        menuC3271.mo4526();
        if (z) {
            C1578 c15782 = this.f60;
            MenuC3271 menuC32712 = c15782.f6324;
            if (menuC32712.mo4529()) {
                if ((menuC32712.mo4526() ? c15782.f6339 : c15782.f6323) == 0) {
                }
            } else {
                i = 8;
            }
        }
        if (i == 0) {
            TextView textView = this.f68;
            C1578 c15783 = this.f60;
            MenuC3271 menuC32713 = c15783.f6324;
            Context context = menuC32713.f12530;
            char c = menuC32713.mo4526() ? c15783.f6339 : c15783.f6323;
            if (c == 0) {
                string = "";
            } else {
                Resources resources = context.getResources();
                StringBuilder sb = new StringBuilder();
                if (ViewConfiguration.get(context).hasPermanentMenuKey()) {
                    sb.append(resources.getString(R.string._1it_res_0x7f130011));
                }
                int i2 = menuC32713.mo4526() ? c15783.f6343 : c15783.f6345;
                C1578.m4423(i2, 65536, resources.getString(R.string._31_res_0x7f13000d), sb);
                C1578.m4423(i2, 4096, resources.getString(R.string._1nb_res_0x7f130009), sb);
                C1578.m4423(i2, 2, resources.getString(R.string._4me_res_0x7f130008), sb);
                C1578.m4423(i2, 1, resources.getString(R.string.c0), sb);
                C1578.m4423(i2, 4, resources.getString(R.string._4ri_res_0x7f130010), sb);
                C1578.m4423(i2, 8, resources.getString(R.string.df), sb);
                if (c == '\b') {
                    sb.append(resources.getString(R.string.h7));
                } else if (c == '\n') {
                    sb.append(resources.getString(R.string._27h_res_0x7f13000b));
                } else if (c != ' ') {
                    sb.append(c);
                } else {
                    sb.append(resources.getString(R.string._1kh_res_0x7f13000f));
                }
                string = sb.toString();
            }
            textView.setText(string);
        }
        if (this.f68.getVisibility() != i) {
            this.f68.setVisibility(i);
        }
        setIcon(c1578.getIcon());
        setEnabled(c1578.isEnabled());
        setSubMenuArrowVisible(c1578.hasSubMenu());
        setContentDescription(c1578.f6338);
    }
}
