-
Notifications
You must be signed in to change notification settings - Fork 727
Description
We have a list of items that come from the database. Based on their date we generate header models that we insert in the list using addModels
.
We scroll for a bit, up to a point where the last item of the first page is at half of the screen (this means the second page will be loaded). Now we update some item in the database to trigger a new PagedList
. Upon submitting this new PagedList
to epoxy, AsyncPagedListDiffer
will diff the items and update the list. This new list will not start at position 0 (that's how paging library works). This means that the initial items will be removed from the RecyclerView
. Without adding extra models, the RecyclerView
will be able to keep it's position. You will see exactly the same items on screen. As soon as we add extra items, the RecyclerView
isn't able to keep the same position on screen and we see a jump when it removes the initial items.
Now I have two untested theories for this:
-
It's because only the item list gets diffed so the
RecyclerView
doesn't account for the extra items height (is this right?). In that case we have to diff the model list instead of the item list. -
It's because of:
override fun onModelBound(
holder: EpoxyViewHolder,
boundModel: EpoxyModel<*>,
position: Int,
previouslyBoundModel: EpoxyModel<*>?
) {
// TODO the position may not be a good value if there are too many injected items.
modelCache.loadAround(position)
}
Somehow, the controller would have to take the additional injected items into account.
I'm more inclined towards theory 1. But I don't know if the premise for that option is valid.
I'll try to build a small project to replicate the issue. Maybe @yigit can shed some light on this?
Thanks