4

Update: 20/11/13: This is still unresolved.

I am making a CountDownTimer and in the onFinish() method, I am apparently doing too much work as the delay between the last second and the finish takes longer than 1 second (which is my delay between ticks).

This is my code.

mCountDownTimer = new CountDownTimer(GAME_LENGTH, 1000) {

public void onTick(long millisUntilFinished) {
                mCountDownTextView.setText("" + millisUntilFinished / 1000);
            }

            public void onFinish() {
                mCountDownTextView.setText("Game Over!");
                tl.setOnTouchListener(null);
                for (DotView dv : mAllDots) {
                    dv.setChangingColors(false, null, -1); // This is my own method
                }
                 }

The question is: Is there a way to perform a potentially long running action in the onFinish() method of a CountDownTimer without the actual timings between the penultimate and last tick being affected?

1 Answers1

1

I had the same problem and I don't think it's the code in the onFinish() that's causing this.

I worked around the problem performing the actions when (millisUntilFinished/1000 == 1) instead of in the onFinish().

I also used mCountDownTextView.setText(String.valueOf((millisUntilFinished/1000) - 1)) to offset the textview by one second.