Fix bug where addOneMinute() was extending paused Timers whose end times have passed by more than a minute
This commit is contained in:
parent
8022536ec8
commit
0163fd7b7e
@ -127,10 +127,12 @@ public abstract class Timer extends ObjectWithId implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addOneMinute() {
|
public void addOneMinute() {
|
||||||
// Allow extending even if paused.
|
if (!isRunning()) {
|
||||||
// if (!isRunning())
|
resume();
|
||||||
// throw new IllegalStateException("Cannot extend a timer that is not running");
|
addOneMinute(); // recursion!
|
||||||
if (expired()) {
|
pause();
|
||||||
|
return;
|
||||||
|
} else if (expired()) {
|
||||||
endTime = SystemClock.elapsedRealtime() + MINUTE;
|
endTime = SystemClock.elapsedRealtime() + MINUTE;
|
||||||
// If the timer's normal duration is >= MINUTE, then an extra run time of one minute
|
// If the timer's normal duration is >= MINUTE, then an extra run time of one minute
|
||||||
// will still be within the normal duration. Thus, the progress calculation does not
|
// will still be within the normal duration. Thus, the progress calculation does not
|
||||||
@ -140,11 +142,12 @@ public abstract class Timer extends ObjectWithId implements Parcelable {
|
|||||||
// This scales the progress bar to a full minute.
|
// This scales the progress bar to a full minute.
|
||||||
duration = MINUTE;
|
duration = MINUTE;
|
||||||
}
|
}
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
endTime += MINUTE;
|
endTime += MINUTE;
|
||||||
duration += MINUTE;
|
duration += MINUTE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasStarted() {
|
public boolean hasStarted() {
|
||||||
return endTime > 0;
|
return endTime > 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user