Addressed Sandor's comments and added more unit tests and fixed 2 NPEs.

This commit is contained in:
Bartlomiej Niechwiej
2010-11-11 10:55:15 -08:00
parent 30f5d6dc85
commit 7e1eae6681
3 changed files with 69 additions and 4 deletions
@@ -52,6 +52,11 @@ public class PeriodicTaskExecuter {
* @param interval The interval in milliseconds
*/
public void scheduleTask(long interval) {
// TODO: Decouple service from this class once and forever.
if (!service.isRecording()) {
return;
}
timer.cancel();
timer.purge();
timer = new Timer();
@@ -73,6 +73,11 @@ public class SplitManager {
* Calculates the next distance that a split should be inserted at.
*/
public void calculateNextSplit() {
// TODO: Decouple service from this class once and forever.
if (!service.isRecording()) {
return;
}
if (splitFrequency >= 0) {
nextSplitDistance = Double.MAX_VALUE;
Log.d(MyTracksConstants.TAG,
@@ -121,6 +126,12 @@ public class SplitManager {
*/
public void setSplitFrequency(int splitFrequency) {
this.splitFrequency = splitFrequency;
// TODO: Decouple service from this class once and forever.
if (!service.isRecording()) {
return;
}
if (splitFrequency < 1) {
if (splitExecuter != null) {
splitExecuter.shutdown();