epoxy-adapter / com.airbnb.epoxy / Typed4EpoxyController

Typed4EpoxyController

abstract class Typed4EpoxyController<T : Any!, U : Any!, V : Any!, W : Any!> : EpoxyController

This is a wrapper around com.airbnb.epoxy.EpoxyController to simplify how data is accessed. Use this if the data required to build your models is represented by four objects.

To use this, create a subclass typed with your data object. Then, call #setData whenever that data changes. This class will handle calling #buildModels with the latest data.

You should NOT call #requestModelBuild() directly.

See Also
TypedEpoxyControllerTyped2EpoxyControllerTyped3EpoxyController

Constructors

<init>

Typed4EpoxyController()
Typed4EpoxyController(modelBuildingHandler: Handler!, diffingHandler: Handler!)

Inherited Properties

defaultDiffingHandler

static var defaultDiffingHandler: Handler!

defaultModelBuildingHandler

static var defaultModelBuildingHandler: Handler!

Functions

buildModels

fun buildModels(): Unit
abstract fun buildModels(data1: T, data2: U, data3: V, data4: W): Unit

moveModel

open fun moveModel(fromPosition: Int, toPosition: Int): Unit

requestDelayedModelBuild

open fun requestDelayedModelBuild(delayMs: Int): Unit

requestModelBuild

fun requestModelBuild(): Unit

setData

open fun setData(data1: T, data2: U, data3: V, data4: W): Unit

Call this with the latest data when you want models to be rebuilt. The data will be passed on to #buildModels(Object, Object, Object, Object)

Inherited Functions

add

open fun add(model: EpoxyModel<*>): Unit

Add the model to this controller. Can only be called from inside .

open fun add(vararg modelsToAdd: EpoxyModel<*>!): Unit
open fun add(modelsToAdd: MutableList<out EpoxyModel<*>!>): Unit

Add the models to this controller. Can only be called from inside .

addInterceptor

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.

addModelBuildListener

open fun addModelBuildListener(listener: OnModelBuildFinishedListener!): Unit

Add a listener that will be called every time #buildModels() has finished running and changes have been dispatched to the RecyclerView.

cancelPendingModelBuild

open fun cancelPendingModelBuild(): Unit

Cancels a pending call to #buildModels() if one has been queued by .

getAdapter

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.

getModelCountBuiltSoFar

open fun getModelCountBuiltSoFar(): Int

Get the number of models added so far during the #buildModels() phase. It is only valid to call this from within that method.

getSpanCount

open fun getSpanCount(): Int

getSpanSizeLookup

open fun getSpanSizeLookup(): SpanSizeLookup

For use with a grid layout manager - use this to get the SpanSizeLookup for models in this controller. This will delegate span look up calls to each model's . Make sure to also call #setSpanCount(int) so the span count is correct.

hasPendingModelBuild

open fun hasPendingModelBuild(): Boolean

Whether an update to models is currently pending. This can either be because #requestModelBuild() was called, or because models are currently being built or diff on a background thread.

isBuildingModels

open fun isBuildingModels(): Boolean

True if the current callstack originated from the buildModels call, on the same thread.

isDebugLoggingEnabled

open fun isDebugLoggingEnabled(): Boolean

isDuplicateFilteringEnabled

open fun isDuplicateFilteringEnabled(): Boolean

isMultiSpan

open fun isMultiSpan(): Boolean

isStickyHeader

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.

notifyModelChanged

open fun notifyModelChanged(position: Int): Unit

An way to notify the adapter that a model has changed. This is intended to be used with androidx.recyclerview.widget.ItemTouchHelper to allow revert swiping a model.

onAttachedToRecyclerView

open fun onAttachedToRecyclerView(recyclerView: RecyclerView): Unit

Called when the controller's adapter is attach to a recyclerview.

onDetachedFromRecyclerView

open fun onDetachedFromRecyclerView(recyclerView: RecyclerView): Unit

Called when the controller's adapter is detached from a recyclerview.

onExceptionSwallowed

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.

onModelBound

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(...)

onModelUnbound

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(...)

onRestoreInstanceState

open fun onRestoreInstanceState(inState: Bundle?): Unit

onSaveInstanceState

open fun onSaveInstanceState(outState: Bundle): Unit

onViewAttachedToWindow

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.

onViewDetachedFromWindow

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.

removeInterceptor

open fun removeInterceptor(interceptor: EpoxyController.Interceptor): Unit

Remove an interceptor that was added with #addInterceptor(Interceptor).

removeModelBuildListener

open fun removeModelBuildListener(listener: OnModelBuildFinishedListener!): Unit

Remove a listener added with #addModelBuildListener(OnModelBuildFinishedListener). This is safe to call from inside the callback OnModelBuildFinishedListener#onModelBuildFinished(DiffResult)

setDebugLoggingEnabled

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.

setFilterDuplicates

open fun setFilterDuplicates(filterDuplicates: Boolean): Unit

If set to true, Epoxy will search for models with duplicate ids added during and remove any duplicates found. If models with the same id are found, the first one is left in the adapter and any subsequent models are removed. will be called for each duplicate removed.

setGlobalDebugLoggingEnabled

open static fun setGlobalDebugLoggingEnabled(globalDebugLoggingEnabled: Boolean): Unit

Similar to #setDebugLoggingEnabled(boolean), but this changes the global default for all EpoxyControllers.

setGlobalDuplicateFilteringDefault

open static fun setGlobalDuplicateFilteringDefault(filterDuplicatesByDefault: Boolean): Unit

#setFilterDuplicates(boolean) is disabled in each EpoxyController by default. It can be toggled individually in each controller, or alternatively you can use this to change the default value for all EpoxyControllers.

setGlobalExceptionHandler

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.

setSpanCount

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.

setupStickyHeaderView

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.

teardownStickyHeaderView

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.