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

How to prevent the last character to animation? #93

Closed iman2420 closed 6 years ago

iman2420 commented 6 years ago

I use this library for Timer view like this:

5:01,8 -> format is: minute:seconds,millisecond

i want to prevent the millisecond character to animation. how to do it?

iman2420 commented 6 years ago

I do it by this code finally:

 ` @Override
    public void run() {
        long millis = System.currentTimeMillis() - startTime;
        int seconds = (int) (millis / 1000);
        int minutes = seconds / 60;
        seconds = seconds % 60;
        int milliSeconds = (int) ((millis - seconds) / 100) % 10;
        String finalResult = String.format(Locale.getDefault(), "%d:%02d,%01d", minutes, seconds, milliSeconds);
        Log.d(TAG, "run: millisecond: " + withOutMilli);
        if (finalResult.contains(withOutMilli)) {
            tickerView.setText(finalResult, false);
        } else {

            tickerView.setText(finalResult, true);
        }
        withOutMilli = finalResult.substring(0, finalResult.length() - 1);
        timerHandler.postDelayed(this, 100);
    }`