Intended to support two use cases without resorting to reflection:
"Load more" button
This was requested by our designers to leave room for footer content rather than infinite scrolling. Disabling automatic loading can be done just by removing call to super. And to load the next page, we just use modelCache.loadAround():
override fun onModelBound(holder: EpoxyViewHolder, boundModel: EpoxyModel<*>, position: Int, previouslyBoundModel: EpoxyModel<*>?) {
// Disable automatically loading pages by removing call to super
// super.onModelBound(holder, boundModel, position, previouslyBoundModel)
}
override fun buildItemModel(currentPosition: Int, item: I?): EpoxyModel<*> {
if (item == null) {
return LoadMoreBindingModel_().apply {
id("load more")
onClick { _ -> modelCache.loadAround(currentPosition) }
}
}
...
}
Invalidate item models
An item model may depends on both paging data from remote and some view state. We're able to manually rebuild EpoxyModels for individual items using the modelCache.updateCallback.onChanged().
Intended to support two use cases without resorting to reflection:
"Load more" button
This was requested by our designers to leave room for footer content rather than infinite scrolling. Disabling automatic loading can be done just by removing call to super. And to load the next page, we just use
modelCache.loadAround()
:Invalidate item models
An item model may depends on both paging data from remote and some view state. We're able to manually rebuild EpoxyModels for individual items using the
modelCache.updateCallback.onChanged()
.