package c.a.g;

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 com.ifpdos.multiuser.R;
import java.lang.reflect.Field;

/* JADX INFO: loaded from: classes.dex */
public class u extends ListView {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Rect f5071b;

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

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

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

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

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public Field f5077h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public a f5078i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public boolean f5079j;
    public boolean k;
    public boolean l;
    public c.c.j.c m;
    public b n;

    public static class a extends c.a.e.a.a {

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

        public a(Drawable drawable) {
            super(drawable);
            this.f5080c = true;
        }

        @Override // c.a.e.a.a, android.graphics.drawable.Drawable
        public void draw(Canvas canvas) {
            if (this.f5080c) {
                this.f4781b.draw(canvas);
            }
        }

        @Override // c.a.e.a.a, android.graphics.drawable.Drawable
        public void setHotspot(float f2, float f3) {
            if (this.f5080c) {
                this.f4781b.setHotspot(f2, f3);
            }
        }

        @Override // c.a.e.a.a, android.graphics.drawable.Drawable
        public void setHotspotBounds(int i2, int i3, int i4, int i5) {
            if (this.f5080c) {
                this.f4781b.setHotspotBounds(i2, i3, i4, i5);
            }
        }

        @Override // c.a.e.a.a, android.graphics.drawable.Drawable
        public boolean setState(int[] iArr) {
            if (this.f5080c) {
                return this.f4781b.setState(iArr);
            }
            return false;
        }

        @Override // c.a.e.a.a, android.graphics.drawable.Drawable
        public boolean setVisible(boolean z, boolean z2) {
            if (this.f5080c) {
                return super.setVisible(z, z2);
            }
            return false;
        }
    }

    public class b implements Runnable {
        public b() {
        }

        @Override // java.lang.Runnable
        public void run() {
            u uVar = u.this;
            uVar.n = null;
            uVar.drawableStateChanged();
        }
    }

    public u(Context context, boolean z) {
        super(context, null, R.attr.dropDownListViewStyle);
        this.f5071b = new Rect();
        this.f5072c = 0;
        this.f5073d = 0;
        this.f5074e = 0;
        this.f5075f = 0;
        this.k = z;
        setCacheColorHint(0);
        try {
            Field declaredField = AbsListView.class.getDeclaredField("mIsChildViewEnabled");
            this.f5077h = declaredField;
            declaredField.setAccessible(true);
        } catch (NoSuchFieldException e2) {
            e2.printStackTrace();
        }
    }

    private void setSelectorEnabled(boolean z) {
        a aVar = this.f5078i;
        if (aVar != null) {
            aVar.f5080c = z;
        }
    }

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

    /* JADX WARN: Removed duplicated region for block: B:13:0x001f  */
    /* JADX WARN: Removed duplicated region for block: B:67:0x012a  */
    /* JADX WARN: Removed duplicated region for block: B:69:0x013f  */
    /* JADX WARN: Removed duplicated region for block: B:71:0x0144  */
    /* JADX WARN: Removed duplicated region for block: B:75:0x015a  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean b(android.view.MotionEvent r17, int r18) {
        /*
            Method dump skipped, instruction units count: 360
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: c.a.g.u.b(android.view.MotionEvent, int):boolean");
    }

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

    @Override // android.widget.ListView, android.widget.AbsListView, android.view.ViewGroup, android.view.View
    public void dispatchDraw(Canvas canvas) {
        Drawable selector;
        if (!this.f5071b.isEmpty() && (selector = getSelector()) != null) {
            selector.setBounds(this.f5071b);
            selector.draw(canvas);
        }
        super.dispatchDraw(canvas);
    }

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

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

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

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

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

    @Override // android.widget.ListView, android.widget.AbsListView, android.widget.AdapterView, android.view.ViewGroup, android.view.View
    public void onDetachedFromWindow() {
        this.n = 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.n == null) {
            b bVar = new b();
            this.n = bVar;
            post(bVar);
        }
        boolean zOnHoverEvent = super.onHoverEvent(motionEvent);
        if (actionMasked == 9 || actionMasked == 7) {
            int iPointToPosition = pointToPosition((int) motionEvent.getX(), (int) motionEvent.getY());
            if (iPointToPosition != -1 && iPointToPosition != getSelectedItemPosition()) {
                View childAt = getChildAt(iPointToPosition - getFirstVisiblePosition());
                if (childAt.isEnabled()) {
                    setSelectionFromTop(iPointToPosition, childAt.getTop() - getTop());
                }
                c();
            }
        } else {
            setSelection(-1);
        }
        return zOnHoverEvent;
    }

    @Override // android.widget.AbsListView, android.view.View
    public boolean onTouchEvent(MotionEvent motionEvent) {
        if (motionEvent.getAction() == 0) {
            this.f5076g = pointToPosition((int) motionEvent.getX(), (int) motionEvent.getY());
        }
        b bVar = this.n;
        if (bVar != null) {
            u uVar = u.this;
            uVar.n = null;
            uVar.removeCallbacks(bVar);
        }
        return super.onTouchEvent(motionEvent);
    }

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

    @Override // android.widget.AbsListView
    public void setSelector(Drawable drawable) {
        a aVar = drawable != null ? new a(drawable) : null;
        this.f5078i = aVar;
        super.setSelector(aVar);
        Rect rect = new Rect();
        if (drawable != null) {
            drawable.getPadding(rect);
        }
        this.f5072c = rect.left;
        this.f5073d = rect.top;
        this.f5074e = rect.right;
        this.f5075f = rect.bottom;
    }
}
