我想在下拉时加载最后一章并在上拉时加载下一章,但是遇到一些问题,当我进入第一页时,然后我拉起来加载最后一章,recyclelerview不调用onScrolled。但如果我向下拉小距离然后向下拉,我可以得到结果,这是我的代码:
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled (RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if(dy < 0 && mLayoutManager.findFirstCompletelyVisibleItemPosition() == 0) {
getNextChapter();
}
if(dy > 0 &&
mLayoutManager.findLastCompletelyVisibleItemPosition() ==
mAdapter.getItemCount() - 1) {
getNextChapter();
}
Logger.i("onScrolled:" + dy);
}
});