EpoxyController

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.

Constructors

EpoxyController
Link copied to clipboard
open fun EpoxyController()
EpoxyController
Link copied to clipboard
open fun EpoxyController(modelBuildingHandler: Handler, diffingHandler: Handler)

Types

ExceptionHandler
Link copied to clipboard
interface ExceptionHandler
Interceptor
Link copied to clipboard
interface Interceptor
A callback that is run after buildModels completes and before diffing is run.

Functions

add
Link copied to clipboard
open fun add(@NonNull() model: EpoxyModel<out Any>)
Add the model to this controller.
abstract fun add(model: Null)
addInterceptor
Link copied to clipboard
open fun addInterceptor(@NonNull() interceptor: EpoxyController.Interceptor)
Add an interceptor callback to be run after models are built, to make any last changes beforethey are set on the adapter.
addModelBuildListener
Link copied to clipboard
open fun addModelBuildListener(listener: OnModelBuildFinishedListener)
Add a listener that will be called every time buildModels has finished runningand changes have been dispatched to the RecyclerView.
cancelPendingModelBuild
Link copied to clipboard
open fun cancelPendingModelBuild()
Cancels a pending call to buildModels if one has been queued by .
getSpanCount
Link copied to clipboard
open fun getSpanCount(): Int
getSpanSizeLookup
Link copied to clipboard
open fun getSpanSizeLookup(): GridLayoutManager.SpanSizeLookup
For use with a grid layout manager - use this to get the SpanSizeLookup for models inthis controller.
hasPendingModelBuild
Link copied to clipboard
open fun hasPendingModelBuild(): Boolean
Whether an update to models is currently pending.
isDebugLoggingEnabled
Link copied to clipboard
open fun isDebugLoggingEnabled(): Boolean
isDuplicateFilteringEnabled
Link copied to clipboard
open fun isDuplicateFilteringEnabled(): Boolean
isMultiSpan
Link copied to clipboard
open fun isMultiSpan(): Boolean
isStickyHeader
Link copied to clipboard
abstract fun isStickyHeader(position: Int): 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 areusing sticky header feature.
moveModel
Link copied to clipboard
open fun moveModel(fromPosition: Int, toPosition: Int)
An optimized way to move a model from one position to another without rebuilding all models.
notifyModelChanged
Link copied to clipboard
open fun notifyModelChanged(position: Int)
An way to notify the adapter that a model has changed.
onRestoreInstanceState
Link copied to clipboard
open fun onRestoreInstanceState(@Nullable() inState: Bundle)
onSaveInstanceState
Link copied to clipboard
open fun onSaveInstanceState(@NonNull() outState: Bundle)
removeInterceptor
Link copied to clipboard
open fun removeInterceptor(@NonNull() interceptor: EpoxyController.Interceptor)
Remove an interceptor that was added with addInterceptor.
removeModelBuildListener
Link copied to clipboard
open fun removeModelBuildListener(listener: OnModelBuildFinishedListener)
Remove a listener added with addModelBuildListener.
requestDelayedModelBuild
Link copied to clipboard
open fun requestDelayedModelBuild(delayMs: Int)
Call this to request a delayed model update.
requestModelBuild
Link copied to clipboard
open fun requestModelBuild()
Call this to request a model update.
setDebugLoggingEnabled
Link copied to clipboard
open fun setDebugLoggingEnabled(enabled: Boolean)
If enabled, DEBUG logcat messages will be printed to show when models are rebuilt, the timetaken to build them, the time taken to diff them, and the item change outcomes from thediffer.
setGlobalDuplicateFilteringDefault
Link copied to clipboard
open fun setGlobalDuplicateFilteringDefault(filterDuplicatesByDefault: Boolean)
setFilterDuplicates is disabled in each EpoxyController by default.
setSpanCount
Link copied to clipboard
open fun setSpanCount(spanCount: Int)
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.
setupStickyHeaderView
Link copied to clipboard
open fun setupStickyHeaderView(stickyHeader: View): Null
open fun setupStickyHeaderView(@NotNull() stickyHeader: View)
Optional callback to setup the sticky view,by default it doesn't do anything.The sub-classes should override the function if they areusing sticky header feature.
teardownStickyHeaderView
Link copied to clipboard
open fun teardownStickyHeaderView(stickyHeader: View): Null
open fun teardownStickyHeaderView(@NotNull() stickyHeader: View)
Optional callback to perform tear down operation on thesticky view, by default it doesn't do anything.The sub-classes should override the function if they areusing sticky header feature.

Properties

adapter
Link copied to clipboard
private val adapter: EpoxyControllerAdapter
defaultDiffingHandler
Link copied to clipboard
open val defaultDiffingHandler: Handler
defaultModelBuildingHandler
Link copied to clipboard
open val defaultModelBuildingHandler: Handler
filterDuplicates
Link copied to clipboard
private open var filterDuplicates: Boolean
globalDebugLoggingEnabled
Link copied to clipboard
private open var globalDebugLoggingEnabled: Boolean
globalExceptionHandler
Link copied to clipboard
private open var globalExceptionHandler: EpoxyController.ExceptionHandler
Default handler for exceptions in all EpoxyControllers.

Inheritors

Typed2EpoxyController
Link copied to clipboard
Typed3EpoxyController
Link copied to clipboard
AsyncEpoxyController
Link copied to clipboard
Typed4EpoxyController
Link copied to clipboard
TypedEpoxyController
Link copied to clipboard
SimpleEpoxyController
Link copied to clipboard