package X6FRs_4.KQgRr5e_0.LGe8pk_15;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ListAdapter;
import android.widget.ListView;
import java.lang.reflect.Field;
/* compiled from: DropDownListView.java */
/* loaded from: classes.dex */
public class LGe8pk_15 extends ListView {
    public int KQgRr5e_0;

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

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public X6FRs_4.IMuAHx_6.WwEq_13.IFxWkV_5 f712KQgRr5e_0;

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

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public QxJ9d_1 f714KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final Rect f715KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public Field f716KQgRr5e_0;

    /* renamed from: Mqv2r_3  reason: collision with root package name */
    public int f3162Mqv2r_3;

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

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

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

    /* renamed from: X6FRs_4  reason: collision with root package name */
    public int f3163X6FRs_4;

    /* compiled from: DropDownListView.java */
    /* loaded from: classes.dex */
    public static class KQgRr5e_0 extends X6FRs_4.KQgRr5e_0.EuDEkJe_12.KQgRr5e_0.PGPF6hQ_2 {
        public boolean QxJ9d_1;

        public KQgRr5e_0(Drawable drawable) {
            super(drawable);
            this.QxJ9d_1 = true;
        }

        public void KQgRr5e_0(boolean z) {
            this.QxJ9d_1 = z;
        }

        @Override // X6FRs_4.KQgRr5e_0.EuDEkJe_12.KQgRr5e_0.PGPF6hQ_2, android.graphics.drawable.Drawable
        public void draw(Canvas canvas) {
            if (this.QxJ9d_1) {
                super.draw(canvas);
            }
        }

        @Override // X6FRs_4.KQgRr5e_0.EuDEkJe_12.KQgRr5e_0.PGPF6hQ_2, android.graphics.drawable.Drawable
        public void setHotspot(float f, float f2) {
            if (this.QxJ9d_1) {
                super.setHotspot(f, f2);
            }
        }

        @Override // X6FRs_4.KQgRr5e_0.EuDEkJe_12.KQgRr5e_0.PGPF6hQ_2, android.graphics.drawable.Drawable
        public void setHotspotBounds(int i, int i2, int i3, int i4) {
            if (this.QxJ9d_1) {
                super.setHotspotBounds(i, i2, i3, i4);
            }
        }

        @Override // X6FRs_4.KQgRr5e_0.EuDEkJe_12.KQgRr5e_0.PGPF6hQ_2, android.graphics.drawable.Drawable
        public boolean setState(int[] iArr) {
            if (this.QxJ9d_1) {
                return super.setState(iArr);
            }
            return false;
        }

        @Override // X6FRs_4.KQgRr5e_0.EuDEkJe_12.KQgRr5e_0.PGPF6hQ_2, android.graphics.drawable.Drawable
        public boolean setVisible(boolean z, boolean z2) {
            if (this.QxJ9d_1) {
                return super.setVisible(z, z2);
            }
            return false;
        }
    }

    /* compiled from: DropDownListView.java */
    /* loaded from: classes.dex */
    public class QxJ9d_1 implements Runnable {
        public QxJ9d_1() {
        }

        public void KQgRr5e_0() {
            LGe8pk_15 lGe8pk_15 = LGe8pk_15.this;
            lGe8pk_15.f714KQgRr5e_0 = null;
            lGe8pk_15.removeCallbacks(this);
        }

        public void QxJ9d_1() {
            LGe8pk_15.this.post(this);
        }

        @Override // java.lang.Runnable
        public void run() {
            LGe8pk_15 lGe8pk_15 = LGe8pk_15.this;
            lGe8pk_15.f714KQgRr5e_0 = null;
            lGe8pk_15.drawableStateChanged();
        }
    }

    public LGe8pk_15(Context context, boolean z) {
        super(context, null, X6FRs_4.KQgRr5e_0.KQgRr5e_0.dropDownListViewStyle);
        this.f715KQgRr5e_0 = new Rect();
        this.KQgRr5e_0 = 0;
        this.QxJ9d_1 = 0;
        this.PGPF6hQ_2 = 0;
        this.f3162Mqv2r_3 = 0;
        this.f718PGPF6hQ_2 = z;
        setCacheColorHint(0);
        try {
            Field declaredField = AbsListView.class.getDeclaredField("mIsChildViewEnabled");
            this.f716KQgRr5e_0 = declaredField;
            declaredField.setAccessible(true);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }
    }

    private void setSelectorEnabled(boolean z) {
        KQgRr5e_0 kQgRr5e_0 = this.f713KQgRr5e_0;
        if (kQgRr5e_0 != null) {
            kQgRr5e_0.KQgRr5e_0(z);
        }
    }

    public int KQgRr5e_0(int i, int i2, int i3, int i4, int i5) {
        int makeMeasureSpec;
        int listPaddingTop = getListPaddingTop();
        int listPaddingBottom = getListPaddingBottom();
        getListPaddingLeft();
        getListPaddingRight();
        int dividerHeight = getDividerHeight();
        Drawable divider = getDivider();
        ListAdapter adapter = getAdapter();
        if (adapter == null) {
            return listPaddingTop + listPaddingBottom;
        }
        int i6 = listPaddingTop + listPaddingBottom;
        dividerHeight = (dividerHeight <= 0 || divider == null) ? 0 : 0;
        int count = adapter.getCount();
        View view = null;
        int i7 = 0;
        int i8 = 0;
        int i9 = 0;
        while (i7 < count) {
            int itemViewType = adapter.getItemViewType(i7);
            if (itemViewType != i8) {
                view = null;
                i8 = itemViewType;
            }
            view = adapter.getView(i7, view, this);
            ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
            if (layoutParams == null) {
                layoutParams = generateDefaultLayoutParams();
                view.setLayoutParams(layoutParams);
            }
            int i10 = layoutParams.height;
            if (i10 > 0) {
                makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(i10, 1073741824);
            } else {
                makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, 0);
            }
            view.measure(i, makeMeasureSpec);
            view.forceLayout();
            if (i7 > 0) {
                i6 += dividerHeight;
            }
            i6 += view.getMeasuredHeight();
            if (i6 >= i4) {
                return (i5 < 0 || i7 <= i5 || i9 <= 0 || i6 == i4) ? i4 : i9;
            }
            if (i5 >= 0 && i7 >= i5) {
                i9 = i6;
            }
            i7++;
        }
        return i6;
    }

    public final void QxJ9d_1() {
        Drawable selector = getSelector();
        if (selector != null && m404KQgRr5e_0() && isPressed()) {
            selector.setState(getDrawableState());
        }
    }

    @Override // android.widget.ListView, android.widget.AbsListView, android.view.ViewGroup, android.view.View
    public void dispatchDraw(Canvas canvas) {
        KQgRr5e_0(canvas);
        super.dispatchDraw(canvas);
    }

    @Override // android.widget.AbsListView, android.view.ViewGroup, android.view.View
    public void drawableStateChanged() {
        if (this.f714KQgRr5e_0 != null) {
            return;
        }
        super.drawableStateChanged();
        setSelectorEnabled(true);
        QxJ9d_1();
    }

    @Override // android.view.ViewGroup, android.view.View
    public boolean hasFocus() {
        return this.f718PGPF6hQ_2 || super.hasFocus();
    }

    @Override // android.view.View
    public boolean hasWindowFocus() {
        return this.f718PGPF6hQ_2 || super.hasWindowFocus();
    }

    @Override // android.view.View
    public boolean isFocused() {
        return this.f718PGPF6hQ_2 || super.isFocused();
    }

    @Override // android.view.View
    public boolean isInTouchMode() {
        return (this.f718PGPF6hQ_2 && this.f719QxJ9d_1) || super.isInTouchMode();
    }

    @Override // android.widget.ListView, android.widget.AbsListView, android.widget.AdapterView, android.view.ViewGroup, android.view.View
    public void onDetachedFromWindow() {
        this.f714KQgRr5e_0 = null;
        super.onDetachedFromWindow();
    }

    @Override // android.view.View
    public boolean onHoverEvent(MotionEvent motionEvent) {
        if (Build.VERSION.SDK_INT < 26) {
            return super.onHoverEvent(motionEvent);
        }
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 10 && this.f714KQgRr5e_0 == null) {
            QxJ9d_1 qxJ9d_1 = new QxJ9d_1();
            this.f714KQgRr5e_0 = qxJ9d_1;
            qxJ9d_1.QxJ9d_1();
        }
        boolean onHoverEvent = super.onHoverEvent(motionEvent);
        if (actionMasked != 9 && actionMasked != 7) {
            setSelection(-1);
        } else {
            int pointToPosition = pointToPosition((int) motionEvent.getX(), (int) motionEvent.getY());
            if (pointToPosition != -1 && pointToPosition != getSelectedItemPosition()) {
                View childAt = getChildAt(pointToPosition - getFirstVisiblePosition());
                if (childAt.isEnabled()) {
                    setSelectionFromTop(pointToPosition, childAt.getTop() - getTop());
                }
                QxJ9d_1();
            }
        }
        return onHoverEvent;
    }

    @Override // android.widget.AbsListView, android.view.View
    public boolean onTouchEvent(MotionEvent motionEvent) {
        if (motionEvent.getAction() == 0) {
            this.f3163X6FRs_4 = pointToPosition((int) motionEvent.getX(), (int) motionEvent.getY());
        }
        QxJ9d_1 qxJ9d_1 = this.f714KQgRr5e_0;
        if (qxJ9d_1 != null) {
            qxJ9d_1.KQgRr5e_0();
        }
        return super.onTouchEvent(motionEvent);
    }

    public void setListSelectionHidden(boolean z) {
        this.f719QxJ9d_1 = z;
    }

    @Override // android.widget.AbsListView
    public void setSelector(Drawable drawable) {
        KQgRr5e_0 kQgRr5e_0 = drawable != null ? new KQgRr5e_0(drawable) : null;
        this.f713KQgRr5e_0 = kQgRr5e_0;
        super.setSelector(kQgRr5e_0);
        Rect rect = new Rect();
        if (drawable != null) {
            drawable.getPadding(rect);
        }
        this.KQgRr5e_0 = rect.left;
        this.QxJ9d_1 = rect.top;
        this.PGPF6hQ_2 = rect.right;
        this.f3162Mqv2r_3 = rect.bottom;
    }

    public final void QxJ9d_1(int i, View view) {
        Drawable selector = getSelector();
        boolean z = (selector == null || i == -1) ? false : true;
        if (z) {
            selector.setVisible(false, false);
        }
        KQgRr5e_0(i, view);
        if (z) {
            Rect rect = this.f715KQgRr5e_0;
            float exactCenterX = rect.exactCenterX();
            float exactCenterY = rect.exactCenterY();
            selector.setVisible(getVisibility() == 0, false);
            X6FRs_4.IMuAHx_6.IFxWkV_5.XnFJ5_9.KQgRr5e_0.KQgRr5e_0(selector, exactCenterX, exactCenterY);
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:7:0x000c, code lost:
        if (r0 != 3) goto L7;
     */
    /* JADX WARN: Removed duplicated region for block: B:22:0x0048 A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:25:0x004f  */
    /* JADX WARN: Removed duplicated region for block: B:29:0x0065  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public boolean KQgRr5e_0(MotionEvent motionEvent, int i) {
        boolean z;
        boolean z2;
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 1) {
            z = false;
        } else if (actionMasked == 2) {
            z = true;
        }
        int findPointerIndex = motionEvent.findPointerIndex(i);
        if (findPointerIndex >= 0) {
            int x = (int) motionEvent.getX(findPointerIndex);
            int y = (int) motionEvent.getY(findPointerIndex);
            int pointToPosition = pointToPosition(x, y);
            if (pointToPosition != -1) {
                View childAt = getChildAt(pointToPosition - getFirstVisiblePosition());
                KQgRr5e_0(childAt, pointToPosition, x, y);
                if (actionMasked == 1) {
                    KQgRr5e_0(childAt, pointToPosition);
                }
                z2 = false;
                z = true;
                if (z) {
                }
                KQgRr5e_0();
                if (z) {
                }
                return z;
            }
            z2 = true;
            if (z || z2) {
                KQgRr5e_0();
            }
            if (z) {
                if (this.f712KQgRr5e_0 == null) {
                    this.f712KQgRr5e_0 = new X6FRs_4.IMuAHx_6.WwEq_13.IFxWkV_5(this);
                }
                this.f712KQgRr5e_0.KQgRr5e_0(true);
                this.f712KQgRr5e_0.onTouch(this, motionEvent);
            } else {
                X6FRs_4.IMuAHx_6.WwEq_13.IFxWkV_5 iFxWkV_5 = this.f712KQgRr5e_0;
                if (iFxWkV_5 != null) {
                    iFxWkV_5.KQgRr5e_0(false);
                }
            }
            return z;
        }
        z2 = false;
        z = false;
        if (z) {
        }
        KQgRr5e_0();
        if (z) {
        }
        return z;
    }

    public final void KQgRr5e_0(View view, int i) {
        performItemClick(view, i, getItemIdAtPosition(i));
    }

    public final void KQgRr5e_0(Canvas canvas) {
        Drawable selector;
        if (this.f715KQgRr5e_0.isEmpty() || (selector = getSelector()) == null) {
            return;
        }
        selector.setBounds(this.f715KQgRr5e_0);
        selector.draw(canvas);
    }

    public final void KQgRr5e_0(int i, View view, float f, float f2) {
        QxJ9d_1(i, view);
        Drawable selector = getSelector();
        if (selector == null || i == -1) {
            return;
        }
        X6FRs_4.IMuAHx_6.IFxWkV_5.XnFJ5_9.KQgRr5e_0.KQgRr5e_0(selector, f, f2);
    }

    public final void KQgRr5e_0(int i, View view) {
        Rect rect = this.f715KQgRr5e_0;
        rect.set(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
        rect.left -= this.KQgRr5e_0;
        rect.top -= this.QxJ9d_1;
        rect.right += this.PGPF6hQ_2;
        rect.bottom += this.f3162Mqv2r_3;
        try {
            boolean z = this.f716KQgRr5e_0.getBoolean(this);
            if (view.isEnabled() != z) {
                this.f716KQgRr5e_0.set(this, Boolean.valueOf(!z));
                if (i != -1) {
                    refreshDrawableState();
                }
            }
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }

    public final void KQgRr5e_0() {
        this.f717Mqv2r_3 = false;
        setPressed(false);
        drawableStateChanged();
        View childAt = getChildAt(this.f3163X6FRs_4 - getFirstVisiblePosition());
        if (childAt != null) {
            childAt.setPressed(false);
        }
        X6FRs_4.IMuAHx_6.EuDEkJe_12.G83uNX_24 g83uNX_24 = this.f711KQgRr5e_0;
        if (g83uNX_24 != null) {
            g83uNX_24.m216KQgRr5e_0();
            this.f711KQgRr5e_0 = null;
        }
    }

    public final void KQgRr5e_0(View view, int i, float f, float f2) {
        View childAt;
        this.f717Mqv2r_3 = true;
        if (Build.VERSION.SDK_INT >= 21) {
            drawableHotspotChanged(f, f2);
        }
        if (!isPressed()) {
            setPressed(true);
        }
        layoutChildren();
        int i2 = this.f3163X6FRs_4;
        if (i2 != -1 && (childAt = getChildAt(i2 - getFirstVisiblePosition())) != null && childAt != view && childAt.isPressed()) {
            childAt.setPressed(false);
        }
        this.f3163X6FRs_4 = i;
        float left = f - view.getLeft();
        float top = f2 - view.getTop();
        if (Build.VERSION.SDK_INT >= 21) {
            view.drawableHotspotChanged(left, top);
        }
        if (!view.isPressed()) {
            view.setPressed(true);
        }
        KQgRr5e_0(i, view, f, f2);
        setSelectorEnabled(false);
        refreshDrawableState();
    }

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