abstract class EpoxyController : ModelCollector, StickyHeaderCallbacks
A controller for easily combining EpoxyModel instances in a RecyclerView.Adapter. Simply implement #buildModels() to declare which models should be used, and in which order. Call #requestModelBuild() whenever your data changes, and the controller will call #buildModels(), update the adapter with the new models, and notify any changes between the new and old models.
The controller maintains a androidx.recyclerview.widget.RecyclerView.Adapter with the latest models, which you can get via #getAdapter() to set on your RecyclerView.
All data change notifications are applied automatically via Epoxy's diffing algorithm. All of your models must have a unique id set on them for diffing to work. You may choose to use annotations to have the controller create models with unique ids for you automatically.
Once a model is created and added to the controller in #buildModels() it should be treated as immutable and never modified again. This is necessary for adapter updates to be accurate.
interface ExceptionHandler |
|
interface Interceptor
A callback that is run after |
EpoxyController()EpoxyController(modelBuildingHandler: Handler!, diffingHandler: Handler!) |
static var defaultDiffingHandler: Handler! |
|
static var defaultModelBuildingHandler: Handler! |
open fun add(model: EpoxyModel<*>): Unit
Add the model to this controller. Can only be called from inside open fun add(vararg modelsToAdd: EpoxyModel<*>!): Unitopen fun add(modelsToAdd: MutableList<out EpoxyModel<*>!>): Unit
Add the models to this controller. Can only be called from inside |
|
open fun addInterceptor(interceptor: EpoxyController.Interceptor): Unit
Add an interceptor callback to be run after models are built, to make any last changes before they are set on the adapter. Interceptors are run in the order they are added. |
|
open fun addModelBuildListener(listener: OnModelBuildFinishedListener!): Unit
Add a listener that will be called every time |
|
abstract fun buildModels(): Unit
Subclasses should implement this to describe what models should be shown for the current state. Implementations should call either |
|
open fun cancelPendingModelBuild(): Unit
Cancels a pending call to |
|
open fun getAdapter(): EpoxyControllerAdapter
Get the underlying adapter built by this controller. Use this to get the adapter to set on a RecyclerView, or to get information about models currently in use. |
|
open fun getModelCountBuiltSoFar(): Int
Get the number of models added so far during the |
|
open fun getSpanCount(): Int |
|
open fun getSpanSizeLookup(): SpanSizeLookup
For use with a grid layout manager - use this to get the |
|
open fun hasPendingModelBuild(): Boolean
Whether an update to models is currently pending. This can either be because |
|
open fun isBuildingModels(): Boolean
True if the current callstack originated from the buildModels call, on the same thread. |
|
open fun isDebugLoggingEnabled(): Boolean |
|
open fun isDuplicateFilteringEnabled(): 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. The sub-classes should override the function if they are using sticky header feature. |
|
open fun moveModel(fromPosition: Int, toPosition: Int): Unit
An optimized way to move a model from one position to another without rebuilding all models. This is intended to be used with |
|
open fun notifyModelChanged(position: Int): Unit
An way to notify the adapter that a model has changed. This is intended to be used with |
|
open fun onAttachedToRecyclerView(recyclerView: RecyclerView): Unit
Called when the controller's adapter is attach to a recyclerview. |
|
open fun onDetachedFromRecyclerView(recyclerView: RecyclerView): Unit
Called when the controller's adapter is detached from a recyclerview. |
|
open fun onExceptionSwallowed(exception: RuntimeException): Unit
This is called when recoverable exceptions occur at runtime. By default they are ignored and Epoxy will recover, but you can override this to be aware of when they happen. |
|
open fun onModelBound(holder: EpoxyViewHolder, boundModel: EpoxyModel<*>, position: Int, previouslyBoundModel: EpoxyModel<*>?): 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. Alternatively you may attach a listener directly to a generated model with model.onBind(...) |
|
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. Alternatively you may attach a listener directly to a generated model with model.onUnbind(...) |
|
open fun onRestoreInstanceState(inState: Bundle?): Unit |
|
open fun onSaveInstanceState(outState: Bundle): Unit |
|
open fun onViewAttachedToWindow(holder: EpoxyViewHolder, model: EpoxyModel<*>): Unit
Called when the given viewholder is attached to the window, along with the model it is bound to. |
|
open fun onViewDetachedFromWindow(holder: EpoxyViewHolder, model: EpoxyModel<*>): Unit
Called when the given viewholder is detechaed from the window, along with the model it is bound to. |
|
open fun removeInterceptor(interceptor: EpoxyController.Interceptor): Unit
Remove an interceptor that was added with |
|
open fun removeModelBuildListener(listener: OnModelBuildFinishedListener!): Unit
Remove a listener added with |
|
open fun requestDelayedModelBuild(delayMs: Int): Unit
Call this to request a delayed model update. The controller will schedule a call to |
|
open fun requestModelBuild(): Unit
Call this to request a model update. The controller will schedule a call to |
|
open fun setDebugLoggingEnabled(enabled: Boolean): Unit
If enabled, DEBUG logcat messages will be printed to show when models are rebuilt, the time taken to build them, the time taken to diff them, and the item change outcomes from the differ. The tag of the logcat message is the class name of your EpoxyController. |
|
open fun setFilterDuplicates(filterDuplicates: Boolean): Unit
If set to true, Epoxy will search for models with duplicate ids added during |
|
open static fun setGlobalDebugLoggingEnabled(globalDebugLoggingEnabled: Boolean): Unit
Similar to |
|
open static fun setGlobalDuplicateFilteringDefault(filterDuplicatesByDefault: Boolean): Unit
|
|
open static fun setGlobalExceptionHandler(globalExceptionHandler: EpoxyController.ExceptionHandler): Unit
Set a callback to be notified when a recoverable exception occurs at runtime. By default these are ignored and Epoxy will recover, but you can override this to be aware of when they happen. |
|
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 which span count to be. |
|
open fun setupStickyHeaderView(stickyHeader: View): Unit
Optional callback to setup the sticky view, by default it doesn't do anything. The sub-classes should override the function if they are using sticky header feature. |
|
open fun teardownStickyHeaderView(stickyHeader: View): Unit
Optional callback to perform tear down operation on the sticky view, by default it doesn't do anything. The sub-classes should override the function if they are using sticky header feature. |
abstract class AsyncEpoxyController : EpoxyController
A subclass of |
|
open class SimpleEpoxyController : EpoxyController
A small wrapper around |
|
abstract class Typed2EpoxyController<T : Any!, U : Any!> : EpoxyController
This is a wrapper around |
|
abstract class Typed3EpoxyController<T : Any!, U : Any!, V : Any!> : EpoxyController
This is a wrapper around |
|
abstract class Typed4EpoxyController<T : Any!, U : Any!, V : Any!, W : Any!> : EpoxyController
This is a wrapper around |
|
abstract class TypedEpoxyController<T : Any!> : EpoxyController
This is a wrapper around |