分页库-无法停止加载项目 [英] Paging library - Can't stop loading items

查看:75
本文介绍了分页库-无法停止加载项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Paging库直接从网络中加载日期.我是否必须实施逻辑以停止获取数据?就我而言,可能是收到的项目数少于页面大小时.目前,当我到达列表末尾时,lib会继续加载新页面.

I'm using Paging library to load date directly from network. Do I have to implement logic to stop fetching data? In my case, that can be when received item count is lower than page size. Currently when I reach end of list lib keeps loading new pages.

推荐答案

从理论上讲,PageKeyedDataSource具有结果回调,

Theoretically, PageKeyedDataSource has a result callback,

PageKeyedDataSource.LoadCallback

并且有一个 onResult 方法,文档说的是

And that has an onResult method, where the docs says

如果没有更多数据要加载,则传递一个空列表.

Pass an empty list if there is no more data to load.

传递用于下一页的键以加载到相邻页面键.例如,如果您已在loadBefore(LoadParams,LoadCallback)中加载了页面,则传递上一页的键;如果已加载的页面是第一页,则传递null.如果在loadAfter(LoadParams,LoadCallback)中,则为下一页传递密钥;如果已加载的页面为最后一页,则为null.

Pass the key for the subsequent page to load to adjacentPageKey. For example, if you've loaded a page in loadBefore(LoadParams, LoadCallback), pass the key for the previous page, or null if the loaded page is the first. If in loadAfter(LoadParams, LoadCallback), pass the key for the next page, or null if the loaded page is the last.

因此它说您应该传递一个空列表,并为相邻的页面密钥传递 null ,它应该可以工作.

So it says you should pass an empty list, and null for adjacent page key, and it should work.

这篇关于分页库-无法停止加载项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆