forked from upstream-mirrors/OpenTracks
Make the app single process only, including the following fixes:
1) Simplify SharedPreferences management 2) Shut down signalManager/splitManager to avoid random crashes 3) Get rid of sharedPreferencesChanged from the service interface All tests pass.
This commit is contained in:
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
package com.google.android.apps.mytracks.services;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.apps.mytracks.MyTracksConstants;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* This class will manage a period task executer.
|
||||
*
|
||||
@@ -26,13 +26,12 @@ import com.google.android.apps.mytracks.MyTracksConstants;
|
||||
*/
|
||||
public class TaskExecuterManager {
|
||||
|
||||
int frequency;
|
||||
PeriodicTask task;
|
||||
PeriodicTaskExecuter executer;
|
||||
private int frequency;
|
||||
private PeriodicTask task;
|
||||
private PeriodicTaskExecuter executer;
|
||||
|
||||
public TaskExecuterManager(int frequency,
|
||||
PeriodicTask task,
|
||||
TrackRecordingService service) {
|
||||
public TaskExecuterManager(int frequency, PeriodicTask task,
|
||||
TrackRecordingService service) {
|
||||
this.task = task;
|
||||
setFrequency(frequency, service);
|
||||
}
|
||||
@@ -69,7 +68,7 @@ public class TaskExecuterManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the task at the current frequency.
|
||||
* Restores the task at the current frequency.
|
||||
*/
|
||||
public void restore() {
|
||||
if (frequency > 0) {
|
||||
@@ -77,4 +76,13 @@ public class TaskExecuterManager {
|
||||
executer.scheduleTask(frequency * 60000);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down this executer.
|
||||
*/
|
||||
public void shutdown() {
|
||||
if (executer != null) {
|
||||
executer.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user