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

Ticking of "$" and "." in currency string #39

Closed hiteshsahu closed 7 years ago

hiteshsahu commented 7 years ago

While testing ticker for simple incremental values using below code snippet,

 float totalBill= 0;

    public void onUpdate() {
        final String currencyFloat = Float.toString((++totalBill) * 100);
        tickerView.setText("$" + currencyFloat.substring(0, Math.min(digits, currencyFloat.length())));
    }

I found that $ and . are also ticking along with changed digit. Ticker should avoid ticking nondigital characters.

jinatonic commented 7 years ago

This is currently working as intended. However, the algorithm to compute how to change from one text to another should try to preserve as much of the original text as possible so the leading $ symbol should never change.

paulvidal commented 7 years ago

Hi @hiteshsahu

Just had the same problem while using the library but solved it by changing the character list given :)

You need to set instead of this code

tickerView.setCharacterList(TickerUtils.getDefaultNumberList());

this new code

tickerView.setCharacterList(TickerUtils.getDefaultListForUSCurrency());

and the $ and . characters won't tick :)