airbnb / epoxy

Epoxy is an Android library for building complex screens in a RecyclerView
https://goo.gl/eIK82p
Apache License 2.0
8.5k stars 733 forks source link

Find rows by id in Epoxy #574

Closed qbait closed 5 years ago

qbait commented 5 years ago

In my list, I defined my carousel

            carousel {
                id("myCarousel")
                numViewsToShowOnScreen(1f)
                withModelsFrom(list) {
                    MarqueeModel_()
                            .id(it)
                            .title(it)
                }
            }

At the moment I query for it this way val myCarousel = recyclerView.asSequence().filterIsInstance(Carousel::class.java).first()

But what if I have more Carousels? Can I find items in Epoxy list by id myCarousel? What's the best practice?

elihart commented 5 years ago

generally epoxy tries not to expose the views, because it can lead to hacky things that are best done some other way

if you really need to you can use epoxyController.getAdapter().getBoundViewHolders() to get details about bound views