-
- All Implemented Interfaces:
-
com.airbnb.epoxy.stickyheader.StickyHeaderCallbacks
public class SimpleEpoxyAdapter extends EpoxyAdapter
A non-abstract version of com.airbnb.epoxy.EpoxyAdapter that exposes all methods and models as public. Use this if you don't want to create your own adapter subclass and instead want to modify the adapter from elsewhere, such as from an activity.
-
-
Method Summary
Modifier and Type Method Description List<EpoxyModel<out Object>>getModels()voidenableDiffing()Enables support for automatically notifying model changes via notifyModelsChanged.If used, this should be called in the constructor, before any models are changed. voidnotifyModelsChanged()Intelligently notify item changes by comparing the current models list against theprevious so you don't have to micromanage notification calls yourself. BoundViewHoldersgetBoundViewHolders()Returns an object that manages the view holders currently bound to the RecyclerView. voidnotifyModelChanged(EpoxyModel<out Object> model)Notify that the given model has had its data changed. voidaddModels(Array<EpoxyModel<out Object>> modelsToAdd)Adds the models to the end of the models list and notifies that the items wereinserted. voidaddModels(Collection<out EpoxyModel<out Object>> modelsToAdd)Adds the models to the end of the models list and notifies that the items wereinserted. voidinsertModelBefore(EpoxyModel<out Object> modelToInsert, EpoxyModel<out Object> modelToInsertBefore)Inserts the given model before the other in the models list, and notifies that theitem was inserted. voidinsertModelAfter(EpoxyModel<out Object> modelToInsert, EpoxyModel<out Object> modelToInsertAfter)Inserts the given model after the other in the models list, and notifies that the itemwas inserted. voidremoveModel(EpoxyModel<out Object> model)If the given model exists it is removed and an item removal is notified. voidremoveAllModels()Removes all models voidremoveAllAfterModel(EpoxyModel<out Object> model)Removes all models after the given model, which must have already been added. voidshowModel(EpoxyModel<out Object> model, boolean show)Sets the visibility of the given model, and notifies that the item changed if the newvisibility is different from the previous. voidshowModel(EpoxyModel<out Object> model)Shows the given model, and notifies that the item changed if the item wasn't already shown. voidshowModels(Array<EpoxyModel<out Object>> models)Shows the given models, and notifies that each item changed if the item wasn't already shown. voidshowModels(boolean show, Array<EpoxyModel<out Object>> models)Sets the visibility of the given models, and notifies that the items changed if the newvisibility is different from the previous. voidshowModels(Iterable<EpoxyModel<out Object>> epoxyModels)Shows the given models, and notifies that each item changed if the item wasn't already shown. voidshowModels(Iterable<EpoxyModel<out Object>> epoxyModels, boolean show)Sets the visibility of the given models, and notifies that the items changed if the newvisibility is different from the previous. voidhideModel(EpoxyModel<out Object> model)Hides the given model, and notifies that the item changed if the item wasn't already hidden. voidhideModels(Iterable<EpoxyModel<out Object>> epoxyModels)Hides the given models, and notifies that each item changed if the item wasn't already hidden. voidhideModels(Array<EpoxyModel<out Object>> models)Hides the given models, and notifies that each item changed if the item wasn't already hidden. voidhideAllAfterModel(EpoxyModel<out Object> model)Hides all models currently located after the given model in the models list. List<EpoxyModel<out Object>>getAllModelsAfter(EpoxyModel<out Object> model)Returns a sub list of all items in models that occur after the given model. intgetModelPosition(EpoxyModel<out Object> model)Finds the position of the given model in the list. -
Methods inherited from class com.airbnb.epoxy.BaseEpoxyAdapter
getItemCount, getItemId, getItemViewType, getSpanCount, getSpanSizeLookup, isEmpty, isMultiSpan, isStickyHeader, onBindViewHolder, onBindViewHolder, onCreateViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onRestoreInstanceState, onSaveInstanceState, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, setSpanCount, setupStickyHeaderView, teardownStickyHeaderView -
Methods inherited from class androidx.recyclerview.widget.RecyclerView.Adapter
bindViewHolder, createViewHolder, findRelativeAdapterPositionIn, getItemCount, getItemId, getItemViewType, getStateRestorationPolicy, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onCreateViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, setStateRestorationPolicy, unregisterAdapterDataObserver -
Methods inherited from class com.airbnb.epoxy.stickyheader.StickyHeaderCallbacks
isStickyHeader, setupStickyHeaderView, teardownStickyHeaderView -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getModels
List<EpoxyModel<out Object>> getModels()
-
enableDiffing
void enableDiffing()
Enables support for automatically notifying model changes via notifyModelsChanged.If used, this should be called in the constructor, before any models are changed.
-
notifyModelsChanged
void notifyModelsChanged()
Intelligently notify item changes by comparing the current models list against theprevious so you don't have to micromanage notification calls yourself. This may beprohibitively slow for large model lists (in the hundreds), in which case consider doingnotification calls yourself. If you use this, all your view models must implement and equals to completely identify theirstate, so that changes to a model's content can be detected. Before using this you must enableit with enableDiffing, since keeping track of the model state adds extra computationtime to all other data change notifications.
-
getBoundViewHolders
BoundViewHolders getBoundViewHolders()
Returns an object that manages the view holders currently bound to the RecyclerView. Thisobject is mainly used by the base Epoxy adapter to save view states, but you may find it usefulto help access views or models currently shown in the RecyclerView.
-
notifyModelChanged
void notifyModelChanged(EpoxyModel<out Object> model)
Notify that the given model has had its data changed. It should only be called if the modelretained the same position.
-
addModels
void addModels(Array<EpoxyModel<out Object>> modelsToAdd)
Adds the models to the end of the models list and notifies that the items wereinserted.
-
addModels
void addModels(Collection<out EpoxyModel<out Object>> modelsToAdd)
Adds the models to the end of the models list and notifies that the items wereinserted.
-
insertModelBefore
void insertModelBefore(EpoxyModel<out Object> modelToInsert, EpoxyModel<out Object> modelToInsertBefore)
Inserts the given model before the other in the models list, and notifies that theitem was inserted.
-
insertModelAfter
void insertModelAfter(EpoxyModel<out Object> modelToInsert, EpoxyModel<out Object> modelToInsertAfter)
Inserts the given model after the other in the models list, and notifies that the itemwas inserted.
-
removeModel
void removeModel(EpoxyModel<out Object> model)
If the given model exists it is removed and an item removal is notified. Otherwise this doesnothing.
-
removeAllModels
void removeAllModels()
Removes all models
-
removeAllAfterModel
void removeAllAfterModel(EpoxyModel<out Object> model)
Removes all models after the given model, which must have already been added. An example usecase is you want to keep a header but clear everything else, like in the case of refreshingdata.
-
showModel
void showModel(EpoxyModel<out Object> model, boolean show)
Sets the visibility of the given model, and notifies that the item changed if the newvisibility is different from the previous.
- Parameters:
model- The model to show.show- True to show the model, false to hide it.
-
showModel
void showModel(EpoxyModel<out Object> model)
Shows the given model, and notifies that the item changed if the item wasn't already shown.
- Parameters:
model- The model to show.
-
showModels
void showModels(Array<EpoxyModel<out Object>> models)
Shows the given models, and notifies that each item changed if the item wasn't already shown.
- Parameters:
models- The models to show.
-
showModels
void showModels(boolean show, Array<EpoxyModel<out Object>> models)
Sets the visibility of the given models, and notifies that the items changed if the newvisibility is different from the previous.
- Parameters:
show- True to show the models, false to hide them.models- The models to show.
-
showModels
void showModels(Iterable<EpoxyModel<out Object>> epoxyModels)
Shows the given models, and notifies that each item changed if the item wasn't already shown.
-
showModels
void showModels(Iterable<EpoxyModel<out Object>> epoxyModels, boolean show)
Sets the visibility of the given models, and notifies that the items changed if the newvisibility is different from the previous.
- Parameters:
show- True to show the models, false to hide them.
-
hideModel
void hideModel(EpoxyModel<out Object> model)
Hides the given model, and notifies that the item changed if the item wasn't already hidden.
- Parameters:
model- The model to hide.
-
hideModels
void hideModels(Iterable<EpoxyModel<out Object>> epoxyModels)
Hides the given models, and notifies that each item changed if the item wasn't already hidden.
-
hideModels
void hideModels(Array<EpoxyModel<out Object>> models)
Hides the given models, and notifies that each item changed if the item wasn't already hidden.
- Parameters:
models- The models to hide.
-
hideAllAfterModel
void hideAllAfterModel(EpoxyModel<out Object> model)
Hides all models currently located after the given model in the models list.
- Parameters:
model- The model after which to hide.
-
getAllModelsAfter
List<EpoxyModel<out Object>> getAllModelsAfter(EpoxyModel<out Object> model)
Returns a sub list of all items in models that occur after the given model. This listis backed by the original models list, any changes to the returned list will be reflected inthe original models list.
- Parameters:
model- Must exist in models.
-
getModelPosition
int getModelPosition(EpoxyModel<out Object> model)
Finds the position of the given model in the list. Doesn't use indexOf to avoid unnecessaryequals() calls since we're looking for the same object instance.
-
-
-
-