CarouselRecyclerView not scrolling to given position
totomft1518 opened this issue · comments
Hi there,
I have to dynamically scroll the recycler view to a given positon, unlikely when i use rv.scrollToPosition(givenPosition) the app crashes.
Following the error : " Caused by: kotlin.UninitializedPropertyAccessException: lateinit property recycler has not been initialized at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.scrollToPosition(CarouselLayoutManager.kt:404)".
Really hope someone out there can help me. Thanks a lot
it's a shame that such a good library has not support at all.
Hi, very sorry actually I was very busy with my company works, not got the time until the weekend but don't worry I will start working today will fix it.
Just a quick question, are you able to show your codes open source or it's a private project, Just wanted to look at the what's the condition?
hey there, thanks a lot for the consideration. Unlikely i cant share the source code as it is a private project, but i found your library very appealing and i would love to integrate it into the project, of course , if for you is alright.
The problem as i said , i need to scroll dynamically to a given position , but unlikely scrollToPosition breaks somewhere.
Thanks again. And really well done for your work. I LOVE IT
Ok, I understand but if you could provide me a sample so that it would be very easy for me to make a fix quickly and update the lib. for example snippet where you are getting this issue, or it's just some time happens.
Hi there, here the snippet generated following the given documentation.
//Init Carousel
var carouselRecyclerview = binding.rvArtworksCorousel
var adapter = CorouselAdapter(listOfArtworks!!)
carouselRecyclerview.adapter = adapter
carouselRecyclerview.set3DItem(true)
carouselRecyclerview.setInfinite(false)
carouselRecyclerview.setFlat(false)
val carouselLayoutManager = carouselRecyclerview.getCarouselLayoutManager()
carouselRecyclerview.layoutManager = carouselLayoutManager
val currentlyCenterPosition = carouselRecyclerview.getSelectedPosition()
if (listPosition == 0) {
getNumberLikesAndDislikes(listOfArtworks!![listPosition])
}else {
//this is where it breaks
// carouselLayoutManager.scrollToPosition(listPosition)
carouselRecyclerview.scrollToPosition(listPosition)
}
it happens everytime I access the carousel with a position different from 0
" Caused by: kotlin.UninitializedPropertyAccessException: lateinit property recycler has not been initialized at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.scrollToPosition(CarouselLayoutManager.kt:404)".
THANKS A LOT
I will fix it by this Sunday because I had long meetings so I am only working in my free time, but I will sure make an update by Sunday.
Really thank you for providing all these details.
Hi, You can use the below codes just to fix now, I am updating this library by tomorrow so you can use the below codes
Where you are setting the position of the item
Handler().postDelayed({ carouselRecyclerview.scrollToPosition(3) }, 200)
I have made some fixes and going to publish it to maven you will get the update tomorrow, I'll update it here
Hi @totomft1518 , I have updated the library, just update the version in Gradle and also let me know if the bug fix or not
The updated library works like a charm. Thanks a lot buddy. Nicely done!
@totomft1518 glad you like it, Now I am closing this issue.