bind

open fun bind(@NonNull() holder: T)

Binds the current data to the given view. You should bind all fields including unset/emptyfields to ensure proper recycling.

open fun bind(@NonNull() holder: T, @NonNull() payloads: List<Any>)

Similar to bind, but provides a non null, non empty list of payloadsdescribing what changed. This is the payloads list specified in the adapter's notifyItemChangedmethod. This is a useful optimization to allow you to only change part of a view instead ofupdating the whole thing, which may prevent unnecessary layout calls. If there are no payloadsthen bind is called instead. This will only be used if the model is used withan EpoxyAdapter

open fun bind(@NonNull() holder: T, @NonNull() previouslyBoundModel: EpoxyModel<out Any>)

Similar to bind, but provides a non null model which was previously bound tothis view. This will only be called if the model is used with an EpoxyController.

Parameters

previouslyBoundModel

This is a model with the same id that was previously bound. You cancompare this previous model with the current one to see exactlywhat changed.

This model and the previously bound model are guaranteed to havethe same id, but will not necessarily be of the same type dependingon your implementation of buildModels.With common usage patterns of Epoxy they should be the same type,and will only differ if you are using different model classes withthe same id.

Comparing the newly bound model with the previous model allows youto be more intelligent when binding your view. This may help youoptimize view binding, or make it easier to work with animations.

If the new model and the previous model have the same view type(given by getViewType), and if you are usingthe default ReyclerView item animator, the same view will bereused. This means that you only need to update the view to reflectthe data that changed. If you are using a custom item animator thenthe view will be the same if the animator returns true incanReuseUpdatedViewHolder.

This previously bound model is taken as a payload from the diffingprocess, and follows the same general conditions for allrecyclerview change payloads.