Android seebar - how does the ValueAnimator determine the animation speed?

25 Views Asked by At

CONTEXT: I want to make my vertical SeekBar's value progression to be a "piece wise linear function". In other words, my value progression looks like this:

enter image description here "db" stands for decibel. As you can see in the beautiful graphic above, my SeekBar is split into segments (s1, s2, s3), which in turn consist of linear functions. In practice, the bottom 1/10 of the SeekBar (s1) accounts for 3/10 of the max value in db.

Currently, I have a fun that serves as an adapter, translating the linear progress value of the SeekBar into a db number. I read the progress value of the SeekBar, determine the segment, then multiply it with the linear function for the segment. I was wondering if it would be possible to remove the adapter and instead implement it directly as part of the SeekBar.

GOAL: I extend the SeekBar class and override its fun getProgress to have it return the progress value adjusted with the function above, instead of its regular, linear progress value. Now, I want to animate the SeekBar to have its value fall from max value to min value at a rate of 20db/1.7s. This means A) The higher the value, the longer the animation and B) the non-linear function should affect the animation speed among the different segments.

QUESTION: Does the ValueAnimator reference the fun getProgress in order to determine the animation speed or does it use the graphical distance between start value and goal value?

NOTE: When I animate the SeekBar to go from max to min, I want it to first go very fast, then slower and finally, even slower. If it only takes the graphical distance from max to min in account, it will disregard the function I sketched above and go from top to bottom at a constant speed.

0

There are 0 best solutions below