AnderWeb / discreteSeekBar

Apache License 2.0
2.11k stars 400 forks source link

Add ability to set thumb color as well as scrubber color programmatically. Add new NumericStringTransformer #9

Closed AOrobator closed 9 years ago

AOrobator commented 9 years ago

The first change I made to the public API were methods to change the color of the thumb and the scrubber, because I need them to be themed dynamically. Changing the color of the thumb also changes the color of the popup indicator to the same color.

The second change I made was the addition of a new numeric transformer called NumericStringTransformer. It's a more generic version of NumericTransformer, and its transform method directly returns a String, so if the user needs to do something more complicated than show a number or apply a format to a number, such as taking a number in milliseconds, and converting it to HH:MM:SS, they have more control over the final display of the popup indicator. If the NumericStringTransformer is set, the library will now prefer it over the NumericTransformer's transform. In my opinion, since this is a more powerful/generic version of NumericTransformer, NumericTransformer can be deprecated because its functionalities are duplicated by NumericStringTransformer.

AnderWeb commented 9 years ago

My first implementation for the popup bubble text was made that way, using code for a int->String transformation but some friends told me to make it work just with XML attributes, so I made the String formatter and a separate NumericTransformer.

Could we merge both implementations into one instead of having different transformers/formatters? Deprecationg the old way would force devs to add obligatory code for simple formatters instead of just relying on a simple formatter string provided by attrs.

And for the dynamic coloring of thumb/track, it would be better to add a setter on StateDrawable.java to update the ColorStateList (similar to how the constructor works) instead of creating new objects.

AOrobator commented 9 years ago

I've merged both implementations of the NumericTransformer and am now using a setter method for the color changing.