0

I am using loader in fragment and when loading is finished then I re-set list adapter's data and start animation using ObjectAnimator.

I coded ObjectAnimator in onLoadFinished(Loader loader, XXX data).

        final ObjectAnimator anim = ObjectAnimator.ofInt(new AnimatedPointView(mTextView), "point", oldPoint, data.getPointBalance());
        anim.setEvaluator(new TypeEvaluator<Integer>() {
            @Override
            public Integer evaluate(float fraction, Integer startValue, Integer endValue) {
                if (BuildConfig.DEBUG) Ln.d("start="+startValue+", end="+endValue+", fraction="+fraction);
                return startValue + Math.round(fraction * (endValue - startValue));
            }
        });
        anim.setInterpolator(new LinearInterpolator());
        anim.setDuration(5000);

But this does not work, the evaluate is called twice and the fraction is only 1.0f.

main start=113, end=103, fraction=1.0
main start=113, end=103, fraction=1.0

This animation code works in blank activity's onCreate.

Any suggestion and help would be appreciated.

I added full example code for this.

https://github.com/sh1nj1/android-test/blob/master/app/src/main/java/com/example/testandroid/app/MainActivity.java

and if I use NineOldAndroids library, this won't happen. This does not only happen in onLoadFinished method but other places like OnClickListner#onClick.

Chk0nDanger
  • 1,211
  • 1
  • 10
  • 26
  • What are the start/end/fraction values in a blank activity's onCreate? Also looks like there are some other threads on onLoadFinished being called twice: http://stackoverflow.com/questions/14719814/onloadfinished-called-twice – Whitney May 15 '14 at 15:54
  • @Whitney, Thank you for comment. start/end are as same as initial arguments of ObjectAnimator#ofInt, the fraction changes between 0.0f to 1.0f. I found something that if I reset duration then, this case happens. not only in onLoadFinished but OnClickListener#onClick. I added full code, https://github.com/sh1nj1/android-test/blob/master/app/src/main/java/com/example/testandroid/app/MainActivity.java – Chk0nDanger May 16 '14 at 00:30

0 Answers0