EpoxyModelWithView

abstract class EpoxyModelWithView<T : View?> : EpoxyModel<T>

A model that allows its view to be built programmatically instead of by inflating a layout resource. Just implement buildView so the adapter can create a new view for this model when needed.

getViewType is used by the adapter to know how to reuse views for this model. This means that all models that return the same type should be able to share the same view, and the view won't be shared with models of any other type.

If it is left unimplemented then at runtime a unique view type will be created to use for all models of that class. The generated view type will be negative so that it cannot collide with values from resource files, which are used in normal Epoxy models. If you would like to share the same view between models of different classes you can have those classes return the same view type. A good way to manually create a view type value is by creating an R.id. value in an ids resource file.

Functions

addIf
Link copied to clipboard
open fun addIf(condition: Boolean, @NonNull() controller: EpoxyController)
Add this model to the given controller if the condition is true.
open fun addIf(@NonNull() predicate: EpoxyModel.AddPredicate, @NonNull() controller: EpoxyController)
Add this model to the given controller if the AddPredicate return true.
addTo
Link copied to clipboard
open fun addTo(@NonNull() controller: EpoxyController)
Add this model to the given controller.
bind
Link copied to clipboard
open fun bind(@NonNull() view: T)
Binds the current data to the given view.
open fun bind(@NonNull() view: T, @NonNull() previouslyBoundModel: EpoxyModel<out Any>)
Similar to bind, but provides a non null model which was previously bound tothis view.
open fun bind(@NonNull() view: T, @NonNull() payloads: List<Any>)
Similar to bind, but provides a non null, non empty list of payloadsdescribing what changed.
equals
Link copied to clipboard
open fun equals(o: Any): Boolean
getLayout
Link copied to clipboard
fun getLayout(): Int
getSpanSize
Link copied to clipboard
open fun getSpanSize(totalSpanCount: Int, position: Int, itemCount: Int): Int
Subclasses can override this if they want their view to take up more than one span in a gridlayout.
hashCode
Link copied to clipboard
open fun hashCode(): Int
hide
Link copied to clipboard
open fun hide(): EpoxyModel<T>
Change the visibility of the model so that it's view is hidden.
id
Link copied to clipboard
open fun id(): Long
open fun id(@Nullable() key: CharSequence): EpoxyModel<T>
Use a string as the model id.
open fun id(@Nullable() ids: Array<Number>): EpoxyModel<T>
Use multiple numbers as the id for this model.
open fun id(id: Long): EpoxyModel<T>
Override the default id in cases where the data subject naturally has an id, like an objectfrom a database.
open fun id(@Nullable() key: CharSequence, @Nullable() otherKeys: Array<CharSequence>): EpoxyModel<T>
Use several strings to define the id of the model.
open fun id(@Nullable() key: CharSequence, id: Long): EpoxyModel<T>
Set an id that is namespaced with a string.
open fun id(id1: Long, id2: Long): EpoxyModel<T>
Use two numbers as the id for this model.
isShown
Link copied to clipboard
open fun isShown(): Boolean
Whether the model's view should be shown on screen.
layout
Link copied to clipboard
open fun layout(@LayoutRes() layoutRes: Int): EpoxyModel<T>
onFailedToRecycleView
Link copied to clipboard
open fun onFailedToRecycleView(@NonNull() view: T): Boolean
Called if the RecyclerView failed to recycle this model's view.
onViewAttachedToWindow
Link copied to clipboard
open fun onViewAttachedToWindow(@NonNull() view: T)
Called when this model's view is attached to the window.
onViewDetachedFromWindow
Link copied to clipboard
open fun onViewDetachedFromWindow(@NonNull() view: T)
Called when this model's view is detached from the the window.
onVisibilityChanged
Link copied to clipboard
open fun onVisibilityChanged(percentVisibleHeight: Float, percentVisibleWidth: Float, @Px() visibleHeight: Int, @Px() visibleWidth: Int, @NonNull() view: T)
TODO link to the wiki
onVisibilityStateChanged
Link copied to clipboard
open fun onVisibilityStateChanged(visibilityState: Int, @NonNull() view: T)
TODO link to the wiki
reset
Link copied to clipboard
open fun reset(): EpoxyModel<T>
Sets fields of the model to default ones.
shouldSaveViewState
Link copied to clipboard
open fun shouldSaveViewState(): Boolean
Whether the adapter should save the state of the view bound to this model.
show
Link copied to clipboard
open fun show(): EpoxyModel<T>
Change the visibility of the model so that it's view is shown.
open fun show(show: Boolean): EpoxyModel<T>
Change the visibility of the model's view.
spanSize
Link copied to clipboard
fun spanSize(totalSpanCount: Int, position: Int, itemCount: Int): Int
Returns the actual span size of this model, using the SpanSizeOverrideCallback if onewas set, otherwise using the value from getSpanSize
spanSizeOverride
Link copied to clipboard
open fun spanSizeOverride(@Nullable() spanSizeCallback: EpoxyModel.SpanSizeOverrideCallback): EpoxyModel<T>
toString
Link copied to clipboard
open fun toString(): String
unbind
Link copied to clipboard
open fun unbind(@NonNull() view: T)
Called when the view bound to this model is recycled.