没有收到有关PagedList更新的通知 [英] Not getting notified on PagedList updates

查看:53
本文介绍了没有收到有关PagedList更新的通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用中使用了 PagedList 库.

I am using the PagedList library in my app.

使用 PagedListAdapter ,所有操作均按预期进行.但是,我找不到如何获得回调并收到有关PagedList已更新的通知.

It all works as expected, using the PagedListAdapter. However, I am not able to find how I can get a callback and be notified that the PagedList has been updated.

在列表的 ItemKeyedDataSource 用于从列表中获取列表数据网络.此时,将调用PagedListAdapter的 submitList ,提供长度为0的PagedList.当DataSource从网络中获取数据时,将执行其 callback.onResult().列表的UI会更新,显示提取的项目.但是,这没有调用 submitList 方法,并且由于没有调用 onCurrentListChanged ,所以我没有在适配器中找到通知该更新的方法.如何将此类更改通知适配器?

At list's ItemKeyedDataSource is used to fetch the list's data from the network. At that point, the PagedListAdapter's submitList is called, providing a PagedList of length 0. When the DataSource has fetched the data from the network, its callback.onResult() is executed and the list's UI is updated showing the fetched items. However, this does not call the submitList method, and I have not found a way to be notified in the adapter of this update, as the onCurrentListChanged is neither called. How can the Adapter be notified of such changes?

谢谢:)

推荐答案

您可以使用PagedList.addWeakCallback.您可以将PagedList.Callback传递给它,并收听诸如onInsertedonChangedonRemoved的事件.可以在以下 answer

You can use PagedList.addWeakCallback. You can pass a PagedList.Callback to it and listen to events such as onInserted, onChanged or onRemoved. More detail can be fofund in this answer

这篇关于没有收到有关PagedList更新的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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