elevenetc / BadgeView

Badge view with animated effect which shows a bitmap or a text
447 stars 92 forks source link

How to set direction up/down for animation? #2

Open trietbui85 opened 9 years ago

trietbui85 commented 9 years ago

How can I control animation direction, for example animation to scroll down instead of up?

elevenetc commented 9 years ago

There is no such functionality. Direction of animation depends on a value: if it is number then smaller value goes from top and vice versa, if it is text then goes from bottom. You can fix it in AbstractBadgeView by changing this:

final boolean isBigger = valueCenter.compare(newValue);
IValue<?> nextValue;
if (isBigger) {
    valueBottom = newValue;
    nextValue = valueBottom;
} else {
    valueTop = newValue;
    nextValue = valueTop;
}

To this:

final boolean isBigger = valueCenter.compare(newValue);
IValue<?> nextValue;
if (!isBigger) {// - inverse
    valueBottom = newValue;
    nextValue = valueBottom;
} else {
    valueTop = newValue;
    nextValue = valueTop;
}

By the way you could create a PR with additional custom xml attribute like inverseAnimation:boolean.