Android PagedList updates

前端 未结 3 1061
失恋的感觉
失恋的感觉 2021-02-13 11:02

My question is how to update item in PagedList?

In my case, there are ListActivity and DetailsActivity. List activity is using Paging component to get posts from network

3条回答
  •  梦如初夏
    2021-02-13 11:45

    PagedListAdapter uses a DiffUtil.ItemCallback that will only update an existing item if the it considers it a "new" item. It seems to me that you do need to go to the server in order to get the new view count, but also you do not want unaffected items to redraw. This can be prevented by adding the view count property to the DiffUtil.ItemCallback to determine what a new item is. Items with a new view count will be redrawn, others won't.

    I am assuming that the original request that retrieves the first list returns objects that have a viewsCount field in them.

提交回复
热议问题