I am designing a bonus runnable such that for each question, if the user can complete the question earlier, there is a bonus score for time remaining for each question.
Code:
private Runnable Run_bonus_countdownHandler = new Runnable()
{
@Override
public void run()
{
if (game_pause ==false)
{
bonus_time_remaining = Math.max((bonus_time_remaining - 10),0);
bonus_countdownHandler.postDelayed(this, 10);
tv_bonus.setText("" + bonus_time_remaining);
if (bonus_time_remaining == 0)
{
tv_bonus.setText("0");
bonus_countdownHandler.removeCallbacks(this);
}
}
else
{
}
}
};
Question:
If the user expires the bonus time period, ie the countdown reach 0, when the user starts another question, the bonus countdown can be run smoothly and at the end be removed. However, if the user can finish earlier for the question, for the next question the countdown would skip some numbers and quickly down to 0.
I would like to ask how could code be modified such that the runnable be properly removed before starting a new question?
Thanks a lot!