我已将页面大小设置为 10,观察者中的页面大小给出了正确的大小,但数据库(ROOM)中的所有项目都已加载到视图持有者中
边界回调onItemAtEndLoaded正在使用数据库中的最后一个项目进行调用。
这是我的配置:
public LiveData<PagedList<Design>> getDesignList(List<String> types, String idCode){
DataSource.Factory<Integer, Design> factory = mRepository.getDesigns(types, idCode);
PagedList.Config pagedListConfig =
(new PagedList.Config.Builder())
.setEnablePlaceholders(false)
.setInitialLoadSizeHint(10)
.setPageSize(10)
.build();
return new LivePagedListBuilder<>(factory, pagedListConfig)
.setBoundaryCallback(**boundCallBack**)
.setFetchExecutor(mRepository.mIoExecutor)
.build();
}
Run Code Online (Sandbox Code Playgroud)
存储库(mRepository.getDesigns):
public DataSource.Factory<Integer, Design> getDesigns(List<String> types, String idCode) {
return designDao.getDesigns(types,idCode);
}
Run Code Online (Sandbox Code Playgroud)
Dao:(获取设计)
@Query("SELECT * FROM Design WHERE design_type IN (:types) AND id=:idCode ORDER BY design_id ASC")
DataSource.Factory<Integer, Design> getDesigns(List<String> types, String idCode);
Run Code Online (Sandbox Code Playgroud)
边界回调(boundCallBack):
public class BoundCall extends …Run Code Online (Sandbox Code Playgroud) android pagedlist android-room android-paging android-paging-library