package androidx.appcompat.widget;

import X6FRs_4.KQgRr5e_0.FSaI4_7;
import X6FRs_4.KQgRr5e_0.LGe8pk_15.NQvZgp_17;
import X6FRs_4.KQgRr5e_0.LGe8pk_15.NzhupJ_29;
import X6FRs_4.KQgRr5e_0.XnFJ5_9;
import X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9.Eps4cJe_18;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.DataSetObserver;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
/* loaded from: classes.dex */
public class ActivityChooserView extends ViewGroup {
    public final int KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public X6FRs_4.IMuAHx_6.EuDEkJe_12.QxJ9d_1 f2030KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final DataSetObserver f2031KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final Drawable f2032KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final View f2033KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final ViewTreeObserver.OnGlobalLayoutListener f2034KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final FrameLayout f2035KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final ImageView f2036KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public PopupWindow.OnDismissListener f2037KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final IFxWkV_5 f2038KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final IMuAHx_6 f2039KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public ListPopupWindow f2040KQgRr5e_0;
    public int PGPF6hQ_2;

    /* renamed from: PGPF6hQ_2  reason: collision with other field name */
    public boolean f2041PGPF6hQ_2;
    public int QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public final FrameLayout f2042QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public final ImageView f2043QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public boolean f2044QxJ9d_1;

    /* loaded from: classes.dex */
    public class IMuAHx_6 implements AdapterView.OnItemClickListener, View.OnClickListener, View.OnLongClickListener, PopupWindow.OnDismissListener {
        public IMuAHx_6() {
        }

        public final void KQgRr5e_0() {
            PopupWindow.OnDismissListener onDismissListener = ActivityChooserView.this.f2037KQgRr5e_0;
            if (onDismissListener != null) {
                onDismissListener.onDismiss();
            }
        }

        @Override // android.view.View.OnClickListener
        public void onClick(View view) {
            ActivityChooserView activityChooserView = ActivityChooserView.this;
            if (view == activityChooserView.f2042QxJ9d_1) {
                activityChooserView.m843KQgRr5e_0();
                Intent KQgRr5e_0 = ActivityChooserView.this.f2038KQgRr5e_0.m844KQgRr5e_0().KQgRr5e_0(ActivityChooserView.this.f2038KQgRr5e_0.m844KQgRr5e_0().KQgRr5e_0(ActivityChooserView.this.f2038KQgRr5e_0.m845KQgRr5e_0()));
                if (KQgRr5e_0 != null) {
                    KQgRr5e_0.addFlags(524288);
                    ActivityChooserView.this.getContext().startActivity(KQgRr5e_0);
                }
            } else if (view == activityChooserView.f2035KQgRr5e_0) {
                activityChooserView.f2044QxJ9d_1 = false;
                activityChooserView.KQgRr5e_0(activityChooserView.QxJ9d_1);
            } else {
                throw new IllegalArgumentException();
            }
        }

        @Override // android.widget.PopupWindow.OnDismissListener
        public void onDismiss() {
            KQgRr5e_0();
            X6FRs_4.IMuAHx_6.EuDEkJe_12.QxJ9d_1 qxJ9d_1 = ActivityChooserView.this.f2030KQgRr5e_0;
            if (qxJ9d_1 != null) {
                qxJ9d_1.KQgRr5e_0(false);
            }
        }

        @Override // android.widget.AdapterView.OnItemClickListener
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
            int itemViewType = ((IFxWkV_5) adapterView.getAdapter()).getItemViewType(i);
            if (itemViewType != 0) {
                if (itemViewType == 1) {
                    ActivityChooserView.this.KQgRr5e_0(Integer.MAX_VALUE);
                    return;
                }
                throw new IllegalArgumentException();
            }
            ActivityChooserView.this.m843KQgRr5e_0();
            ActivityChooserView activityChooserView = ActivityChooserView.this;
            if (activityChooserView.f2044QxJ9d_1) {
                if (i > 0) {
                    activityChooserView.f2038KQgRr5e_0.m844KQgRr5e_0().m424KQgRr5e_0(i);
                    return;
                }
                return;
            }
            if (!activityChooserView.f2038KQgRr5e_0.m846KQgRr5e_0()) {
                i++;
            }
            Intent KQgRr5e_0 = ActivityChooserView.this.f2038KQgRr5e_0.m844KQgRr5e_0().KQgRr5e_0(i);
            if (KQgRr5e_0 != null) {
                KQgRr5e_0.addFlags(524288);
                ActivityChooserView.this.getContext().startActivity(KQgRr5e_0);
            }
        }

        @Override // android.view.View.OnLongClickListener
        public boolean onLongClick(View view) {
            ActivityChooserView activityChooserView = ActivityChooserView.this;
            if (view == activityChooserView.f2042QxJ9d_1) {
                if (activityChooserView.f2038KQgRr5e_0.getCount() > 0) {
                    ActivityChooserView activityChooserView2 = ActivityChooserView.this;
                    activityChooserView2.f2044QxJ9d_1 = true;
                    activityChooserView2.KQgRr5e_0(activityChooserView2.QxJ9d_1);
                }
                return true;
            }
            throw new IllegalArgumentException();
        }
    }

    /* loaded from: classes.dex */
    public static class InnerLayout extends LinearLayout {
        public static final int[] KQgRr5e_0 = {16842964};

        public InnerLayout(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
            NzhupJ_29 KQgRr5e_02 = NzhupJ_29.KQgRr5e_0(context, attributeSet, KQgRr5e_0);
            setBackgroundDrawable(KQgRr5e_02.m416KQgRr5e_0(0));
            KQgRr5e_02.KQgRr5e_0();
        }
    }

    /* loaded from: classes.dex */
    public class KQgRr5e_0 extends DataSetObserver {
        public KQgRr5e_0() {
        }

        @Override // android.database.DataSetObserver
        public void onChanged() {
            super.onChanged();
            ActivityChooserView.this.f2038KQgRr5e_0.notifyDataSetChanged();
        }

        @Override // android.database.DataSetObserver
        public void onInvalidated() {
            super.onInvalidated();
            ActivityChooserView.this.f2038KQgRr5e_0.notifyDataSetInvalidated();
        }
    }

    /* loaded from: classes.dex */
    public class Mqv2r_3 extends NQvZgp_17 {
        public Mqv2r_3(View view) {
            super(view);
        }

        @Override // X6FRs_4.KQgRr5e_0.LGe8pk_15.NQvZgp_17
        public Eps4cJe_18 KQgRr5e_0() {
            return ActivityChooserView.this.getListPopupWindow();
        }

        @Override // X6FRs_4.KQgRr5e_0.LGe8pk_15.NQvZgp_17
        public boolean QxJ9d_1() {
            ActivityChooserView.this.m843KQgRr5e_0();
            return true;
        }

        @Override // X6FRs_4.KQgRr5e_0.LGe8pk_15.NQvZgp_17
        public boolean KQgRr5e_0() {
            ActivityChooserView.this.PGPF6hQ_2();
            return true;
        }
    }

    /* loaded from: classes.dex */
    public class PGPF6hQ_2 extends View.AccessibilityDelegate {
        public PGPF6hQ_2(ActivityChooserView activityChooserView) {
        }

        @Override // android.view.View.AccessibilityDelegate
        public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfo accessibilityNodeInfo) {
            super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfo);
            X6FRs_4.IMuAHx_6.EuDEkJe_12.NzhupJ_29.Mqv2r_3.KQgRr5e_0(accessibilityNodeInfo).QxJ9d_1(true);
        }
    }

    /* loaded from: classes.dex */
    public class QxJ9d_1 implements ViewTreeObserver.OnGlobalLayoutListener {
        public QxJ9d_1() {
        }

        @Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
        public void onGlobalLayout() {
            if (ActivityChooserView.this.QxJ9d_1()) {
                if (!ActivityChooserView.this.isShown()) {
                    ActivityChooserView.this.getListPopupWindow().dismiss();
                    return;
                }
                ActivityChooserView.this.getListPopupWindow().show();
                X6FRs_4.IMuAHx_6.EuDEkJe_12.QxJ9d_1 qxJ9d_1 = ActivityChooserView.this.f2030KQgRr5e_0;
                if (qxJ9d_1 != null) {
                    qxJ9d_1.KQgRr5e_0(true);
                }
            }
        }
    }

    /* loaded from: classes.dex */
    public class X6FRs_4 extends DataSetObserver {
        public X6FRs_4() {
        }

        @Override // android.database.DataSetObserver
        public void onChanged() {
            super.onChanged();
            ActivityChooserView.this.KQgRr5e_0();
        }
    }

    public ActivityChooserView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r0v15 */
    /* JADX WARN: Type inference failed for: r0v6 */
    /* JADX WARN: Type inference failed for: r0v7, types: [int, boolean] */
    public void KQgRr5e_0(int i) {
        if (this.f2038KQgRr5e_0.m844KQgRr5e_0() != null) {
            getViewTreeObserver().addOnGlobalLayoutListener(this.f2034KQgRr5e_0);
            ?? r0 = this.f2042QxJ9d_1.getVisibility() == 0 ? 1 : 0;
            int KQgRr5e_02 = this.f2038KQgRr5e_0.KQgRr5e_0();
            if (i != Integer.MAX_VALUE && KQgRr5e_02 > i + r0) {
                this.f2038KQgRr5e_0.KQgRr5e_0(true);
                this.f2038KQgRr5e_0.KQgRr5e_0(i - 1);
            } else {
                this.f2038KQgRr5e_0.KQgRr5e_0(false);
                this.f2038KQgRr5e_0.KQgRr5e_0(i);
            }
            ListPopupWindow listPopupWindow = getListPopupWindow();
            if (listPopupWindow.KQgRr5e_0()) {
                return;
            }
            if (!this.f2044QxJ9d_1 && r0 != 0) {
                this.f2038KQgRr5e_0.KQgRr5e_0(false, false);
            } else {
                this.f2038KQgRr5e_0.KQgRr5e_0(true, r0);
            }
            listPopupWindow.QxJ9d_1(Math.min(this.f2038KQgRr5e_0.PGPF6hQ_2(), this.KQgRr5e_0));
            listPopupWindow.show();
            X6FRs_4.IMuAHx_6.EuDEkJe_12.QxJ9d_1 qxJ9d_1 = this.f2030KQgRr5e_0;
            if (qxJ9d_1 != null) {
                qxJ9d_1.KQgRr5e_0(true);
            }
            listPopupWindow.KQgRr5e_0().setContentDescription(getContext().getString(FSaI4_7.abc_activitychooserview_choose_application));
            listPopupWindow.KQgRr5e_0().setSelector(new ColorDrawable(0));
            return;
        }
        throw new IllegalStateException("No data model. Did you call #setDataModel?");
    }

    public boolean PGPF6hQ_2() {
        if (QxJ9d_1() || !this.f2041PGPF6hQ_2) {
            return false;
        }
        this.f2044QxJ9d_1 = false;
        KQgRr5e_0(this.QxJ9d_1);
        return true;
    }

    public boolean QxJ9d_1() {
        return getListPopupWindow().KQgRr5e_0();
    }

    public X6FRs_4.KQgRr5e_0.LGe8pk_15.PGPF6hQ_2 getDataModel() {
        return this.f2038KQgRr5e_0.m844KQgRr5e_0();
    }

    public ListPopupWindow getListPopupWindow() {
        if (this.f2040KQgRr5e_0 == null) {
            ListPopupWindow listPopupWindow = new ListPopupWindow(getContext());
            this.f2040KQgRr5e_0 = listPopupWindow;
            listPopupWindow.KQgRr5e_0(this.f2038KQgRr5e_0);
            this.f2040KQgRr5e_0.KQgRr5e_0(this);
            this.f2040KQgRr5e_0.KQgRr5e_0(true);
            this.f2040KQgRr5e_0.KQgRr5e_0((AdapterView.OnItemClickListener) this.f2039KQgRr5e_0);
            this.f2040KQgRr5e_0.KQgRr5e_0((PopupWindow.OnDismissListener) this.f2039KQgRr5e_0);
        }
        return this.f2040KQgRr5e_0;
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        X6FRs_4.KQgRr5e_0.LGe8pk_15.PGPF6hQ_2 m844KQgRr5e_0 = this.f2038KQgRr5e_0.m844KQgRr5e_0();
        if (m844KQgRr5e_0 != null) {
            m844KQgRr5e_0.registerObserver(this.f2031KQgRr5e_0);
        }
        this.f2041PGPF6hQ_2 = true;
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        X6FRs_4.KQgRr5e_0.LGe8pk_15.PGPF6hQ_2 m844KQgRr5e_0 = this.f2038KQgRr5e_0.m844KQgRr5e_0();
        if (m844KQgRr5e_0 != null) {
            m844KQgRr5e_0.unregisterObserver(this.f2031KQgRr5e_0);
        }
        ViewTreeObserver viewTreeObserver = getViewTreeObserver();
        if (viewTreeObserver.isAlive()) {
            viewTreeObserver.removeGlobalOnLayoutListener(this.f2034KQgRr5e_0);
        }
        if (QxJ9d_1()) {
            m843KQgRr5e_0();
        }
        this.f2041PGPF6hQ_2 = false;
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onLayout(boolean z, int i, int i2, int i3, int i4) {
        this.f2033KQgRr5e_0.layout(0, 0, i3 - i, i4 - i2);
        if (QxJ9d_1()) {
            return;
        }
        m843KQgRr5e_0();
    }

    @Override // android.view.View
    public void onMeasure(int i, int i2) {
        View view = this.f2033KQgRr5e_0;
        if (this.f2042QxJ9d_1.getVisibility() != 0) {
            i2 = View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(i2), 1073741824);
        }
        measureChild(view, i, i2);
        setMeasuredDimension(view.getMeasuredWidth(), view.getMeasuredHeight());
    }

    public void setActivityChooserModel(X6FRs_4.KQgRr5e_0.LGe8pk_15.PGPF6hQ_2 pGPF6hQ_2) {
        this.f2038KQgRr5e_0.KQgRr5e_0(pGPF6hQ_2);
        if (QxJ9d_1()) {
            m843KQgRr5e_0();
            PGPF6hQ_2();
        }
    }

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

    public void setExpandActivityOverflowButtonContentDescription(int i) {
        this.f2036KQgRr5e_0.setContentDescription(getContext().getString(i));
    }

    public void setExpandActivityOverflowButtonDrawable(Drawable drawable) {
        this.f2036KQgRr5e_0.setImageDrawable(drawable);
    }

    public void setInitialActivityCount(int i) {
        this.QxJ9d_1 = i;
    }

    public void setOnDismissListener(PopupWindow.OnDismissListener onDismissListener) {
        this.f2037KQgRr5e_0 = onDismissListener;
    }

    public void setProvider(X6FRs_4.IMuAHx_6.EuDEkJe_12.QxJ9d_1 qxJ9d_1) {
        this.f2030KQgRr5e_0 = qxJ9d_1;
    }

    public ActivityChooserView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.f2031KQgRr5e_0 = new KQgRr5e_0();
        this.f2034KQgRr5e_0 = new QxJ9d_1();
        this.QxJ9d_1 = 4;
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, XnFJ5_9.ActivityChooserView, i, 0);
        this.QxJ9d_1 = obtainStyledAttributes.getInt(XnFJ5_9.ActivityChooserView_initialActivityCount, 4);
        Drawable drawable = obtainStyledAttributes.getDrawable(XnFJ5_9.ActivityChooserView_expandActivityOverflowButtonDrawable);
        obtainStyledAttributes.recycle();
        LayoutInflater.from(getContext()).inflate(X6FRs_4.KQgRr5e_0.IMuAHx_6.abc_activity_chooser_view, (ViewGroup) this, true);
        this.f2039KQgRr5e_0 = new IMuAHx_6();
        View findViewById = findViewById(X6FRs_4.KQgRr5e_0.IFxWkV_5.activity_chooser_view_content);
        this.f2033KQgRr5e_0 = findViewById;
        this.f2032KQgRr5e_0 = findViewById.getBackground();
        FrameLayout frameLayout = (FrameLayout) findViewById(X6FRs_4.KQgRr5e_0.IFxWkV_5.default_activity_button);
        this.f2042QxJ9d_1 = frameLayout;
        frameLayout.setOnClickListener(this.f2039KQgRr5e_0);
        this.f2042QxJ9d_1.setOnLongClickListener(this.f2039KQgRr5e_0);
        this.f2043QxJ9d_1 = (ImageView) this.f2042QxJ9d_1.findViewById(X6FRs_4.KQgRr5e_0.IFxWkV_5.image);
        FrameLayout frameLayout2 = (FrameLayout) findViewById(X6FRs_4.KQgRr5e_0.IFxWkV_5.expand_activities_button);
        frameLayout2.setOnClickListener(this.f2039KQgRr5e_0);
        frameLayout2.setAccessibilityDelegate(new PGPF6hQ_2(this));
        frameLayout2.setOnTouchListener(new Mqv2r_3(frameLayout2));
        this.f2035KQgRr5e_0 = frameLayout2;
        ImageView imageView = (ImageView) frameLayout2.findViewById(X6FRs_4.KQgRr5e_0.IFxWkV_5.image);
        this.f2036KQgRr5e_0 = imageView;
        imageView.setImageDrawable(drawable);
        IFxWkV_5 iFxWkV_5 = new IFxWkV_5();
        this.f2038KQgRr5e_0 = iFxWkV_5;
        iFxWkV_5.registerDataSetObserver(new X6FRs_4());
        Resources resources = context.getResources();
        this.KQgRr5e_0 = Math.max(resources.getDisplayMetrics().widthPixels / 2, resources.getDimensionPixelSize(X6FRs_4.KQgRr5e_0.Mqv2r_3.abc_config_prefDialogWidth));
    }

    /* loaded from: classes.dex */
    public class IFxWkV_5 extends BaseAdapter {
        public int KQgRr5e_0 = 4;

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public X6FRs_4.KQgRr5e_0.LGe8pk_15.PGPF6hQ_2 f2045KQgRr5e_0;

        /* renamed from: Mqv2r_3  reason: collision with root package name */
        public boolean f3464Mqv2r_3;
        public boolean PGPF6hQ_2;
        public boolean QxJ9d_1;

        public IFxWkV_5() {
        }

        public void KQgRr5e_0(X6FRs_4.KQgRr5e_0.LGe8pk_15.PGPF6hQ_2 pGPF6hQ_2) {
            X6FRs_4.KQgRr5e_0.LGe8pk_15.PGPF6hQ_2 m844KQgRr5e_0 = ActivityChooserView.this.f2038KQgRr5e_0.m844KQgRr5e_0();
            if (m844KQgRr5e_0 != null && ActivityChooserView.this.isShown()) {
                m844KQgRr5e_0.unregisterObserver(ActivityChooserView.this.f2031KQgRr5e_0);
            }
            this.f2045KQgRr5e_0 = pGPF6hQ_2;
            if (pGPF6hQ_2 != null && ActivityChooserView.this.isShown()) {
                pGPF6hQ_2.registerObserver(ActivityChooserView.this.f2031KQgRr5e_0);
            }
            notifyDataSetChanged();
        }

        public int PGPF6hQ_2() {
            int i = this.KQgRr5e_0;
            this.KQgRr5e_0 = Integer.MAX_VALUE;
            int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, 0);
            int makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(0, 0);
            int count = getCount();
            View view = null;
            int i2 = 0;
            for (int i3 = 0; i3 < count; i3++) {
                view = getView(i3, view, null);
                view.measure(makeMeasureSpec, makeMeasureSpec2);
                i2 = Math.max(i2, view.getMeasuredWidth());
            }
            this.KQgRr5e_0 = i;
            return i2;
        }

        public int QxJ9d_1() {
            return this.f2045KQgRr5e_0.QxJ9d_1();
        }

        @Override // android.widget.Adapter
        public int getCount() {
            int KQgRr5e_0 = this.f2045KQgRr5e_0.KQgRr5e_0();
            if (!this.QxJ9d_1 && this.f2045KQgRr5e_0.m421KQgRr5e_0() != null) {
                KQgRr5e_0--;
            }
            int min = Math.min(KQgRr5e_0, this.KQgRr5e_0);
            return this.f3464Mqv2r_3 ? min + 1 : min;
        }

        @Override // android.widget.Adapter
        public Object getItem(int i) {
            int itemViewType = getItemViewType(i);
            if (itemViewType != 0) {
                if (itemViewType == 1) {
                    return null;
                }
                throw new IllegalArgumentException();
            }
            if (!this.QxJ9d_1 && this.f2045KQgRr5e_0.m421KQgRr5e_0() != null) {
                i++;
            }
            return this.f2045KQgRr5e_0.m422KQgRr5e_0(i);
        }

        @Override // android.widget.Adapter
        public long getItemId(int i) {
            return i;
        }

        @Override // android.widget.BaseAdapter, android.widget.Adapter
        public int getItemViewType(int i) {
            return (this.f3464Mqv2r_3 && i == getCount() - 1) ? 1 : 0;
        }

        @Override // android.widget.Adapter
        public View getView(int i, View view, ViewGroup viewGroup) {
            int itemViewType = getItemViewType(i);
            if (itemViewType != 0) {
                if (itemViewType == 1) {
                    if (view == null || view.getId() != 1) {
                        View inflate = LayoutInflater.from(ActivityChooserView.this.getContext()).inflate(X6FRs_4.KQgRr5e_0.IMuAHx_6.abc_activity_chooser_view_list_item, viewGroup, false);
                        inflate.setId(1);
                        ((TextView) inflate.findViewById(X6FRs_4.KQgRr5e_0.IFxWkV_5.title)).setText(ActivityChooserView.this.getContext().getString(FSaI4_7.abc_activity_chooser_view_see_all));
                        return inflate;
                    }
                    return view;
                }
                throw new IllegalArgumentException();
            }
            if (view == null || view.getId() != X6FRs_4.KQgRr5e_0.IFxWkV_5.list_item) {
                view = LayoutInflater.from(ActivityChooserView.this.getContext()).inflate(X6FRs_4.KQgRr5e_0.IMuAHx_6.abc_activity_chooser_view_list_item, viewGroup, false);
            }
            PackageManager packageManager = ActivityChooserView.this.getContext().getPackageManager();
            ResolveInfo resolveInfo = (ResolveInfo) getItem(i);
            ((ImageView) view.findViewById(X6FRs_4.KQgRr5e_0.IFxWkV_5.icon)).setImageDrawable(resolveInfo.loadIcon(packageManager));
            ((TextView) view.findViewById(X6FRs_4.KQgRr5e_0.IFxWkV_5.title)).setText(resolveInfo.loadLabel(packageManager));
            if (this.QxJ9d_1 && i == 0 && this.PGPF6hQ_2) {
                view.setActivated(true);
            } else {
                view.setActivated(false);
            }
            return view;
        }

        @Override // android.widget.BaseAdapter, android.widget.Adapter
        public int getViewTypeCount() {
            return 3;
        }

        public void KQgRr5e_0(int i) {
            if (this.KQgRr5e_0 != i) {
                this.KQgRr5e_0 = i;
                notifyDataSetChanged();
            }
        }

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        public ResolveInfo m845KQgRr5e_0() {
            return this.f2045KQgRr5e_0.m421KQgRr5e_0();
        }

        public void KQgRr5e_0(boolean z) {
            if (this.f3464Mqv2r_3 != z) {
                this.f3464Mqv2r_3 = z;
                notifyDataSetChanged();
            }
        }

        public int KQgRr5e_0() {
            return this.f2045KQgRr5e_0.KQgRr5e_0();
        }

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        public X6FRs_4.KQgRr5e_0.LGe8pk_15.PGPF6hQ_2 m844KQgRr5e_0() {
            return this.f2045KQgRr5e_0;
        }

        public void KQgRr5e_0(boolean z, boolean z2) {
            if (this.QxJ9d_1 == z && this.PGPF6hQ_2 == z2) {
                return;
            }
            this.QxJ9d_1 = z;
            this.PGPF6hQ_2 = z2;
            notifyDataSetChanged();
        }

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        public boolean m846KQgRr5e_0() {
            return this.QxJ9d_1;
        }
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public boolean m843KQgRr5e_0() {
        if (QxJ9d_1()) {
            getListPopupWindow().dismiss();
            ViewTreeObserver viewTreeObserver = getViewTreeObserver();
            if (viewTreeObserver.isAlive()) {
                viewTreeObserver.removeGlobalOnLayoutListener(this.f2034KQgRr5e_0);
                return true;
            }
            return true;
        }
        return true;
    }

    public void KQgRr5e_0() {
        if (this.f2038KQgRr5e_0.getCount() > 0) {
            this.f2035KQgRr5e_0.setEnabled(true);
        } else {
            this.f2035KQgRr5e_0.setEnabled(false);
        }
        int KQgRr5e_02 = this.f2038KQgRr5e_0.KQgRr5e_0();
        int QxJ9d_12 = this.f2038KQgRr5e_0.QxJ9d_1();
        if (KQgRr5e_02 != 1 && (KQgRr5e_02 <= 1 || QxJ9d_12 <= 0)) {
            this.f2042QxJ9d_1.setVisibility(8);
        } else {
            this.f2042QxJ9d_1.setVisibility(0);
            ResolveInfo m845KQgRr5e_0 = this.f2038KQgRr5e_0.m845KQgRr5e_0();
            PackageManager packageManager = getContext().getPackageManager();
            this.f2043QxJ9d_1.setImageDrawable(m845KQgRr5e_0.loadIcon(packageManager));
            if (this.PGPF6hQ_2 != 0) {
                this.f2042QxJ9d_1.setContentDescription(getContext().getString(this.PGPF6hQ_2, m845KQgRr5e_0.loadLabel(packageManager)));
            }
        }
        if (this.f2042QxJ9d_1.getVisibility() == 0) {
            this.f2033KQgRr5e_0.setBackgroundDrawable(this.f2032KQgRr5e_0);
        } else {
            this.f2033KQgRr5e_0.setBackgroundDrawable(null);
        }
    }
}
