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

cant get visibilitystate and onVisibilityStateChanged on model inside the carousel #625

Closed gokulkrizh closed 4 years ago

gokulkrizh commented 5 years ago

private fun initEpoxy(images: MutableList<Images>) { mBinding.recyclerView.withModels { imageCarousel { id("Carousel") padding(Carousel.Padding(0, 0, 0, 0, 10)) setDefaultGlobalSnapHelperFactory(object : Carousel.SnapHelperFactory() { override fun buildSnapHelper(context: Context?): SnapHelper { return PagerSnapHelper() } }) withModelsFrom(images){ ViewholderListingDetailsPhotoStoryBindingModel_() .id(it.id()) .url(it.name()) .onVisibilityChanged { model, view, percentVisibleHeight, percentVisibleWidth, heightVisible, widthVisible -> } .onVisibilityStateChanged { model, view, visibilityState -> } } } } }

@ModelView(saveViewState = true, autoLayout = ModelView.Size.MATCH_WIDTH_MATCH_HEIGHT) class ImageCarousel(context: Context) : Carousel(context) { @NonNull override fun createLayoutManager(): RecyclerView.LayoutManager { return LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) } }

elihart commented 5 years ago

can you format this better and provide more details?

elihart commented 5 years ago

I believe this is intended - we don't currently support nested recyclerviews, but it is being worked on

https://github.com/airbnb/epoxy/pull/627

gokulkrizh commented 5 years ago

Great. Thanks @elihart for super fast response is there any way to find the position of the carousel while scrolling. i tried with linearlayoutmanager to get position but ended up with 0 for findFirstCompletelyVisibleItemPosition, findFirstVisibleItemPosition, findLastCompletelyVisibleItemPosition, findLastVisibleItemPosition all methods