Thursday, June 2, 2011

The countdown timer - finishing the job

It's all fine and well to have a countdown timer show a nice progress bar, but that's not all. What do you do when the timer comes to an end? Or if an answer is chosen before the timer comes to a finish?

To answer the second question first, probably just need to set the progress bar to zero and let the answer logic take over. But, what if they run out? It's a wrong answer, but there's no wrong answer to highlight. Maybe change the color of the progress bar? Actually, the default colors aren't that great, anyway.

First things first. Let's check out how to activate the answer selected routine when an answer has been chosen.

Ok, I've figured out how to cancel the timer when the choose it - just call timer.cancel();

I also have extracted a common routine to handle the "correctAnswer" setup on the onListViewClick.

this will be called from the click event, and also from the timer finished event.

the correct answer routine will also reset the progress bar to zero by calling countdownTimer.cancel();

So, I now will make the leap of faith, and call the "correctAnswer" routine from the countdownTimer cancel event.

It seems to be working ok. That's a wrap.

No comments:

Post a Comment