I have below metod to configure my ValueAnimator for cross fading between two colors. But it doesn't work. It always gives ending color value.
Integer colorFrom;
Integer colorTo;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGoogleApiClient = buildGoogleApiClient();
activity = getActivity();
context = activity.getApplicationContext();
colorFrom = ContextCompat.getColor(context, R.color.donut_finished_color);
colorTo = ContextCompat.getColor(context, R.color.Red);
}
@Override
public void onResume() {
super.onResume();
setColorAnimation();
}
private void setColorAnimation() {
long passedTime = Calendar.getInstance().getTime().getTime() - currentEarlyDate.getTime();
colorAnimator = ValueAnimator.ofObject(argbEvaluator, colorFrom, colorTo);
colorAnimator.setDuration(currentPrayerTimeLength);
colorAnimator.setInterpolator(null);
colorAnimator.addUpdateListener(this);
colorAnimator.start();
colorAnimator.setCurrentPlayTime(passedTime);
}
@Override
public void onAnimationUpdate(ValueAnimator animation) {
Integer colorValue = (Integer) colorAnimator.getAnimatedValue();
Log.e(Constants.LOG_TAG, "Duration : " + colorAnimator.getDuration());
Log.e(Constants.LOG_TAG, "Current : " + colorAnimator.getCurrentPlayTime());
Log.e(Constants.LOG_TAG, "Color : " + colorValue);
remainingTimeProgress.setFinishedStrokeColor(colorValue);
remainingTimeProgress.setUnfinishedStrokeColor(colorValue);
}
Timing values seems wright on log but animated color value jumps to end
09-02 17:53:22.032 updateLocationNamesList
09-02 17:59:30.104 setColorAnimation - Length : 10620000
09-02 17:59:30.104 setColorAnimation - Passed : 4290093
09-02 17:53:22.099 onAnimationUpdate - Duration : 10620000
09-02 17:53:22.099 onAnimationUpdate - Current : 0
09-02 17:53:22.099 onAnimationUpdate - Color : -16058881
09-02 17:53:22.100 onAnimationUpdate - Duration : 10620000
09-02 17:53:22.100 onAnimationUpdate - Current : 0
09-02 17:53:22.100 onAnimationUpdate - Color : -10183775
09-02 17:53:22.102 onAnimationUpdate - Duration : 10620000
09-02 17:53:22.102 onAnimationUpdate - Current : 2
09-02 17:53:22.102 onAnimationUpdate - Color : -65536 //Quickly jumps to end
Can't figure out what is wrong?
make sure you have Animations enabled in your device "developer options"
, if disabled your animation simply jumps from "start"
to "end"
value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With