Closed DarioAhdoot closed 3 years ago
Also tried this instead of calling show multiple times, but I was not able to get the data to reload:
binding.carouselView.size = assets.size
requireView().findViewById<RecyclerView>(R.id.carouselRecyclerView).adapter!!.notifyDataSetChanged()
Same issues here as well can some one help me solve this
@rohanisme I had to just fork the repo and make a bunch of changes to accommodate that and other needs. This library seems to be designed for static data that doesn't change
Can u share me the changed repo so i can use the same
@rohanisme I can't unfortunately, but it wasn't hard
before apply set onFlingListener null
binding.carouselView.findViewById
I've got the same problem, I just made it static, I am using live data to load the update news data when it was added to the bookmark and really not affected in the carousel, so I just create an instance of my data, and check it, if it was empty add and load data carousel
private var carouselData = listOf<ArticlesItem?>()
in observer
model.getNews().observe(viewLifecycleOwner, {
if (carouselData.isEmpty()) {
carouselData = it.articles!!
setDataCarousel(carouselData)
}
})
I've tried to remove all data before apply but it doesn't work too
before apply set onFlingListener null
binding.carouselView.findViewById(R.id.carouselRecyclerView).onFlingListener = null
this was better solution to resolve issue
val v: RecyclerView = binding.videoSlider!!.findViewById(R.id.carouselRecyclerView) v.onFlingListener = null
it's is working perfectly
Solved in #26
Describe the bug Calling show() multiple times results in an IllegalStateException being thrown by SnapHelper::setupCallbacks,
throw new IllegalStateException("An instance of OnFlingListener already set.");
To Reproduce Steps to reproduce the behavior:
Expected behavior Should support calling show() multiple times to repopulate the carousel
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context Add any other context about the problem here.
Maybe I'm doing something wrong, but, I don't see a way to get the carousel to reload data other than calling show(). Here is my code: