youlookwhat / ByRecyclerView

🔥 RecyclerView 下拉刷新、上拉松手/自动加载更多、item点击/长按、item局部刷新、头布局/尾布局/状态布局、万能分割线、Skeleton骨架图、极简adapter、嵌套滑动置顶
https://youlookwhat.github.io/ByRecyclerView
Apache License 2.0
798 stars 139 forks source link

给大牛ByRecyclerView提建议 #74

Closed wchcom closed 1 year ago

wchcom commented 1 year ago

建议新增removeEmptyView方法或removeStateView方法,使用场景非常多

youlookwhat commented 1 year ago

是不是项目中的 setPageData() 这个方法,能满足吗。如果data有数据就会自动移除

    public void setPageData(boolean isFirstPage, List<T> data, View emptyView) {
        if (this.mRecyclerView != null) {
            if (isFirstPage) {
                if (data != null && data.size() > 0) {
                    this.mRecyclerView.setStateViewEnabled(false);
                    this.mRecyclerView.setLoadMoreEnabled(true);
                    this.setNewData(data);
                } else {
                    if (emptyView != null) {
                        this.mRecyclerView.setStateView(emptyView);
                    }

                    this.mRecyclerView.setLoadMoreEnabled(false);
                    this.setNewData((List)null);
                }
            } else if (data != null && data.size() > 0) {
                this.addData(data);
                this.mRecyclerView.loadMoreComplete();
            } else {
                this.mRecyclerView.loadMoreEnd();
            }

        }
    }
wchcom commented 1 year ago

建议更灵活点,用自已的适配器时候也可以通过byRecyclerView删除removeEmptyView和removeStateView

wchcom commented 1 year ago

byRecyclerView能添加EmptyView和StateView但是没有删除就不灵活了

youlookwhat commented 1 year ago

你试试这个方法:

byRecyclerView.setStateViewEnabled(false,true);

感觉可以,里面有移除的处理。 EmptyView和StateView其实走的一个方法,都可以用上面的那个方法试试

youlookwhat commented 1 year ago

@wchcom 可以满足你的需求吗

wchcom commented 1 year ago

可以满足能删除,但是你不跟我说我也不知道这样就能删除EmptyView和StateView,我之前一直在找删除EmptyView和StateView的方法

youlookwhat commented 1 year ago

是的,这需要看代码才行,一眼比较难找到。因为需要兼顾显示与关闭,所以取了那个方法。

youlookwhat commented 1 year ago

先关了,有问题再提了哈~