分页库 - 无法停止加载项目

Paging library - Can't stop loading items

我正在使用 Paging 库直接从网络加载日期。我是否必须实施停止获取数据的逻辑?在我的例子中,这可能是当收到的项目数低于页面大小时。目前,当我到达列表末尾时,库会不断加载新页面。

理论上PageKeyedDataSource是有结果回调的,

PageKeyedDataSource.LoadCallback

它有一个 onResult 方法,文档说

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

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 作为相邻的页面键,它应该可以工作。