abstract class EpoxyAdapter : BaseEpoxyAdapter
Allows you to easily combine different view types in the same adapter, and handles view holder creation, binding, and ids for you. Subclasses just need to add their desired EpoxyModel objects and the rest is done automatically.
androidx.recyclerview.widget.RecyclerView.Adapter#setHasStableIds(boolean) is set to true by default, since EpoxyModel makes it easy to support unique ids. If you don't want to support this then disable it in your base class (not recommended).
EpoxyAdapter()
Allows you to easily combine different view types in the same adapter, and handles view holder creation, binding, and ids for you. Subclasses just need to add their desired |
val models: MutableList<EpoxyModel<*>!>!
Subclasses should modify this list as necessary with the models they want to show. Subclasses are responsible for notifying data changes whenever this list is changed. |
open fun addModel(modelToAdd: EpoxyModel<*>!): Unit
Adds the model to the end of the |
|
open fun addModels(vararg modelsToAdd: EpoxyModel<*>!): Unitopen fun addModels(modelsToAdd: MutableCollection<out EpoxyModel<*>!>!): Unit
Adds the models to the end of the |
|
open fun enableDiffing(): Unit
Enables support for automatically notifying model changes via |
|
open fun getAllModelsAfter(model: EpoxyModel<*>!): MutableList<EpoxyModel<*>!>!
Returns a sub list of all items in |
|
open fun hideAllAfterModel(model: EpoxyModel<*>!): Unit
Hides all models currently located after the given model in the |
|
open fun hideModel(model: EpoxyModel<*>!): Unit
Hides the given model, and notifies that the item changed if the item wasn't already hidden. |
|
open fun hideModels(models: MutableIterable<EpoxyModel<*>!>!): Unitopen fun hideModels(vararg models: EpoxyModel<*>!): Unit
Hides the given models, and notifies that each item changed if the item wasn't already hidden. |
|
open fun insertModelAfter(modelToInsert: EpoxyModel<*>!, modelToInsertAfter: EpoxyModel<*>!): Unit
Inserts the given model after the other in the |
|
open fun insertModelBefore(modelToInsert: EpoxyModel<*>!, modelToInsertBefore: EpoxyModel<*>!): Unit
Inserts the given model before the other in the |
|
open fun notifyModelChanged(model: EpoxyModel<*>!): Unitopen fun notifyModelChanged(model: EpoxyModel<*>!, payload: Any?): Unit
Notify that the given model has had its data changed. It should only be called if the model retained the same position. |
|
open fun notifyModelsChanged(): Unit
Intelligently notify item changes by comparing the current |
|
open fun removeAllAfterModel(model: EpoxyModel<*>!): Unit
Removes all models after the given model, which must have already been added. An example use case is you want to keep a header but clear everything else, like in the case of refreshing data. |
|
open fun removeAllModels(): Unit
Removes all models |
|
open fun removeModel(model: EpoxyModel<*>!): Unit
If the given model exists it is removed and an item removal is notified. Otherwise this does nothing. |
|
open fun showModel(model: EpoxyModel<*>!, show: Boolean): Unit
Sets the visibility of the given model, and notifies that the item changed if the new visibility is different from the previous. open fun showModel(model: EpoxyModel<*>!): Unit
Shows the given model, and notifies that the item changed if the item wasn't already shown. |
|
open fun showModels(vararg models: EpoxyModel<*>!): Unitopen fun showModels(models: MutableIterable<EpoxyModel<*>!>!): Unit
Shows the given models, and notifies that each item changed if the item wasn't already shown. open fun showModels(show: Boolean, vararg models: EpoxyModel<*>!): Unitopen fun showModels(models: MutableIterable<EpoxyModel<*>!>!, show: Boolean): Unit
Sets the visibility of the given models, and notifies that the items changed if the new visibility is different from the previous. |
open fun getBoundViewHolders(): BoundViewHolders!
Returns an object that manages the view holders currently bound to the RecyclerView. This object is mainly used by the base Epoxy adapter to save view states, but you may find it useful to help access views or models currently shown in the RecyclerView. |
|
open fun getItemCount(): Int |
|
open fun getItemId(position: Int): Long |
|
open fun getItemViewType(position: Int): Int |
|
open fun getModelPosition(model: EpoxyModel<*>!): Int
Finds the position of the given model in the list. Doesn't use indexOf to avoid unnecessary equals() calls since we're looking for the same object instance. |
|
open fun getSpanCount(): Int |
|
open fun getSpanSizeLookup(): SpanSizeLookup!
For use with a grid layout manager - use this to get the |
|
open fun isEmpty(): Boolean |
|
open fun isMultiSpan(): Boolean |
|
open fun isStickyHeader(position: Int): Boolean
Called to check if the item at the position is a sticky item, by default returns false. |
|
open fun onBindViewHolder(holder: EpoxyViewHolder, position: Int): Unitopen fun onBindViewHolder(holder: EpoxyViewHolder, position: Int, payloads: MutableList<Any!>): Unit |
|
open fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EpoxyViewHolder |
|
open fun onDetachedFromRecyclerView(recyclerView: RecyclerView): Unit |
|
open fun onExceptionSwallowed(exception: RuntimeException!): Unit
This is called when recoverable exceptions happen at runtime. They can be ignored and Epoxy will recover, but you can override this to be aware of when they happen. |
|
open fun onFailedToRecycleView(holder: EpoxyViewHolder): Boolean |
|
open fun onModelBound(holder: EpoxyViewHolder!, model: EpoxyModel<*>!, position: Int, payloads: MutableList<Any!>?): Unitopen fun onModelBound(holder: EpoxyViewHolder!, model: EpoxyModel<*>!, position: Int): Unit
Called immediately after a model is bound to a view holder. Subclasses can override this if they want alerts on when a model is bound. |
|
open fun onModelUnbound(holder: EpoxyViewHolder!, model: EpoxyModel<*>!): Unit
Called immediately after a model is unbound from a view holder. Subclasses can override this if they want alerts on when a model is unbound. |
|
open fun onRestoreInstanceState(inState: Bundle?): Unit |
|
open fun onSaveInstanceState(outState: Bundle!): Unit |
|
open fun onViewAttachedToWindow(holder: EpoxyViewHolder): Unit |
|
open fun onViewDetachedFromWindow(holder: EpoxyViewHolder): Unit |
|
open fun onViewRecycled(holder: EpoxyViewHolder): Unit |
|
open fun setSpanCount(spanCount: Int): Unit
If you are using a grid layout manager you must call this to set the span count of the grid. This span count will be passed on to the models so models can choose what span count to be. |
|
open fun setupStickyHeaderView(stickyHeader: View): Unit
Optional callback to setup the sticky view, by default it doesn't do anything. |
|
open fun teardownStickyHeaderView(stickyHeader: View): Unit
Optional callback to perform tear down operation on the sticky view, by default it doesn't do anything. |
open class SimpleEpoxyAdapter : EpoxyAdapter
A non-abstract version of |