Closed SiminaNicolae closed 8 years ago
Hi @SiminaNicolae I'll add position check to this code. But generally you should call RecyclerView.smoothScrollToPosition method instead of LayoutManager one. The other thing that both infinite and non-infinite will crash (I'll add this) if you pass wrong position that is not in [0, adapger.getCount()-1]. Are you agree with this? Thanks.
@SiminaNicolae please find this commit https://github.com/Azoft/CarouselLayoutManager/commit/294e16b90375d9f4fe21f6ecf712c33bc276c3b1. If you don't have any objections, I'll create new tag
Thanks
Hi @mig35 Thank you for investigating it. I am not 100% sure that with this fix you will still be able to smooth scroll to left if the centered item from carousel is the first one from the list. I am thinking about the case of infinite scroll carousel where you have to go to the end of the list. (but I am sure that you tested it already ;) )
Thanks
@SiminaNicolae This works fine if you pass 0 (this will go to the first element). Bug if you pass carouselLayoutManager.getCenterItemPosition() - 1, then it will crash because this will be -1 and there can not be an element with index -1. And this is true for infinite carousel too. So any way you will have to add code that checks position bounds.
Thanks
Ok...thank you.
Hi SiminaNicolae, Upload new version with this checks: 1.1.4
dear mig35
i am also having same issue, not able to do smoothScrollToPositon after initializing the view, RecyclerView.State.getItemCount() giving 0 therefore it is firing "position can't be great then adapter items count. ..."
can you please help
I figured out my problem, it was with my code, it is working fine now, thank you
Hi @engzico We also figured out our problem. Fixed in commit cf4fcb2. Upload new version: 1.1.5
Hi, I tried to smooth scroll to next item from carousel using two buttons(left and right). For this I used the following:
Process: com.azoft.carousellayoutmanager.sample, PID: 31908 java.lang.IllegalArgumentException: Invalid target position at android.support.v7.widget.RecyclerView$SmoothScroller.start(RecyclerView.java:9562) at android.support.v7.widget.RecyclerView$LayoutManager.startSmoothScroll(RecyclerView.java:6596) at com.azoft.carousellayoutmanager.CarouselLayoutManager.smoothScrollToPosition(CarouselLayoutManager.java:193)
There is a workaround for example for non infinite scroll to check when navigate left if carouselLayoutManager.getCenterItemPosition() != 0, but the issue is still there.