robinhood / ticker

An Android text view with scrolling text change animation
https://medium.com/robinhood-engineering/hello-ticker-20eaf6e51689
Apache License 2.0
4.38k stars 462 forks source link

Preferred TickerColumn Scrolling Direction #100

Closed mattsilber closed 5 years ago

mattsilber commented 5 years ago

This PR fixes #97 by introducing the ability to enforce a preferred scrolling direction when animating TickerColumn changes.

The direction can be set by calling TickerView.setPreferredScrollingDirection(int) with values of TickerView.DIRECTION_ANY, TickerView.DIRECTION_UP, or TickerView.DIRECTION_DOWN. It can also be set via XML via ::ticker_defaultPreferredScrollingDirection with values of any, up, or down. The default behavior of the scrolling animation is what it currently is before the introduction of this PR (TickerView.DIRECTION_ANY).

The direction is stored within the TickerDrawMetrics and is retrievable via TickerDrawMetrics.getPreferredScrollingDirection().

This PR also updates the TickerCharacterListTest tests to explicitly define their target direction, and adds several tests for the enforced up/down scrolling behavior.

I also left some sample calls within ticker-sample, but was unsure if you'd prefer to leave them out.

mattsilber commented 5 years ago

Thanks for the awesome lib!

I went ahead and made some of the changes you requested. If you decide you want me to go ahead and migrate it to using an enum I'd be happy to do that as well

mattsilber commented 5 years ago

I migrated the TickerView.DIRECTION_X constants to TickerView.ScrollingDirection. Would you prefer it in there, or would you rather that enum pulled out of that level?