package com.google.android.material.internal;

import E.j;
import M.J;
import android.R;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.CheckedTextView;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import com.google.android.material.datepicker.i;
import java.lang.reflect.Field;
import m.InterfaceC1155p;
import m.MenuItemC1148i;
import n.C1201b0;
import n4.u0;
import s3.e;

/* JADX INFO: loaded from: classes.dex */
public class NavigationMenuItemView extends e implements InterfaceC1155p {

    /* JADX INFO: renamed from: V, reason: collision with root package name */
    public static final int[] f10288V = {R.attr.state_checked};

    /* JADX INFO: renamed from: L, reason: collision with root package name */
    public int f10289L;

    /* JADX INFO: renamed from: M, reason: collision with root package name */
    public boolean f10290M;

    /* JADX INFO: renamed from: N, reason: collision with root package name */
    public boolean f10291N;

    /* JADX INFO: renamed from: O, reason: collision with root package name */
    public final CheckedTextView f10292O;

    /* JADX INFO: renamed from: P, reason: collision with root package name */
    public FrameLayout f10293P;

    /* JADX INFO: renamed from: Q, reason: collision with root package name */
    public MenuItemC1148i f10294Q;

    /* JADX INFO: renamed from: R, reason: collision with root package name */
    public ColorStateList f10295R;

    /* JADX INFO: renamed from: S, reason: collision with root package name */
    public boolean f10296S;

    /* JADX INFO: renamed from: T, reason: collision with root package name */
    public Drawable f10297T;

    /* JADX INFO: renamed from: U, reason: collision with root package name */
    public final i f10298U;

    public NavigationMenuItemView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        i iVar = new i(3, this);
        this.f10298U = iVar;
        setOrientation(0);
        LayoutInflater.from(context).inflate(com.martsnew.tv.R.layout.design_navigation_menu_item, (ViewGroup) this, true);
        setIconSize(context.getResources().getDimensionPixelSize(com.martsnew.tv.R.dimen.design_navigation_icon_size));
        CheckedTextView checkedTextView = (CheckedTextView) findViewById(com.martsnew.tv.R.id.design_menu_item_text);
        this.f10292O = checkedTextView;
        checkedTextView.setDuplicateParentStateEnabled(true);
        J.j(checkedTextView, iVar);
    }

    private void setActionView(View view) {
        if (view != null) {
            if (this.f10293P == null) {
                this.f10293P = (FrameLayout) ((ViewStub) findViewById(com.martsnew.tv.R.id.design_menu_item_action_area_stub)).inflate();
            }
            this.f10293P.removeAllViews();
            this.f10293P.addView(view);
        }
    }

    @Override // m.InterfaceC1155p
    public final void b(MenuItemC1148i menuItemC1148i) {
        StateListDrawable stateListDrawable;
        this.f10294Q = menuItemC1148i;
        int i = menuItemC1148i.f14487a;
        if (i > 0) {
            setId(i);
        }
        setVisibility(menuItemC1148i.isVisible() ? 0 : 8);
        if (getBackground() == null) {
            TypedValue typedValue = new TypedValue();
            if (getContext().getTheme().resolveAttribute(com.martsnew.tv.R.attr.colorControlHighlight, typedValue, true)) {
                stateListDrawable = new StateListDrawable();
                stateListDrawable.addState(f10288V, new ColorDrawable(typedValue.data));
                stateListDrawable.addState(ViewGroup.EMPTY_STATE_SET, new ColorDrawable(0));
            } else {
                stateListDrawable = null;
            }
            Field field = J.f4065a;
            setBackground(stateListDrawable);
        }
        setCheckable(menuItemC1148i.isCheckable());
        setChecked(menuItemC1148i.isChecked());
        setEnabled(menuItemC1148i.isEnabled());
        setTitle(menuItemC1148i.f14491e);
        setIcon(menuItemC1148i.getIcon());
        View view = menuItemC1148i.f14511z;
        if (view == null) {
            view = null;
        }
        setActionView(view);
        setContentDescription(menuItemC1148i.f14502q);
        u0.z(this, menuItemC1148i.f14503r);
        MenuItemC1148i menuItemC1148i2 = this.f10294Q;
        CharSequence charSequence = menuItemC1148i2.f14491e;
        CheckedTextView checkedTextView = this.f10292O;
        if (charSequence == null && menuItemC1148i2.getIcon() == null) {
            View view2 = this.f10294Q.f14511z;
            if ((view2 != null ? view2 : null) != null) {
                checkedTextView.setVisibility(8);
                FrameLayout frameLayout = this.f10293P;
                if (frameLayout != null) {
                    C1201b0 c1201b0 = (C1201b0) frameLayout.getLayoutParams();
                    ((LinearLayout.LayoutParams) c1201b0).width = -1;
                    this.f10293P.setLayoutParams(c1201b0);
                    return;
                }
                return;
            }
        }
        checkedTextView.setVisibility(0);
        FrameLayout frameLayout2 = this.f10293P;
        if (frameLayout2 != null) {
            C1201b0 c1201b02 = (C1201b0) frameLayout2.getLayoutParams();
            ((LinearLayout.LayoutParams) c1201b02).width = -2;
            this.f10293P.setLayoutParams(c1201b02);
        }
    }

    @Override // m.InterfaceC1155p
    public MenuItemC1148i getItemData() {
        return this.f10294Q;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final int[] onCreateDrawableState(int i) {
        int[] iArrOnCreateDrawableState = super.onCreateDrawableState(i + 1);
        MenuItemC1148i menuItemC1148i = this.f10294Q;
        if (menuItemC1148i != null && menuItemC1148i.isCheckable() && this.f10294Q.isChecked()) {
            View.mergeDrawableStates(iArrOnCreateDrawableState, f10288V);
        }
        return iArrOnCreateDrawableState;
    }

    public void setCheckable(boolean z8) {
        refreshDrawableState();
        if (this.f10291N != z8) {
            this.f10291N = z8;
            this.f10298U.h(this.f10292O, 2048);
        }
    }

    public void setChecked(boolean z8) {
        refreshDrawableState();
        this.f10292O.setChecked(z8);
    }

    public void setHorizontalPadding(int i) {
        setPadding(i, 0, i, 0);
    }

    public void setIcon(Drawable drawable) {
        if (drawable != null) {
            if (this.f10296S) {
                Drawable.ConstantState constantState = drawable.getConstantState();
                if (constantState != null) {
                    drawable = constantState.newDrawable();
                }
                drawable = drawable.mutate();
                drawable.setTintList(this.f10295R);
            }
            int i = this.f10289L;
            drawable.setBounds(0, 0, i, i);
        } else if (this.f10290M) {
            if (this.f10297T == null) {
                Resources resources = getResources();
                Resources.Theme theme = getContext().getTheme();
                ThreadLocal threadLocal = j.f1954a;
                Drawable drawable2 = resources.getDrawable(com.martsnew.tv.R.drawable.navigation_empty_icon, theme);
                this.f10297T = drawable2;
                if (drawable2 != null) {
                    int i5 = this.f10289L;
                    drawable2.setBounds(0, 0, i5, i5);
                }
            }
            drawable = this.f10297T;
        }
        this.f10292O.setCompoundDrawablesRelative(drawable, null, null, null);
    }

    public void setIconPadding(int i) {
        this.f10292O.setCompoundDrawablePadding(i);
    }

    public void setIconSize(int i) {
        this.f10289L = i;
    }

    public void setIconTintList(ColorStateList colorStateList) {
        this.f10295R = colorStateList;
        this.f10296S = colorStateList != null;
        MenuItemC1148i menuItemC1148i = this.f10294Q;
        if (menuItemC1148i != null) {
            setIcon(menuItemC1148i.getIcon());
        }
    }

    public void setMaxLines(int i) {
        this.f10292O.setMaxLines(i);
    }

    public void setNeedsEmptyIcon(boolean z8) {
        this.f10290M = z8;
    }

    public void setTextAppearance(int i) {
        this.f10292O.setTextAppearance(i);
    }

    public void setTextColor(ColorStateList colorStateList) {
        this.f10292O.setTextColor(colorStateList);
    }

    public void setTitle(CharSequence charSequence) {
        this.f10292O.setText(charSequence);
    }
}
