@@ -19,21 +19,21 @@ public Timer(Runnable onCountdownComplete) {
1919 }
2020
2121 public void startCountUp () {
22- if (state != TimerState .OFF ) return ;
22+ if (this . state != TimerState .OFF ) return ;
2323 this .direction = TimerDirection .COUNT_UP ;
2424 this .seconds = 0 ;
25- start ();
25+ this . start ();
2626 }
2727
2828 public void startCountDown (long seconds ) {
29- if (state != TimerState .OFF ) return ;
29+ if (this . state != TimerState .OFF ) return ;
3030 this .direction = TimerDirection .COUNT_DOWN ;
3131 this .seconds = seconds ;
32- start ();
32+ this . start ();
3333 }
3434
3535 public void reset () {
36- if (state == TimerState .OFF ) return ;
36+ if (this . state == TimerState .OFF ) return ;
3737 this .direction = TimerDirection .COUNT_UP ;
3838 this .seconds = 0 ;
3939 this .state = TimerState .OFF ;
@@ -51,7 +51,7 @@ public Component getDisplay() {
5151 (String .valueOf (seconds ).length () > 1 ? "" : "0" ) + seconds
5252 ));
5353
54- if (state == TimerState .PAUSED ) component .decorate (TextDecoration .ITALIC ).color (NamedTextColor .RED );
54+ if (this . state == TimerState .PAUSED ) component .decorate (TextDecoration .ITALIC ).color (NamedTextColor .RED );
5555 else component .color (NamedTextColor .GREEN );
5656 return component .decorate (TextDecoration .BOLD );
5757 }
@@ -61,16 +61,16 @@ private void start() {
6161 timer .schedule (new TimerTask () {
6262 @ Override
6363 public void run () {
64- if (state == TimerState .OFF ) cancel ();
65- if (state == TimerState .PAUSED ) return ;
66-
67- if (direction == TimerDirection .COUNT_UP ) seconds ++;
68- else if (direction == TimerDirection .COUNT_DOWN ) {
69- seconds --;
70- if (seconds < 0 ) {
71- seconds = 0 ;
72- state = TimerState .PAUSED ;
73- onCountdownComplete .run ();
64+ if (Timer . this . state == TimerState .OFF ) this . cancel ();
65+ if (Timer . this . state == TimerState .PAUSED ) return ;
66+
67+ if (Timer . this . direction == TimerDirection .COUNT_UP ) Timer . this . seconds ++;
68+ else if (Timer . this . direction == TimerDirection .COUNT_DOWN ) {
69+ Timer . this . seconds --;
70+ if (Timer . this . seconds < 0 ) {
71+ Timer . this . seconds = 0 ;
72+ Timer . this . state = TimerState .PAUSED ;
73+ Timer . this . onCountdownComplete .run ();
7474 }
7575 }
7676 }
@@ -99,7 +99,7 @@ public long resolveSeconds(String timeValue) {
9999 case "y" -> duration * 60 * 60 * 24 * 7 * 52 ;
100100 default -> {
101101 try {
102- yield resolveSeconds (Integer .parseInt (timeValue ) + "s" );
102+ yield this . resolveSeconds (Integer .parseInt (timeValue ) + "s" );
103103 } catch (NumberFormatException e ) {
104104 yield -1 ;
105105 }
@@ -108,23 +108,23 @@ public long resolveSeconds(String timeValue) {
108108 }
109109
110110 public TimerDirection getDirection () {
111- return direction ;
111+ return this . direction ;
112112 }
113113
114114 public void setDirection (TimerDirection direction ) {
115115 this .direction = direction ;
116116 }
117117
118118 public TimerState getState () {
119- return state ;
119+ return this . state ;
120120 }
121121
122122 public void setState (TimerState state ) {
123123 this .state = state ;
124124 }
125125
126126 public long getSeconds () {
127- return seconds ;
127+ return this . seconds ;
128128 }
129129
130130 public void setSeconds (long seconds ) {
0 commit comments