uknownothingsnow / CircleProgress

CircleProgress, DonutProgress, ArcProgress
3.81k stars 921 forks source link

Donut progress animation with 1.2.1 #88

Open rajvardhanyadav opened 7 years ago

rajvardhanyadav commented 7 years ago

How to apply animation for donut progress bar? Old ObjectAnimator logic is not working with 1.2.1 version.

shahwaiz90 commented 7 years ago

following.

TahaZaman commented 7 years ago

Any solution for this issue?

TahaZaman commented 7 years ago

Ok found my problem I was using ObjectAnimator.OfInt(....) but setProgress() method in DonutProgress class has float argument so it was not being called. Changed ObjectAnimator.OfInt(....) to ObjectAnimator.OfFloat(....) and it worked. But float values were looking weird so I extended CustomDonutProgress from DonutProgress and defined setProgress(int arg)

 public void setProgress(int progress) {
       super.setProgress(progress);
        Log.d("CustDonut", "setProgress: " + progress);
    }
caiob3 commented 6 years ago

Thanks guys! It worked for me too!

I have into a Fragment, so this can help others (same as you guys helped me :)

`

// Donut Progress Animation :) getActivity().runOnUiThread(new Runnable() {

        public void run() {

            ObjectAnimator anim = ObjectAnimator.ofFloat(mDonutProgress, "progress", 0, progress);
            anim.setInterpolator(new DecelerateInterpolator());
            anim.setDuration(2000);
            anim.start();

            anim.addListener(new Animator.AnimatorListener() {
                @Override
                public void onAnimationStart(Animator animation) {
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                }

                @Override
                public void onAnimationRepeat(Animator animation) {
                }

                @Override
                public void onAnimationEnd(Animator animation) {

                    if (progress >= 100) {
                            //do something :)
                    }
                }

            });

        }
    });

`