countdown timer loop android
<p>I need to to show a countdown timer with 2 time periods, for example i need it to count down a 45 sec, then count down 15 sec and then loop it all over again 4 times.</p>

<p>I tried this code but it seems to start all the timers at ones. I want at to start the first timer and wait till it finish and then start the second timer wait till it finish and then loop it again.
what should i do??</p>

<pre><code>for (int i = 0; i &lt; labsNum; i++) {
    currLabTV.setText("LAB " + (i + 1));
    if(isWorking) {
            timer = new WorkCounter(workNum * 1000, 1000);
            timer.start();
    }
    if(!isWorking){
        timer = new WorkCounter(restNum * 1000, 1000);
        timer.start();
    }
}
</code></pre>

<p>i extended the CountDownTimer class.</p>

<pre><code>public class WorkCounter extends CountDownTimer {
    public WorkCounter(long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
    }

    @Override
    public void onTick(long millisUntilFinished) {
        String ms = String.format("%02d:%02d" , TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished), TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished));
        timeTV.setText(ms);
    }

    @Override
    public void onFinish() {
        if(isWorking) {
            workoutSign.setText("REST");
        }else {
            workoutSign.setText("WORKOUT");
        }
        isWorking = !isWorking;
    }
}
</code></pre>