0

If I create a RotateAnimation based on certain duration and degree parameters, but I want to call the same animation with different duration and degree parameters, how do I do that?

RotateAnimation animation = new RotateAnimation(fromDegrees, toDegrees, width, height/2);
        animation.setInterpolator(new LinearInterpolator());
        animation.setDuration(animationDuration);
        animation.setFillAfter(true);
        animation.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                activityTimeOrRepeat.setText(task.getDurationTitle());
                activityTimeOrRepeat.setTextColor(textColor);
                activityDescription.setText(task.getTitle());
                activityDescription.setTextColor(textColor);
                timeLeftForThisActivity.setTextColor(textColor);
                currentTimerIndex[0] = index;
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                timeLeftForThisActivity.setText("00:00");
                CountDownTimer currentTimer = timers[index];
                currentTimer.cancel();

                if (index == taskSize - 1) {
                    overallTimer[0].cancel();
                    startButton.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.done_button_master));
                    startButton.setTag(context.getString(R.string.wtrDoneButtonTag));
                    elapsedTimeDynamic.setText(String.format("%02d:%02d", (totalActivityTime / 1000) / 60, (totalActivityTime / 1000) % 60));
                }
                else {
                    RotateAnimation nextAnimation = animations[index + 1];
                    CountDownTimer nextTimer = timers[index + 1];
                    nextTimer.start();
                    workoutWidget.startAnimation(nextAnimation);
                }
            }
        });

How do I call this same animation, but with different duration and degree parameters?

Adam Johns
  • 35,397
  • 25
  • 123
  • 176
  • not sure what you want: you set duration by calling ..., you know what... – pskink Jul 22 '13 at 14:25
  • @pskink right, i set the duration the first time by calling setDuration...what I want is to call this same animation later in code, but with it having a different duration. Meaning I want the internal code of the animationStart and animationEnd to do the exact same thing, I just want it to have different duration. – Adam Johns Jul 22 '13 at 14:29
  • @pskink ok I see now that setDuration is a method of Animation. So that can be called later. But how about changing from degrees of same animation? – Adam Johns Jul 22 '13 at 14:52
  • for different degrees you have ro creatw new RotateAnimarion sorry – pskink Jul 22 '13 at 15:58

0 Answers0