-
public abstract class EpoxyModelWithHolder<T extends EpoxyHolder> extends EpoxyModel<T>
A version of com.airbnb.epoxy.EpoxyModel that allows you to use a view holder pattern instead of a specific view when binding to your model.
-
-
Constructor Summary
Constructors Constructor Description EpoxyModelWithHolder()EpoxyModelWithHolder(long id)
-
Method Summary
Modifier and Type Method Description voidbind(@NonNull() T holder)Binds the current data to the given view. voidbind(@NonNull() T holder, @NonNull() List<Object> payloads)Similar to bind, but provides a non null, non empty list of payloadsdescribing what changed. voidbind(@NonNull() T holder, @NonNull() EpoxyModel<out Object> previouslyBoundModel)Similar to bind, but provides a non null model which was previously bound tothis view. voidunbind(@NonNull() T holder)Called when the view bound to this model is recycled. voidonVisibilityStateChanged(int visibilityState, @NonNull() T holder)TODO link to the wiki voidonVisibilityChanged(@FloatRange(from = 0, to = 100) float percentVisibleHeight, @FloatRange(from = 0, to = 100) float percentVisibleWidth, @Px() int visibleHeight, @Px() int visibleWidth, @NonNull() T holder)TODO link to the wiki booleanonFailedToRecycleView(T holder)Called if the RecyclerView failed to recycle this model's view. voidonViewAttachedToWindow(T holder)Called when this model's view is attached to the window. voidonViewDetachedFromWindow(T holder)Called when this model's view is detached from the the window. -
Methods inherited from class com.airbnb.epoxy.EpoxyModel
addIf, addIf, addTo, bind, bind, bind, buildView, equals, getLayout, getSpanSize, hashCode, hide, id, id, id, id, id, id, id, isShown, layout, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onVisibilityChanged, onVisibilityStateChanged, preBind, reset, shouldSaveViewState, show, show, spanSize, spanSizeOverride, toString, unbind -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
bind
void bind(@NonNull() T holder)
Binds the current data to the given view. You should bind all fields including unset/emptyfields to ensure proper recycling.
-
bind
void bind(@NonNull() T holder, @NonNull() List<Object> payloads)
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
-
bind
void bind(@NonNull() T holder, @NonNull() EpoxyModel<out Object> previouslyBoundModel)
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.
-
unbind
void unbind(@NonNull() T holder)
Called when the view bound to this model is recycled. Subclasses can override this if theirview should release resources when it's recycled.
Note that bind can be called multiple times without an unbind call in betweenif the view has remained on screen to be reused across item changes. This means that you shouldnot rely on unbind to clear a view or model's state before bind is called again.
-
onVisibilityStateChanged
void onVisibilityStateChanged(int visibilityState, @NonNull() T holder)
TODO link to the wiki
-
onVisibilityChanged
void onVisibilityChanged(@FloatRange(from = 0, to = 100) float percentVisibleHeight, @FloatRange(from = 0, to = 100) float percentVisibleWidth, @Px() int visibleHeight, @Px() int visibleWidth, @NonNull() T holder)
TODO link to the wiki
-
onFailedToRecycleView
boolean onFailedToRecycleView(T holder)
Called if the RecyclerView failed to recycle this model's view. You can take this opportunityto clear the animation(s) that affect the View's transient state and return
trueso that the View can be recycled. Keep in mind that the View in question is already removedfrom the RecyclerView.
-
onViewAttachedToWindow
void onViewAttachedToWindow(T holder)
Called when this model's view is attached to the window.
-
onViewDetachedFromWindow
void onViewDetachedFromWindow(T holder)
Called when this model's view is detached from the the window.
-
-
-
-