package X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9;

import X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9.LGe8pk_15;
import X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9.YghfZG_14;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
/* compiled from: BaseMenuPresenter.java */
/* loaded from: classes.dex */
public abstract class QxJ9d_1 implements YghfZG_14 {
    public int KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public FSaI4_7 f910KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public LGe8pk_15 f911KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public YghfZG_14.KQgRr5e_0 f912KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public Context f913KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public LayoutInflater f914KQgRr5e_0;
    public int PGPF6hQ_2;
    public int QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public Context f915QxJ9d_1;

    public QxJ9d_1(Context context, int i, int i2) {
        this.f913KQgRr5e_0 = context;
        this.f914KQgRr5e_0 = LayoutInflater.from(context);
        this.KQgRr5e_0 = i;
        this.QxJ9d_1 = i2;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public LGe8pk_15 m476KQgRr5e_0(ViewGroup viewGroup) {
        if (this.f911KQgRr5e_0 == null) {
            LGe8pk_15 lGe8pk_15 = (LGe8pk_15) this.f914KQgRr5e_0.inflate(this.KQgRr5e_0, viewGroup, false);
            this.f911KQgRr5e_0 = lGe8pk_15;
            lGe8pk_15.initialize(this.f910KQgRr5e_0);
            updateMenuView(true);
        }
        return this.f911KQgRr5e_0;
    }

    public abstract void KQgRr5e_0(XnFJ5_9 xnFJ5_9, LGe8pk_15.KQgRr5e_0 kQgRr5e_0);

    public abstract boolean KQgRr5e_0(int i, XnFJ5_9 xnFJ5_9);

    @Override // X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9.YghfZG_14
    public boolean collapseItemActionView(FSaI4_7 fSaI4_7, XnFJ5_9 xnFJ5_9) {
        return false;
    }

    @Override // X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9.YghfZG_14
    public boolean expandItemActionView(FSaI4_7 fSaI4_7, XnFJ5_9 xnFJ5_9) {
        return false;
    }

    @Override // X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9.YghfZG_14
    public int getId() {
        return this.PGPF6hQ_2;
    }

    @Override // X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9.YghfZG_14
    public void initForMenu(Context context, FSaI4_7 fSaI4_7) {
        this.f915QxJ9d_1 = context;
        LayoutInflater.from(context);
        this.f910KQgRr5e_0 = fSaI4_7;
    }

    @Override // X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9.YghfZG_14
    public void onCloseMenu(FSaI4_7 fSaI4_7, boolean z) {
        YghfZG_14.KQgRr5e_0 kQgRr5e_0 = this.f912KQgRr5e_0;
        if (kQgRr5e_0 != null) {
            kQgRr5e_0.onCloseMenu(fSaI4_7, z);
        }
    }

    @Override // X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9.YghfZG_14
    public boolean onSubMenuSelected(ZzDuCHW_20 zzDuCHW_20) {
        YghfZG_14.KQgRr5e_0 kQgRr5e_0 = this.f912KQgRr5e_0;
        if (kQgRr5e_0 != null) {
            return kQgRr5e_0.KQgRr5e_0(zzDuCHW_20);
        }
        return false;
    }

    @Override // X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9.YghfZG_14
    public void setCallback(YghfZG_14.KQgRr5e_0 kQgRr5e_0) {
        this.f912KQgRr5e_0 = kQgRr5e_0;
    }

    @Override // X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9.YghfZG_14
    public void updateMenuView(boolean z) {
        ViewGroup viewGroup = (ViewGroup) this.f911KQgRr5e_0;
        if (viewGroup == null) {
            return;
        }
        FSaI4_7 fSaI4_7 = this.f910KQgRr5e_0;
        int i = 0;
        if (fSaI4_7 != null) {
            fSaI4_7.flagActionItems();
            ArrayList<XnFJ5_9> visibleItems = this.f910KQgRr5e_0.getVisibleItems();
            int size = visibleItems.size();
            int i2 = 0;
            for (int i3 = 0; i3 < size; i3++) {
                XnFJ5_9 xnFJ5_9 = visibleItems.get(i3);
                if (KQgRr5e_0(i2, xnFJ5_9)) {
                    View childAt = viewGroup.getChildAt(i2);
                    XnFJ5_9 itemData = childAt instanceof LGe8pk_15.KQgRr5e_0 ? ((LGe8pk_15.KQgRr5e_0) childAt).getItemData() : null;
                    View KQgRr5e_0 = KQgRr5e_0(xnFJ5_9, childAt, viewGroup);
                    if (xnFJ5_9 != itemData) {
                        KQgRr5e_0.setPressed(false);
                        KQgRr5e_0.jumpDrawablesToCurrentState();
                    }
                    if (KQgRr5e_0 != childAt) {
                        KQgRr5e_0(KQgRr5e_0, i2);
                    }
                    i2++;
                }
            }
            i = i2;
        }
        while (i < viewGroup.getChildCount()) {
            if (!KQgRr5e_0(viewGroup, i)) {
                i++;
            }
        }
    }

    public void KQgRr5e_0(View view, int i) {
        ViewGroup viewGroup = (ViewGroup) view.getParent();
        if (viewGroup != null) {
            viewGroup.removeView(view);
        }
        ((ViewGroup) this.f911KQgRr5e_0).addView(view, i);
    }

    public boolean KQgRr5e_0(ViewGroup viewGroup, int i) {
        viewGroup.removeViewAt(i);
        return true;
    }

    public YghfZG_14.KQgRr5e_0 KQgRr5e_0() {
        return this.f912KQgRr5e_0;
    }

    public LGe8pk_15.KQgRr5e_0 KQgRr5e_0(ViewGroup viewGroup) {
        return (LGe8pk_15.KQgRr5e_0) this.f914KQgRr5e_0.inflate(this.QxJ9d_1, viewGroup, false);
    }

    public View KQgRr5e_0(XnFJ5_9 xnFJ5_9, View view, ViewGroup viewGroup) {
        LGe8pk_15.KQgRr5e_0 KQgRr5e_0;
        if (view instanceof LGe8pk_15.KQgRr5e_0) {
            KQgRr5e_0 = (LGe8pk_15.KQgRr5e_0) view;
        } else {
            KQgRr5e_0 = KQgRr5e_0(viewGroup);
        }
        KQgRr5e_0(xnFJ5_9, KQgRr5e_0);
        return (View) KQgRr5e_0;
    }

    public void KQgRr5e_0(int i) {
        this.PGPF6hQ_2 = i;
    }
}
