Giter Site home page Giter Site logo

robinhood / ticker Goto Github PK

View Code? Open in Web Editor NEW
4.4K 83.0 458.0 1.64 MB

An Android text view with scrolling text change animation

Home Page: https://medium.com/robinhood-engineering/hello-ticker-20eaf6e51689

License: Apache License 2.0

Java 100.00%
android android-ui android-animation

ticker's People

Contributors

carloshwa avatar davidmigloz avatar donyu avatar erickfn avatar hegazy avatar jawnnypoo avatar jinatonic avatar mandrizzle avatar mattsilber avatar naturalwarren avatar rtsketo avatar supercilex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ticker's Issues

Colliding numbers

If a two digit ticker number is updated rapidly (maybe four times in a ten second period) an odd issue occurs in which the two digits begin to move toward one another and eventually overlap.

This issue is occurring for me when switching from the number 72 to the number 0. The two digit 72 remains and the numbers slowly collide.

Shadow gets clipped in pre-L

Hi! When I use shadow, the characters are clipped in width (pre lollipop), how I fix this?

Thanks for library!

Auto resize

Please add a feature to Auto resize texts when texts exceeds tickerView bounds.
Like, I have to give fix width to tickerView and manage its text size according to its width. Then how can I manage it?

No Animation

I have set the tickerview with simple text. Its not animating any numbers. Here is the code

<RelativeLayout >
<com.robinhood.ticker.TickerView
        android:id="@+id/tickerView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true" />
</RelativeLayout>


public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TickerView tickerView = (TickerView) findViewById(R.id.tickerView);
        tickerView.setCharacterList(TickerUtils.getDefaultListForUSCurrency());
        tickerView.setAnimationDuration(500);
        tickerView.setText("$1000.34");
    }
}

I dont see any animation of the text

Support gravity attribute

You can see that the width of TickerView does a weird jump when you have the width set to wrap_content and you go from a longer string, such as "August" to a shorter string, such as "July". It will appear normal at first, with the "July" text appearing centered within within the view. When you then set the text to a similarly short string, such as "June", you will see the text jump from being center aligned to being left aligned.

I am going to investigate this further and see if I can find a solution.

Support baseline alignment

TextViews are often baseline-aligned to other views. TickerView should also support layout_alignBaseline and other similar layout attributes.

Request: Add isCharacterListSet() to API.

Hey,
as the title says, I'd like to see the function isCharacterListSet() added to the TickerView, so that can be dynamically set once it's required(, instead of hoping I remembered to initialize it beforehand or get Thrown out ">_> ).

Coding-wise, given what I've seen, this would likely be a simple null check on the characterList field.

android:text should not force user to specify character list in XML

Hello,

Since the latest update from 1.2.0 to 1.2.1 or 1.2.2, I am receiving the following crash:
01-19 23:20:51.007 20955-20955/<package name> E/AndroidRuntime: FATAL EXCEPTION: main Process: <package name>, PID: 20955 java.lang.RuntimeException: Unable to start activity ComponentInfo{<package name>/<package name>.activities.<activity name>}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.robinhood.ticker.TickerView at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.robinhood.ticker.TickerView Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.robinhood.ticker.TickerView Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:334) at android.view.LayoutInflater.createView(LayoutInflater.java:647) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at <package name>.fragments.<fragment name>.onCreateView(<fragment name>.java:126) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2354) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367) at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229) at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3221)

When reverting ticker to version 1.2.0, it works again.
I am using the latest Android API 27 in Android Studio with Gradle 4.

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

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.

Change the view bounds to match the parent

Is it possible to change the view bounds of the ticker so it matches the parent? The problem is that i can see animation starts just a little above the the ticker, not from the top of the view. i have set ticker to match the parent and gravity to center, the ticker pop up in the center but the view doesn't match the parent, more like wrap content.

get text

How to get current text from TickerView programmatically?

Support tools:text attribute

Would you please add support for the tools:text attribute like the TextView? It helps while designing the view.

Add support to prevent ticking of units as suffixes

I'm currently using your library to display instantaneous values of flow from my sensor and what's happening is that the unit (L/m) is a suffix and it's ticking every time the value changes which, ideally, shouldn't happen. Any idea how I'd be dealing with a situation like this?

Provide convenience methods for extending character lists

Just getting started with this library, I don't understand why it animates chars that are not part of the currently set character list. IMHO, these chars should not be animated at all.

For my use case, I'm displaying a percentage value (e.g. 81.03%). However, the % char is not included in the default lists provided by the TickerUtils, thus the ticker animates it on every value change.

The straight forward fix for that was adding the % char to a new character list and using it for the ticker:

protected void initializeLayout(View contentView) {
    valueTickerView = contentView.findViewById(R.id.valueTickerView);
    valueTickerView.setCharacterList(createTickerCharacterList());
}

private static char[] createTickerCharacterList() {
    char[] newCharacters = new char[]{'%', '€'};
    return extendCharacterList(TickerUtils.getDefaultNumberList(), newCharacters);
}

private static char[] extendCharacterList(char[] existingCharacters, char[] newCharacters) {
    char[] extendedCharacters = new char[existingCharacters.length + newCharacters.length];
    System.arraycopy(existingCharacters, 0, extendedCharacters, 0, existingCharacters.length);
    System.arraycopy(newCharacters, 0, extendedCharacters, existingCharacters.length, newCharacters.length);
    return extendedCharacters;
}

I think something like extendCharacterList would be nice to have as part of the TickerUtils. Note that the implementation above doesn't check for duplicate characters.

Tell me what am I doing wrong!

I've implemented this into my project, but it doesn't seem to work. Can you tell me what am I doing wrong? see code below...
final TickerView tickerView = (TickerView) findViewById(R.id.tickerView); tickerView.setCharacterList(TickerUtils.getDefaultNumberList()); String[] ticker_content = {"Lorem ipsum dolor sit amet", "Lorem ipsum dolor sit amet", "Lorem ipsum dolor sit amet"}; int idx = new Random().nextInt(ticker_content.length); tickerView.setText(ticker_content[idx]);

PS: I've added the .xml view and gradle lib

Countdown Timer transition 00:00:20 -> 00:00:19

Thanks for this library, I think I will be able to do great things with it. Sadly I am greedy and would like another feature:

It would be nice if the numbers did not count up when going from 0->9 when the overall number is getting smaller. Not sure if there is a way to do this.

My character list is:
static char[] characters = new char[]{TickerUtils.EMPTY_CHAR, ':', '9', '8', '7', '6', '5', '4', '3', '2', '1', '0'};

giphy

As you can see when the ticker goes from 07:53:20 to 07:53:19, the ticker does a huge animation when all I want it to do is go from 9 to 0 and 2 to 1, however I can only specify one character list.

No Autocompletion on Styleable Attributes

I was using Ticker and noticed that I'm not getting autocomplete in Android Studio 3.0.1 on styleable attributes. I dug in a little bit and discovered that because <declare-styleable name="ticker_TickerView"> isn't named the same as its custom view class Studio can't autocomplete. There's a standard lint shipped for this:

https://android.googlesource.com/platform/tools/base/+/master/lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/CustomViewDetector.java

#73 introduces a backwards incompatible change in preparation for a major release. Would you be open to a PR that renames the XML tag for v2.0.0? This change should be compile time safe and prompt folks to update their XML/source.

Add formating for Date/Times?

Would it be possible to add in functionality to extend the capabilities for date/time values? Maybe add logic for timers or countdowns?

Add textStyle support

Hello,

I'd like to have textStyle support too so I can make my text bold. I am using the textAppearance tag but it does not support textStyle="bold" yet.

Thanks!

Digital transform errors

when transform 15233 to 9151 or reverse,in the LevenshteinUtils,method computeColumnActions has mistake,turn the number to 152335 & 915

Request for different text size

Thanks for this lib!!!

Its possible add support for text with different length?
For example, the first word was 8 characters in length, and the second would be 20 characters in length
And when I set the second word, it is drawn outside the 'TickerView'
It is possible to add a function to automatically equalize the text size or transfer a part of the text to the second line?

<ScrollView
                            android:id="@+id/svWord"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center">
                   <com.robinhood.ticker.TickerView
                                android:id="@+id/tvWord"
                                android:background="@color/colorPrimary"
                                android:gravity="center"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:textSize="36sp" />
</ScrollView>

ticker is unable to smoothly transition during resize

OnePlus One A0001
Android 6.0.1
Cyanogen OS 13.1.2

There's a bug that impacts the smoothness of the animations/transitions. It happens when the ticker needs to resize the dollar value string, for example, when it transitions from above $100 to below $100, or from above $10 to below $10. I've recorded a video of my screen to demonstrate the issue on my device:

https://www.dropbox.com/s/y4k3f3u6jb3wulm/device-2017-09-21-104722.mp4

This has been happening for well over a year, maybe longer. When will this be resolved?

Shadow on numbers

It seems there's no way to add shadow on numbers because
TickerView extends View instead of TextView.

I tried with TickerTextAppearance, but it didn't work.
What would be the best way to implement the text shadow?

Support for Android Databinding library?

It would be useful to be able to make use of the databinding library to update the ticker, to follow MVVM design principles. Is there any way to do this currently?

e.g:

<com.robinhood.ticker.TickerView
            android:id="@+id/opponent_score_ticker"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="@style/text_large"
            android:text="@{viewModel.number}"/>

Recalculating character spacing on text size change

Hi,
I've got a TickerView sitting inside a CoordinatorLayout. I'm making the text size smaller as the screen is scrolled up, using a CoordinatorLayout.Behavior and RecyclerView.OnScrollListener(). While the text size shrinks correctly, the character spacing doesn't seem to update. To illustrate:

screen shot 2017-10-25 at 6 22 50 pm

becomes

screen shot 2017-10-25 at 6 23 01 pm

Approaches that I've tried so far without success:

  1. Increasing right padding: If I set the right padding with the view width set to wrap_content, the view size increases. If I set it to a fixed width, the right edge of the view gets cropped.

  2. setAnimateMeasurementChange(true): Seems to have no effect.

  3. balance.setText(text): Retrieving and setting the same text on the view in hopes of triggering a remeasuring of the character widths.

  4. Calling balance.requestLayout() manually on every update, and a variety of permutations of using this combined with the other approaches above.

Is there another approach that you could suggest? Thanks!

Add default support for arbitrary undefined characters

Hi, I'm trying to use your library to swap letters which means that I need to use the Greek latin alphabet letters with accents, etc.
Right now I just passing as the alphabet the 255 chars from the ascii table, but this is not the best solution because there are chars that have no printable representation and "blurry" also the animation when passing from one char to another...

Do you have a better solution?
Thanks.

What I'm doing right now:

alphabetlist = new char[255];
        alphabetlist[0] = TickerUtils.EMPTY_CHAR;
        for (int i = 0; i < 255; i++) {
            alphabetlist[i] = (char) (i);
        }

Auto resize

Hello,

I would love a feature where it possible to dynamically change the textSize to fit into the view? Can't use my resizable textview anymore with this library.

Disappearing characters

Repro:

  • Slow down animation.
  • Start with a short string (e.g. "1234")
  • Continuously set target to a longer string (e.g. "12345") before the animation completes.
  • Observe that some characters start popping up mid-frame rather than smoothly scroll from top/bottom.

Need help with adding support for a prefix

Hey folks, I'm trying to understand how does TickerUtils.getDefaultListForUSCurrency() work, but I'm unable to wrap my head around it. To be more specific, how does it ignore the dollar character? The only thing I've been able to figure out so far is that it probably has something to do with line numbers 38 and 39.

I'd like to use the rupee symbol (₹, \u20b9). Can you please help me out here?

Ticker animates initial setText() value when it should not

When calling ticker.setText("value") for the very first time, Ticker tries to not animate this call by checking if getWidth == 0. I think this check is currently broken.

I'm proposing two things:

  1. add a getText() method that returns the last value passed to setText() or empty CharSequence if never set (same behavior as TextView)
  2. the 1 argument setText() method should pass !getText().isEmpty() for the animate argument to the 2 argument constructor.

gas meter

Hello, can this do the same effect as the gas meter?

Add Animation Listener

I have seen that you have closed #16 .
But I think we should add an animation listener to that. In my case I'm showing ticker in red/green colour depending on whether the change is positive/negative. But after the animation I want to make it black again.
This may be the case with some of the people who wants to use TickerView.
Thank you for this awesome library. :)

Make size changing animation less funky

The current animation for changing size (e.g. "1234" to "12345") is a bit funky when the animation is slowed down. Investigate how to improve this behavior.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.