The mentioned exception occurs for instance when I filter the items in the list (change the items in the array and notifyDataSetChanged) > scroll to a position larger than 0 and > unfiltered the list > call smoothScrollToPosition(0). This also happens when the filter leaves only a single item in the list and then I unfiltered the list and > call smoothScrollToPosition(0). I was able to fix this problem by changing the CarouselLayoutManager#layoutItems method to use itemCount from RecyclerView.State.#getItemCount instead of RecyclerView#getItemCount. in the doc about RecyclerView#getItemCount it says "Note that this number is not necessarily equal to State#getItemCount() .In methods where State is available, you should use State#getItemCount() instead." I wonde r whether is better to pass the state also to to other methods in CarouselLayoutManager where item count is accessed directly through RecyclerView#getItemCount. Or would you expect any negative effects of this?
The mentioned exception occurs for instance when I filter the items in the list (change the items in the array and notifyDataSetChanged) > scroll to a position larger than 0 and > unfiltered the list > call smoothScrollToPosition(0). This also happens when the filter leaves only a single item in the list and then I unfiltered the list and > call smoothScrollToPosition(0). I was able to fix this problem by changing the CarouselLayoutManager#layoutItems method to use itemCount from RecyclerView.State.#getItemCount instead of RecyclerView#getItemCount. in the doc about RecyclerView#getItemCount it says "Note that this number is not necessarily equal to State#getItemCount() .In methods where State is available, you should use State#getItemCount() instead." I wonde r whether is better to pass the state also to to other methods in CarouselLayoutManager where item count is accessed directly through RecyclerView#getItemCount. Or would you expect any negative effects of this?