下拉时setOnLoadMoreListener执行多次

shopListAdapter.loadMoreComplete();放错地方了,不应该放在请求数据结束的时候,应该放在shopListAdapter.addData(itemList);上面

完整的:

GoodsListAdapter goodsListAdapter;
goodsListAdapter = new GoodsListAdapter(null);
goodsListAdapter.setEmptyView(new YJGEmptyView(getContext(), YJGEmptyView.TYPE_ORDER));
goodsListAdapter.setLoadMoreView(new YJGLoadMoreView());
goodsListAdapter.setEnableLoadMore(false);
goodsListAdapter.setOnLoadMoreListener(() -> {
            getSearchGoodsList();
});
rv_goods_list.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
rv_goods_list.setAdapter(goodsListAdapter);


getSearchGoodsList(){
mTotalCount = searchResult.getTotalCount();
setMultiItem(listObj);
}

public void setMultiItem(List itemList) {
        if(mCurPageNum == 1){
            goodsListAdapter.setNewData(itemList);
        }else {
            goodsListAdapter.loadMoreComplete();
            goodsListAdapter.addData(itemList);
        }
        checkNoMoreData();
        mCurPageNum++;
    }

private void checkNoMoreData() {
        if (mCurPageNum * 10 >= mTotalCount) {
            goodsListAdapter.loadMoreEnd();
        } else {
            goodsListAdapter.setEnableLoadMore(true);
        }
    }

另外,到底部了,setLoadMoreView的底部样式没有出现,需要设置goodsListAdapter.loadMoreEnd();,默认是false,为true的时候,是不会出现的

你可能感兴趣的:(下拉时setOnLoadMoreListener执行多次)