回答編集履歴

3

rest_counts/rest_sets 及び Status 関係を追加

2020/05/14 20:00

投稿

jimbe
jimbe

スコア12670

test CHANGED
@@ -40,7 +40,7 @@
40
40
 
41
41
  public class CountDownTimerActivity extends AppCompatActivity implements Workout.Listener {
42
42
 
43
- private TextView setTextView, countTextView, lefttimeTextView;
43
+ private TextView setTextView, countTextView, statusTextView, lefttimeTextView;
44
44
 
45
45
  private ProgressBar progressBar;
46
46
 
@@ -74,14 +74,14 @@
74
74
 
75
75
  countTextView = findViewById(R.id.countNumber);
76
76
 
77
+ statusTextView = findViewById(R.id.status);
78
+
77
79
  lefttimeTextView = findViewById(R.id.timeLeft);
78
80
 
79
81
 
80
82
 
81
83
  progressBar = findViewById(R.id.pb);
82
84
 
83
- progressBar.setMax(workout.getTickMax());
84
-
85
85
 
86
86
 
87
87
  startStopButton = findViewById(R.id.button_start_stop);
@@ -138,7 +138,7 @@
138
138
 
139
139
  private Workout getWorkout(int id) {
140
140
 
141
- return new Workout("test",10,0,2,1,0); //テスト用
141
+ return new Workout("test",10,5,2,2,20); //テスト用
142
142
 
143
143
  /*
144
144
 
@@ -178,7 +178,15 @@
178
178
 
179
179
  setTextView.setText(""+properties.getSet());
180
180
 
181
-
181
+ statusTextView.setText(""+properties.getStatus());
182
+
183
+
184
+
185
+ if(progressBar.getMax() != properties.getTickMax()) {
186
+
187
+ progressBar.setMax(properties.getTickMax());
188
+
189
+ }
182
190
 
183
191
  progressBar.setProgress(properties.getTickMax() - properties.getTick());
184
192
 
@@ -320,6 +328,8 @@
320
328
 
321
329
  int getLeftSecond();
322
330
 
331
+ Workout.Status getStatus();
332
+
323
333
  }
324
334
 
325
335
 
@@ -338,23 +348,29 @@
338
348
 
339
349
  }
340
350
 
351
+ enum Status {
352
+
353
+ Nonexecution, Training, RestCounts, RestSets
354
+
355
+ }
356
+
341
357
 
342
358
 
343
359
  private static final int PARTICLE_SIZE = 20; //1秒を何tickに分けるか
344
360
 
345
361
 
346
362
 
347
- //private String name;
363
+ private String name;
348
-
364
+
349
- //private int time; //トレーニング時間[s]
365
+ private int time; //トレーニング時間[s]
350
-
366
+
351
- //private int rest_time; //休憩時間[s]
367
+ private int rest_counts; //休憩時間[s]
352
368
 
353
369
  private int countMax; //カウント
354
370
 
355
371
  private int setMax; //セット数
356
372
 
357
- //private int set_during; //セット間の休憩時間[s]
373
+ private int rest_sets; //セット間の休憩時間[s]
358
374
 
359
375
 
360
376
 
@@ -366,27 +382,45 @@
366
382
 
367
383
  private int count, set;
368
384
 
385
+ private Status status;
386
+
369
387
  private Handler handler;
370
388
 
371
389
 
372
390
 
391
+ /**
392
+
393
+ *
394
+
395
+ * @param name トレーニング名?
396
+
397
+ * @param time トレーニング時間[s]
398
+
399
+ * @param rest_counts 休憩時間[s]
400
+
401
+ * @param count カウント
402
+
403
+ * @param set セット数
404
+
405
+ * @param rest_sets セット間の休憩時間[s]
406
+
407
+ */
408
+
373
- Workout(String name, int time, int rest_time, int count, int set, int set_during) {
409
+ Workout(String name, int time, int rest_counts, int count, int set, int rest_sets) {
374
-
410
+
375
- //this.name = name;
411
+ this.name = name;
376
-
412
+
377
- //this.time = time;
413
+ this.time = time;
378
-
414
+
379
- //this.rest_time = rest_time;
415
+ this.rest_counts = rest_counts;
380
416
 
381
417
  this.countMax = count;
382
418
 
383
419
  this.setMax = set;
384
420
 
385
- //this.set_during = set_during;
421
+ this.rest_sets = rest_sets;
386
-
387
-
388
-
389
- this.tickMax = time * PARTICLE_SIZE;
422
+
423
+
390
424
 
391
425
  this.handler = new Handler();
392
426
 
@@ -408,6 +442,8 @@
408
442
 
409
443
  public int getLeftSecond() { return calcLeftSecond(tick); }
410
444
 
445
+ public Status getStatus() { return status; }
446
+
411
447
 
412
448
 
413
449
  private static int calcLeftSecond(int tick) { return (tick + PARTICLE_SIZE - 1) / PARTICLE_SIZE; }
@@ -416,18 +452,18 @@
416
452
 
417
453
  synchronized void start(Listener listener) {
418
454
 
419
- if(timer != null)
420
-
421
- throw new IllegalStateException();
455
+ if(timer != null) throw new IllegalStateException();
422
456
 
423
457
  this.listener = listener;
424
458
 
459
+ status = Status.Training;
460
+
461
+ listener.start(Workout.this);
462
+
425
463
  timer = new Timer();
426
464
 
427
465
  timer.scheduleAtFixedRate(new TickTask(), 1000L / PARTICLE_SIZE, 1000L / PARTICLE_SIZE); //[ms]
428
466
 
429
- listener.start(Workout.this);
430
-
431
467
  }
432
468
 
433
469
 
@@ -482,119 +518,171 @@
482
518
 
483
519
  private boolean downTick() {
484
520
 
521
+ if(--tick > 0) return false;
522
+
523
+
524
+
525
+ switch(status) {
526
+
527
+ case RestCounts:
528
+
485
- if(--tick <= 0) {
529
+ if(count <= 0) {
530
+
486
-
531
+ status = Status.RestSets;
532
+
533
+ tickMax = rest_sets * PARTICLE_SIZE;
534
+
535
+ tick = tickMax;
536
+
537
+ break;
538
+
539
+ }
540
+
541
+ /*break;*/
542
+
543
+ case RestSets:
544
+
545
+ status = Status.Training;
546
+
547
+ if(count <= 0) count = countMax;
548
+
549
+ tickMax = time * PARTICLE_SIZE;
550
+
551
+ tick = tickMax;
552
+
553
+ break;
554
+
555
+ default: //Training
556
+
487
- if(--count <= 0) {
557
+ if(--count <= 0) {
558
+
488
-
559
+ if(--set <= 0) {
560
+
561
+ status = Status.Nonexecution;
562
+
489
- if(--set <= 0) return true; //finish
563
+ return true; //finish
564
+
490
-
565
+ }
566
+
567
+ }
568
+
569
+ status = Status.RestCounts;
570
+
571
+ tickMax = rest_counts * PARTICLE_SIZE;
572
+
573
+ tick = tickMax;
574
+
575
+ }
576
+
577
+ return false;
578
+
579
+ }
580
+
581
+
582
+
583
+ private static class WorkoutSnapshot implements WorkoutProperties {
584
+
585
+ private int tick, tickMax;
586
+
587
+ private int count, set;
588
+
589
+ private Status status;
590
+
591
+
592
+
593
+ WorkoutSnapshot(Workout wo) {
594
+
595
+ this.tick = wo.tick;
596
+
597
+ this.tickMax = wo.tickMax;
598
+
491
- count = countMax;
599
+ this.count = wo.count;
600
+
601
+ this.set = wo.set;
602
+
603
+ this.status = wo.status;
604
+
605
+ }
606
+
607
+
608
+
609
+ public int getSet() { return set; }
610
+
611
+ public int getCount() { return count; }
612
+
613
+ public int getTick() { return tick; }
614
+
615
+ public int getTickMax() { return tickMax; }
616
+
617
+ public int getLeftSecond() { return calcLeftSecond(tick); }
618
+
619
+ public Status getStatus() { return status; }
620
+
621
+ }
622
+
623
+
624
+
625
+ private synchronized void postProgress(WorkoutProperties properties) {
626
+
627
+ if(listener != null) {
628
+
629
+ listener.progress(properties);
630
+
631
+ }
632
+
633
+ }
634
+
635
+
636
+
637
+ private synchronized void postFinish(WorkoutProperties properties) {
638
+
639
+ if(listener != null) {
640
+
641
+ listener.finish(properties);
642
+
643
+ listener = null;
644
+
645
+ }
646
+
647
+ }
648
+
649
+
650
+
651
+ synchronized void stop() {
652
+
653
+ if(timer != null) {
654
+
655
+ timer.cancel();
656
+
657
+ timer = null;
658
+
659
+ if(listener != null) {
660
+
661
+ listener.stop(this);
662
+
663
+ listener = null;
492
664
 
493
665
  }
494
666
 
667
+ }
668
+
669
+ }
670
+
671
+
672
+
673
+ synchronized void reset() {
674
+
675
+ if(timer == null) {
676
+
677
+ count = countMax;
678
+
679
+ set = setMax;
680
+
681
+ tickMax = time * PARTICLE_SIZE;
682
+
495
683
  tick = tickMax;
496
684
 
497
- }
498
-
499
- return false;
500
-
501
- }
502
-
503
-
504
-
505
- private static class WorkoutSnapshot implements WorkoutProperties {
506
-
507
- private int tick, tickMax;
508
-
509
- private int count, set;
510
-
511
-
512
-
513
- WorkoutSnapshot(Workout wo) {
514
-
515
- this.tick = wo.tick;
516
-
517
- this.tickMax = wo.tickMax;
518
-
519
- this.count = wo.count;
520
-
521
- this.set = wo.set;
522
-
523
- }
524
-
525
-
526
-
527
- public int getSet() { return set; }
528
-
529
- public int getCount() { return count; }
530
-
531
- public int getTick() { return tick; }
532
-
533
- public int getTickMax() { return tickMax; }
534
-
535
- public int getLeftSecond() { return calcLeftSecond(tick); }
536
-
537
- }
538
-
539
-
540
-
541
- private synchronized void postProgress(WorkoutProperties properties) {
542
-
543
- if(listener != null) {
544
-
545
- listener.progress(properties);
546
-
547
- }
548
-
549
- }
550
-
551
-
552
-
553
- private synchronized void postFinish(WorkoutProperties properties) {
554
-
555
- if(listener != null) {
556
-
557
- listener.finish(properties);
685
+ status = Status.Nonexecution;
558
-
559
- listener = null;
560
-
561
- }
562
-
563
- }
564
-
565
-
566
-
567
- synchronized void stop() {
568
-
569
- if(timer != null) {
570
-
571
- timer.cancel();
572
-
573
- timer = null;
574
-
575
- if(listener != null) {
576
-
577
- listener.stop(this);
578
-
579
- listener = null;
580
-
581
- }
582
-
583
- }
584
-
585
- }
586
-
587
-
588
-
589
- synchronized void reset() {
590
-
591
- if(timer == null) {
592
-
593
- this.count = countMax;
594
-
595
- this.set = setMax;
596
-
597
- this.tick = tickMax;
598
686
 
599
687
  }
600
688
 

2

CountDownTimer から Timer#scheduleAtFixedRate に変更

2020/05/14 20:00

投稿

jimbe
jimbe

スコア12670

test CHANGED
@@ -56,7 +56,7 @@
56
56
 
57
57
  super.onCreate(savedInstanceState);
58
58
 
59
- setContentView(R.layout.activity_main); //activity_count_down_timer
59
+ setContentView(R.layout.activity_count_down_timer);
60
60
 
61
61
 
62
62
 
@@ -138,7 +138,7 @@
138
138
 
139
139
  private Workout getWorkout(int id) {
140
140
 
141
- return new Workout("test",10,0,3,4,0); //テスト用
141
+ return new Workout("test",10,0,2,1,0); //テスト用
142
142
 
143
143
  /*
144
144
 
@@ -172,17 +172,19 @@
172
172
 
173
173
 
174
174
 
175
- private void showWorkout(Workout workout) {
175
+ private void showWorkout(WorkoutProperties properties) {
176
-
176
+
177
- countTextView.setText(""+workout.getCount());
177
+ countTextView.setText(""+properties.getCount());
178
-
178
+
179
- setTextView.setText(""+workout.getSet());
179
+ setTextView.setText(""+properties.getSet());
180
-
180
+
181
+
182
+
181
- progressBar.setProgress(workout.getTick());
183
+ progressBar.setProgress(properties.getTickMax() - properties.getTick());
182
-
183
-
184
-
184
+
185
+
186
+
185
- int left = workout.getLeftSecond();
187
+ int left = properties.getLeftSecond();
186
188
 
187
189
  int minute = left / 60;
188
190
 
@@ -214,7 +216,7 @@
214
216
 
215
217
  @Override
216
218
 
217
- public void start(Workout workout) {
219
+ public void start(WorkoutProperties properties) {
218
220
 
219
221
  setStop();
220
222
 
@@ -228,9 +230,9 @@
228
230
 
229
231
  @Override
230
232
 
231
- public void progress(Workout workout) {
233
+ public void progress(WorkoutProperties properties) {
232
-
234
+
233
- showWorkout(workout);
235
+ showWorkout(properties);
234
236
 
235
237
  }
236
238
 
@@ -238,9 +240,9 @@
238
240
 
239
241
  @Override
240
242
 
241
- public void finish(Workout workout) {
243
+ public void finish(WorkoutProperties properties) {
242
-
244
+
243
- showWorkout(workout);
245
+ showWorkout(properties);
244
246
 
245
247
  startStopButton.setEnabled(false);
246
248
 
@@ -252,7 +254,7 @@
252
254
 
253
255
  @Override
254
256
 
255
- public void stop(Workout workout) {
257
+ public void stop(WorkoutProperties properties) {
256
258
 
257
259
  setRestart();
258
260
 
@@ -298,23 +300,41 @@
298
300
 
299
301
 
300
302
 
301
- import android.os.CountDownTimer;
303
+ import android.os.Handler;
302
-
304
+
305
+
306
+
303
- import android.util.Log;
307
+ import java.util.*;
304
-
305
-
306
-
308
+
309
+
310
+
307
- class Workout {
311
+ interface WorkoutProperties {
312
+
313
+ int getSet();
314
+
315
+ int getCount();
316
+
317
+ int getTick();
318
+
319
+ int getTickMax();
320
+
321
+ int getLeftSecond();
322
+
323
+ }
324
+
325
+
326
+
327
+ class Workout implements WorkoutProperties {
308
328
 
309
329
  interface Listener {
310
330
 
311
- void start(Workout workout);
331
+ void start(WorkoutProperties properties);
312
-
332
+
313
- void progress(Workout workout);
333
+ void progress(WorkoutProperties properties);
314
-
334
+
315
- void finish(Workout workout);
335
+ void finish(WorkoutProperties properties);
316
-
336
+
317
- void stop(Workout workout);
337
+ void stop(WorkoutProperties properties);
318
338
 
319
339
  }
320
340
 
@@ -340,13 +360,13 @@
340
360
 
341
361
  private Listener listener;
342
362
 
343
- private CountDownTimer countDownTimer;
363
+ private Timer timer;
344
364
 
345
365
  private int tick, tickMax;
346
366
 
347
367
  private int count, set;
348
368
 
349
- private boolean firstTick = false; //CountDownTimer の 最初の onTick を無視するため
369
+ private Handler handler;
350
370
 
351
371
 
352
372
 
@@ -368,6 +388,8 @@
368
388
 
369
389
  this.tickMax = time * PARTICLE_SIZE;
370
390
 
391
+ this.handler = new Handler();
392
+
371
393
 
372
394
 
373
395
  reset();
@@ -376,109 +398,205 @@
376
398
 
377
399
 
378
400
 
379
- int getSet() { return set; }
401
+ public int getSet() { return set; }
380
-
402
+
381
- int getCount() { return count; }
403
+ public int getCount() { return count; }
382
-
404
+
383
- int getTick() { return tick; }
405
+ public int getTick() { return tick; }
384
-
406
+
385
- int getTickMax() { return tickMax; }
407
+ public int getTickMax() { return tickMax; }
408
+
386
-
409
+ public int getLeftSecond() { return calcLeftSecond(tick); }
410
+
411
+
412
+
387
- int getLeftSecond() { return (tick+PARTICLE_SIZE-1) / PARTICLE_SIZE; }
413
+ private static int calcLeftSecond(int tick) { return (tick + PARTICLE_SIZE - 1) / PARTICLE_SIZE; }
388
-
389
-
390
-
414
+
415
+
416
+
391
- void start(Listener listener) {
417
+ synchronized void start(Listener listener) {
418
+
419
+ if(timer != null)
420
+
421
+ throw new IllegalStateException();
392
422
 
393
423
  this.listener = listener;
394
424
 
395
- long millisInFuture = (tick+tickMax*(count*set-1))*1000L/PARTICLE_SIZE;
396
-
397
- firstTick = true;
425
+ timer = new Timer();
398
-
426
+
399
- countDownTimer = new CountDownTimer(millisInFuture, 1000L/PARTICLE_SIZE) { //[ms]
427
+ timer.scheduleAtFixedRate(new TickTask(), 1000L / PARTICLE_SIZE, 1000L / PARTICLE_SIZE); //[ms]
428
+
400
-
429
+ listener.start(Workout.this);
430
+
431
+ }
432
+
433
+
434
+
435
+ private class TickTask extends TimerTask {
436
+
401
- @Override
437
+ @Override
402
-
438
+
403
- public void onTick(long ignore) {
439
+ public void run() {
404
-
440
+
405
- if(firstTick) { //最初の onTick を無視
441
+ boolean finish = downTick();
442
+
406
-
443
+ final WorkoutProperties properties = new WorkoutSnapshot(Workout.this);
444
+
445
+ handler.post(new Runnable() {
446
+
407
- firstTick = false;
447
+ public void run() {
408
-
448
+
409
- return;
449
+ postProgress(properties);
410
450
 
411
451
  }
412
452
 
453
+ });
454
+
455
+ if(finish) {
456
+
457
+ synchronized(this) {
458
+
413
- downTick();
459
+ timer.cancel();
460
+
414
-
461
+ timer = null;
462
+
463
+ }
464
+
465
+ handler.post(new Runnable() {
466
+
467
+ public void run() {
468
+
415
- Workout.this.listener.progress(Workout.this);
469
+ postFinish(properties);
470
+
471
+ }
472
+
473
+ });
416
474
 
417
475
  }
418
476
 
419
- @Override
477
+ }
478
+
420
-
479
+ }
480
+
481
+
482
+
421
- public void onFinish() {
483
+ private boolean downTick() {
484
+
422
-
485
+ if(--tick <= 0) {
486
+
423
- onTick(0L); //終了時の Tick を発生(したように見せかける)
487
+ if(--count <= 0) {
424
-
488
+
425
- Workout.this.listener.finish(Workout.this);
489
+ if(--set <= 0) return true; //finish
426
-
490
+
427
- Workout.this.listener = null;
491
+ count = countMax;
428
492
 
429
493
  }
430
494
 
431
- }.start();
495
+ tick = tickMax;
432
-
433
- listener.start(Workout.this);
496
+
434
-
435
- }
497
+ }
498
+
436
-
499
+ return false;
500
+
501
+ }
502
+
503
+
504
+
505
+ private static class WorkoutSnapshot implements WorkoutProperties {
506
+
507
+ private int tick, tickMax;
508
+
437
- private void downTick() {
509
+ private int count, set;
510
+
511
+
512
+
438
-
513
+ WorkoutSnapshot(Workout wo) {
514
+
439
- if(--tick <= 0) {
515
+ this.tick = wo.tick;
440
-
516
+
441
- if(--count <= 0) {
517
+ this.tickMax = wo.tickMax;
442
-
443
- if(--set <= 0) return; //finish
518
+
444
-
445
- count = countMax;
519
+ this.count = wo.count;
520
+
521
+ this.set = wo.set;
522
+
523
+ }
524
+
525
+
526
+
527
+ public int getSet() { return set; }
528
+
529
+ public int getCount() { return count; }
530
+
531
+ public int getTick() { return tick; }
532
+
533
+ public int getTickMax() { return tickMax; }
534
+
535
+ public int getLeftSecond() { return calcLeftSecond(tick); }
536
+
537
+ }
538
+
539
+
540
+
541
+ private synchronized void postProgress(WorkoutProperties properties) {
542
+
543
+ if(listener != null) {
544
+
545
+ listener.progress(properties);
546
+
547
+ }
548
+
549
+ }
550
+
551
+
552
+
553
+ private synchronized void postFinish(WorkoutProperties properties) {
554
+
555
+ if(listener != null) {
556
+
557
+ listener.finish(properties);
558
+
559
+ listener = null;
560
+
561
+ }
562
+
563
+ }
564
+
565
+
566
+
567
+ synchronized void stop() {
568
+
569
+ if(timer != null) {
570
+
571
+ timer.cancel();
572
+
573
+ timer = null;
574
+
575
+ if(listener != null) {
576
+
577
+ listener.stop(this);
578
+
579
+ listener = null;
446
580
 
447
581
  }
448
582
 
449
- tick = tickMax;
450
-
451
- }
583
+ }
452
-
584
+
453
- }
585
+ }
454
-
455
-
456
-
586
+
587
+
588
+
457
- void stop() {
589
+ synchronized void reset() {
458
-
590
+
459
- if(countDownTimer != null) {
591
+ if(timer == null) {
460
-
461
- countDownTimer.cancel();
592
+
462
-
463
- countDownTimer = null;
464
-
465
- listener.stop(this);
593
+ this.count = countMax;
466
-
594
+
467
- listener = null;
595
+ this.set = setMax;
596
+
468
-
597
+ this.tick = tickMax;
598
+
469
- }
599
+ }
470
-
471
- }
472
-
473
-
474
-
475
- void reset() {
476
-
477
- this.count = countMax;
478
-
479
- this.set = setMax;
480
-
481
- this.tick = tickMax;
482
600
 
483
601
  }
484
602
 

1

Workout のイベント発生とカウントダウンのタイミングを変更

2020/05/13 15:50

投稿

jimbe
jimbe

スコア12670

test CHANGED
@@ -300,6 +300,8 @@
300
300
 
301
301
  import android.os.CountDownTimer;
302
302
 
303
+ import android.util.Log;
304
+
303
305
 
304
306
 
305
307
  class Workout {
@@ -318,7 +320,7 @@
318
320
 
319
321
 
320
322
 
321
- private static final int PARTICLE_SIZE = 2; //1秒を何tickに分けるか
323
+ private static final int PARTICLE_SIZE = 20; //1秒を何tickに分けるか
322
324
 
323
325
 
324
326
 
@@ -344,6 +346,8 @@
344
346
 
345
347
  private int count, set;
346
348
 
349
+ private boolean firstTick = false; //CountDownTimer の 最初の onTick を無視するため
350
+
347
351
 
348
352
 
349
353
  Workout(String name, int time, int rest_time, int count, int set, int set_during) {
@@ -380,7 +384,7 @@
380
384
 
381
385
  int getTickMax() { return tickMax; }
382
386
 
383
- int getLeftSecond() { return tick / PARTICLE_SIZE; }
387
+ int getLeftSecond() { return (tick+PARTICLE_SIZE-1) / PARTICLE_SIZE; }
384
388
 
385
389
 
386
390
 
@@ -390,28 +394,24 @@
390
394
 
391
395
  long millisInFuture = (tick+tickMax*(count*set-1))*1000L/PARTICLE_SIZE;
392
396
 
397
+ firstTick = true;
398
+
393
399
  countDownTimer = new CountDownTimer(millisInFuture, 1000L/PARTICLE_SIZE) { //[ms]
394
400
 
395
401
  @Override
396
402
 
397
- public void onTick(long millisUntilFinished) {
403
+ public void onTick(long ignore) {
398
-
404
+
399
- tick --;
405
+ if(firstTick) { //最初の onTick を無視
400
-
406
+
401
- if(tick < 0) {
407
+ firstTick = false;
402
-
403
- tick = tickMax - 1;
408
+
404
-
405
- if(--count <= 0) {
406
-
407
- set --;
409
+ return;
408
-
409
- count = countMax;
410
-
411
- }
412
410
 
413
411
  }
414
412
 
413
+ downTick();
414
+
415
415
  Workout.this.listener.progress(Workout.this);
416
416
 
417
417
  }
@@ -420,11 +420,7 @@
420
420
 
421
421
  public void onFinish() {
422
422
 
423
- tick = 0;
423
+ onTick(0L); //終了時の Tick を発生(したように見せかける)
424
-
425
- count = 0;
426
-
427
- set = 0;
428
424
 
429
425
  Workout.this.listener.finish(Workout.this);
430
426
 
@@ -438,6 +434,24 @@
438
434
 
439
435
  }
440
436
 
437
+ private void downTick() {
438
+
439
+ if(--tick <= 0) {
440
+
441
+ if(--count <= 0) {
442
+
443
+ if(--set <= 0) return; //finish
444
+
445
+ count = countMax;
446
+
447
+ }
448
+
449
+ tick = tickMax;
450
+
451
+ }
452
+
453
+ }
454
+
441
455
 
442
456
 
443
457
  void stop() {