Azoft / CarouselLayoutManager

Android Carousel LayoutManager for RecyclerView
Apache License 2.0
2.56k stars 367 forks source link

Play sound when item goes through the center position [Question] #81

Open alinberce opened 6 years ago

alinberce commented 6 years ago

Hi,

First of all, awesome awesome library. Thank you for it. Secondly, I am trying play a small sound each time an item goes through the center position. I've tried implementing my own CarouselLayoutManager.PostLayoutListener but it does not work as extended because this fires only when an item remains stationary. The problem is when doing a smoothScrollToPostion or when the user flings the recyclerview and a lot of scroll happens on the screen.

So what event should I be looking for in order to be notified each time an item goes through the center position, independent if it's programatically or scrolled by the user?

Thank you again for this awesome work.

mig35 commented 6 years ago

Hi @alinberce

We have OnCenterItemSelectionListener for this situation with addOnItemSelectionListener method. This listener will be fired on every new center item change event. But this listener will be fired when it is a visual change. So imagine that user is scrolling really slow. And the center item now is 0. And when 1 item will be upper then 0 - this event will be fired. So it may take some time while user will move this new 1 item to the center... So basically I don't have what you need - there is no event when item is going through the center position. May be I will add this event as a part of androidx update.