小红书.apk(点击下载) / b.java


package se.emilsjolander.stickylistheaders;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Build;
import android.view.View;
import android.widget.AbsListView;
import android.widget.ListView;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

/* compiled from: WrapperViewList */
public class b extends ListView {

    /* renamed from: a  reason: collision with root package name */
    public a f129455a;

    /* renamed from: b  reason: collision with root package name */
    public List<View> f129456b;

    /* renamed from: c  reason: collision with root package name */
    public int f129457c;

    /* renamed from: d  reason: collision with root package name */
    public Rect f129458d = new Rect();

    /* renamed from: e  reason: collision with root package name */
    public Field f129459e;

    /* renamed from: f  reason: collision with root package name */
    public boolean f129460f = true;

    /* renamed from: g  reason: collision with root package name */
    public boolean f129461g = false;

    /* compiled from: WrapperViewList */
    public interface a {
        void a(Canvas canvas);
    }

    public b(Context context) {
        super(context);
        try {
            Field declaredField = AbsListView.class.getDeclaredField("mSelectorRect");
            declaredField.setAccessible(true);
            this.f129458d = (Rect) declaredField.get(this);
            if (Build.VERSION.SDK_INT >= 14) {
                Field declaredField2 = AbsListView.class.getDeclaredField("mSelectorPosition");
                this.f129459e = declaredField2;
                declaredField2.setAccessible(true);
            }
        } catch (NoSuchFieldException e14) {
            e14.printStackTrace();
        } catch (IllegalArgumentException e15) {
            e15.printStackTrace();
        } catch (IllegalAccessException e16) {
            e16.printStackTrace();
        }
    }

    public final void a(View view) {
        if (this.f129456b == null) {
            this.f129456b = new ArrayList();
        }
        this.f129456b.add(view);
    }

    public void addFooterView(View view) {
        super.addFooterView(view);
        a(view);
    }

    public boolean b(View view) {
        List<View> list = this.f129456b;
        if (list == null) {
            return false;
        }
        return list.contains(view);
    }

    public int c() {
        int firstVisiblePosition = getFirstVisiblePosition();
        if (Build.VERSION.SDK_INT >= 11) {
            return firstVisiblePosition;
        }
        int i10 = 0;
        while (true) {
            if (i10 >= getChildCount()) {
                break;
            } else if (getChildAt(i10).getBottom() >= 0) {
                firstVisiblePosition += i10;
                break;
            } else {
                i10++;
            }
        }
        return (this.f129460f || getPaddingTop() <= 0 || firstVisiblePosition <= 0 || getChildAt(0).getTop() <= 0) ? firstVisiblePosition : firstVisiblePosition - 1;
    }

    public final int d() {
        Field field = this.f129459e;
        if (field == null) {
            for (int i10 = 0; i10 < getChildCount(); i10++) {
                if (getChildAt(i10).getBottom() == this.f129458d.bottom) {
                    return i10 + c();
                }
            }
            return -1;
        }
        try {
            return field.getInt(this);
        } catch (IllegalArgumentException e14) {
            e14.printStackTrace();
            return -1;
        } catch (IllegalAccessException e15) {
            e15.printStackTrace();
            return -1;
        }
    }

    public void dispatchDraw(Canvas canvas) {
        e();
        if (this.f129457c != 0) {
            canvas.save();
            Rect clipBounds = canvas.getClipBounds();
            clipBounds.top = this.f129457c;
            canvas.clipRect(clipBounds);
            super.dispatchDraw(canvas);
            canvas.restore();
        } else {
            super.dispatchDraw(canvas);
        }
        this.f129455a.a(canvas);
    }

    public final void e() {
        int d14;
        if (!this.f129458d.isEmpty() && (d14 = d()) >= 0) {
            View childAt = getChildAt(d14 - c());
            if (childAt instanceof WrapperView) {
                WrapperView wrapperView = (WrapperView) childAt;
                this.f129458d.top = wrapperView.getTop() + wrapperView.mItemTop;
            }
        }
    }

    public void f(boolean z14) {
        this.f129461g = z14;
    }

    public void g(a aVar) {
        this.f129455a = aVar;
    }

    public void h(int i10) {
        this.f129457c = i10;
    }

    public void layoutChildren() {
        if (!this.f129461g) {
            super.layoutChildren();
        }
    }

    public boolean performItemClick(View view, int i10, long j14) {
        if (view instanceof WrapperView) {
            view = ((WrapperView) view).mItem;
        }
        return super.performItemClick(view, i10, j14);
    }

    public boolean removeFooterView(View view) {
        if (!super.removeFooterView(view)) {
            return false;
        }
        this.f129456b.remove(view);
        return true;
    }

    public void setClipToPadding(boolean z14) {
        this.f129460f = z14;
        super.setClipToPadding(z14);
    }

    public void addFooterView(View view, Object obj, boolean z14) {
        super.addFooterView(view, obj, z14);
        a(view);
    }
}