EpoxyModelGroup

open class EpoxyModelGroup : EpoxyModelWithHolder<ModelGroupHolder>

An EpoxyModel that contains other models, and allows you to combine those models in whatever view configuration you want.

The constructors take a list of models and a layout resource. The layout must have a viewgroup as its top level view; it determines how the view of each model is laid out. There are two ways to specify this

1. Leave the viewgroup empty. The view for each model will be inflated and added in order. This works fine if you don't need to include any other views, your model views don't need their layout params changed, and your views don't need ids (eg for saving state).

Alternatively you can have nested view groups, with the innermost viewgroup given the id "epoxy_model_group_child_container" to mark it as the viewgroup that should have the model views added to it. The viewgroup marked with this id should be empty. This allows you to nest viewgroups, such as a LinearLayout inside of a CardView.

2. Include a ViewStub for each of the models in the list. There should be at least as many view stubs as models. Extra stubs will be ignored. Each model will have its view replace the stub in order of the view stub's position in the view group. That is, the view group's children will be iterated through in order. The first view stub found will be used for the first model in the models list, the second view stub will be used for the second model, and so on. A depth first recursive search through nested viewgroups is done to find these viewstubs.

The layout can be of any ViewGroup subclass, and can have arbitrary other child views besides the view stubs. It can arrange the views and view stubs however is needed.

Any layout param options set on the view stubs will be transferred to the corresponding model view by default. If you want a model to keep the layout params from it's own layout resource you can override useViewStubLayoutParams

If you want to override the id used for a model's view you can set via xml. That id will be transferred over to the view taking that stub's place. This is necessary if you want your model to save view state, since without this the model's view won't have an id to associate the saved state with.

By default this model inherits the same id as the first model in the list. Call id to override that if needed.

When a model group is recycled, its child views are automatically recycled to a pool that is shared with all other model groups in the activity. This enables model groups to more efficiently manage their children. The shared pool is cleaned up when the activity is destroyed.

Constructors

EpoxyModelGroup
Link copied to clipboard
open fun EpoxyModelGroup(@LayoutRes() layoutRes: Int, models: Collection<out EpoxyModel<out Any>>)
The layout to use with these models.
EpoxyModelGroup
Link copied to clipboard
open fun EpoxyModelGroup(@LayoutRes() layoutRes: Int, models: Array<EpoxyModel<out Any>>)
The layout to use with these models.

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() holder: ModelGroupHolder)
Binds the current data to the given view.
open fun bind(@NonNull() holder: 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.
open fun bind(@NonNull() holder: ModelGroupHolder, @NonNull() previouslyBoundModel: EpoxyModel<out Any>)
Similar to bind, but provides a non null model which was previously bound tothis view.
open fun bind(@NonNull() holder: ModelGroupHolder, @NonNull() payloads: List<Any>)
Similar to bind, but provides a non null, non empty list of payloadsdescribing what changed.
open fun bind(@NonNull() holder: 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() holder: 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.
open fun onFailedToRecycleView(holder: 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.
open fun onViewAttachedToWindow(holder: ModelGroupHolder)
Called when this model's view is attached to the window.
open fun onViewAttachedToWindow(holder: 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.
open fun onViewDetachedFromWindow(holder: ModelGroupHolder)
Called when this model's view is detached from the the window.
open fun onViewDetachedFromWindow(holder: 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
open fun onVisibilityChanged(percentVisibleHeight: Float, percentVisibleWidth: Float, @Px() visibleHeight: Int, @Px() visibleWidth: Int, @NonNull() holder: T)
TODO link to the wiki
onVisibilityStateChanged
Link copied to clipboard
open fun onVisibilityStateChanged(visibilityState: Int, @NonNull() view: T)
TODO link to the wiki
open fun onVisibilityStateChanged(visibilityState: Int, @NonNull() holder: 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.
open fun shouldSaveViewState(shouldSaveViewState: Boolean): EpoxyModelGroup
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.
open fun unbind(@NonNull() holder: ModelGroupHolder)
Called when the view bound to this model is recycled.
open fun unbind(@NonNull() holder: T)
Called when the view bound to this model is recycled.

Inheritors

GroupModel
Link copied to clipboard