Epoxy: Visibility callbacks on top level EpoxyModelGroup

Created on 8 Aug 2019  路  1Comment  路  Source: airbnb/epoxy

I have an EpoxyModelGroup that's created within my PagedListEpoxyController#buildItemModel as follows:

EpoxyModelGroup(
    R.layout.example_layout,
    HeaderViewModel_()
        .heading(item.heading)
        .subheading(item.subheading),
    CarouselModel_()
        .id(item.id)
        .padding(carouselPadding)
        .models(item.items.map {
            ItemViewModel_()
                .id(it.id)
                .coverImage(it.cover)
        }
)

I'd like to track the visibility of the overall group, as mentioned in the wiki.
However, it seems that EpoxyModelGroup doesn't have any method to register a OnModelVisibilityChangedListener (as can be usually found on generated EpoxyModels).

What is the correct process for registering a visibility callbacks on EpoxyModelGroups?

Most helpful comment

If you do want to register visibility callbacks on EpoxyModelGroup then you must use a generated subclass of it, so that the visibility callbacks are generated. Make a subclass of EpoxyModelGroup and add the @EpoxyModelClass annotation to it to force a generated class to be created - then use the resulting generated class.

EpoxyModelGroup could be modified in the future to have visibility handling built in - pull requests are welcome!

I updated the wiki with that info too

>All comments

If you do want to register visibility callbacks on EpoxyModelGroup then you must use a generated subclass of it, so that the visibility callbacks are generated. Make a subclass of EpoxyModelGroup and add the @EpoxyModelClass annotation to it to force a generated class to be created - then use the resulting generated class.

EpoxyModelGroup could be modified in the future to have visibility handling built in - pull requests are welcome!

I updated the wiki with that info too

Was this page helpful?
0 / 5 - 0 ratings