ChaosLeung / EasyChat

毕业设计项目,帮朋友做的一个聊天应用
3 stars 1 forks source link

ArrayRecyclerAdapter 写的非常好,只是我在用的时候遇到了个问题,就是 RecyclerView的滑到底部加载更多不好用了 #1

Open tosslife opened 9 years ago

tosslife commented 9 years ago
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);

    LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
    visibleItemCount = recyclerView.getChildCount();
    totalItemCount = recyclerView.getLayoutManager().getItemCount();
    firstVisibleItem = layoutManager.findFirstVisibleItemPosition();

    if (loading) {
        if (totalItemCount > previousTotal) {
            previousTotal = totalItemCount;
            loading = false;
        }
    }

    if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) {
        loadMoreCallBack.onLoadMore();
        loading = true;
    }

}
ChaosLeung commented 8 years ago

@tosslife 不懂你意思,再者你这部分代码跟 adapter 没多大关系吧?