Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CarouselRecyclerView not scrolling to given position #6

Closed
totomft1518 opened this issue May 20, 2021 · 13 comments
Closed

CarouselRecyclerView not scrolling to given position #6

totomft1518 opened this issue May 20, 2021 · 13 comments

Comments

@totomft1518
Copy link

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

@totomft1518
Copy link
Author

it's a shame that such a good library has not support at all.

@sparrow007
Copy link
Owner

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.

@sparrow007
Copy link
Owner

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?

@totomft1518
Copy link
Author

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

@sparrow007
Copy link
Owner

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.

@totomft1518
Copy link
Author

totomft1518 commented May 25, 2021

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

@sparrow007
Copy link
Owner

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.

@totomft1518
Copy link
Author

totomft1518 commented May 27, 2021 via email

@sparrow007
Copy link
Owner

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)

@sparrow007
Copy link
Owner

I have made some fixes and going to publish it to maven you will get the update tomorrow, I'll update it here

@sparrow007
Copy link
Owner

Hi @totomft1518 , I have updated the library, just update the version in Gradle and also let me know if the bug fix or not

@totomft1518
Copy link
Author

The updated library works like a charm. Thanks a lot buddy. Nicely done!

@sparrow007
Copy link
Owner

@totomft1518 glad you like it, Now I am closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants