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(EpoxyModel, int)
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(long) 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.
EpoxyModelGroup(layoutRes: Int, models: MutableCollection<out EpoxyModel<*>!>!)EpoxyModelGroup(layoutRes: Int, vararg models: EpoxyModel<*>!)EpoxyModelGroup()EpoxyModelGroup(layoutRes: Int)
Constructor use for DSL |
val models: MutableList<EpoxyModel<*>!>! |
open fun addModel(model: EpoxyModel<*>): Unit |
|
open fun bind(holder: ModelGroupHolder): Unitopen fun bind(holder: ModelGroupHolder, payloads: MutableList<Any!>): Unitopen fun bind(holder: ModelGroupHolder, previouslyBoundModel: EpoxyModel<*>): Unit |
|
fun createNewHolder(parent: ViewParent): ModelGroupHolder! |
|
open fun equals(other: Any?): Boolean |
|
fun getDefaultLayout(): Int |
|
open fun getSpanSize(totalSpanCount: Int, position: Int, itemCount: Int): Int |
|
open fun hashCode(): Int |
|
open fun onViewAttachedToWindow(holder: ModelGroupHolder): Unit |
|
open fun onViewDetachedFromWindow(holder: ModelGroupHolder): Unit |
|
open fun shouldSaveViewState(shouldSaveViewState: Boolean): EpoxyModelGroupopen fun shouldSaveViewState(): Boolean |
|
open fun unbind(holder: ModelGroupHolder): Unit |
|
open fun useViewStubLayoutParams(model: EpoxyModel<*>!, modelPosition: Int): Boolean
Whether the layout params set on the view stub for the given model should be carried over to the model's view. Default is true |
open fun onFailedToRecycleView(holder: T): Boolean |
|
open fun onVisibilityChanged(percentVisibleHeight: Float, percentVisibleWidth: Float, visibleHeight: Int, visibleWidth: Int, holder: T): Unit |
|
open fun onVisibilityStateChanged(visibilityState: Int, holder: T): Unit |
abstract class GroupModel : EpoxyModelGroup, ModelCollector
An EpoxyModelGroup usable in a DSL manner via the group extension. |