Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>the issue here is that you create <code>prepCountTimer</code> and assign on finish ect, then start it. then it reaches the end of for each and loops again making another <code>preopCountTimer</code> and starting it. you need to make your <code>restCountTimer</code> start the next <code>preopCountTimer</code> once it's done. unless I'm understanding something wrong here.</p> <pre><code>public void callingMethod() { timerMethod(times.getValue()); // execution continues as your timer will run in a different thread } public void timerMethod(final int count) { if (count == 0) { // we have done the number of timers we want we can // call whatever we wanted to once our timers were done } //you could use count to get the times for each timer here startTimer(_finalPrep, new timerListner() { @Override public void timerFinish() { //when timer 1 finishes we will start timer 2 startTimer(_finalWorkout, new timerListner() { @Override public void timerFinish() { //when timer 2 finishes we will start timer 3 startTimer(_finalRest, new timerListner() { @Override public void timerFinish() { //when timer 3 finishes we want to call the next timer in the list. timerMethod(count - 1); } }); } }); } }); } private interface timerListner { void timerFinish(); } public void startTimer(int timerTime, final timerListner onFinish) { // you can pass in other parameters unqiue to each timer to this method aswell CountDownTimer timer = new CountDownTimer(timerTime * 1000, 1000) { public void onTick(long millisUntilFinished) { tvRoundCount.setText("Round " + roundCount + " / " + times.getValue()); tvCountDown.setText((millisUntilFinished / 1000) + "s"); if (millisUntilFinished &lt;= (6 * 1000)) { tvCountDown.setTextColor(Color.RED); } } @Override public void onFinish() { onFinish.timerFinish(); } }; timer.start(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload