Multiple Countdown Timer Running One After Another
this is my first question here. I need to implement in my app six countdown timers running one after another. When first finishes, next one starts and so on. Init time of every sin
Solution 1:
You probably need to break out the start timer functionallity and call it in onFinish()
.
publicvoidstartTimer(int counterId){
Countercounter=null;
switch(counterId){
case0:
counter = newCounterOne(counterId,user_input1,1000);
break;
/* Counter 1-5 goes here*/default:
break;
}
if(counter !=null ){
counter.start();
}
}
then start your next timer in onFinsh()
publicabstractclassCounterextendsCountDownTimer
{
privateint counterId;
publicCounter(int counterId /*counter id start with 0*/,long millisInFuture, long countDownInterval)
{
super(millisInFuture, countDownInterval);
this.counterId = counterId;
}
publicabstractvoidonTick(long millisUntilFinished);
publicvoidonFinish()
{
playSound(sound_id_1);
runMyMethod(user_input_1);
startTimer(this.counterId++);
}
}
publicclassCounterOneextendsCounter{
publicvoidonTick(long millisUntilFinished)
{
//counter 1 logic
}
}
/* Subclass others. eg. CounterTwo etc. */
Post a Comment for "Multiple Countdown Timer Running One After Another"