Finished renaming: TrackPointCreator was still referenced as HandlerServer.

This commit is contained in:
Dennis Guse
2021-08-29 12:23:14 +02:00
parent fa02ba9c69
commit 9cb3d8c1bb
9 changed files with 103 additions and 103 deletions
@@ -81,19 +81,19 @@ class TrackRecordingManager {
insertTrackPoint(trackId, segmentStartTrackPoint);
}
void pause(TrackPointCreator handlerServer) {
void pause(TrackPointCreator trackPointCreator) {
if (lastTrackPoint != null) {
insertTrackPointIfNewer(trackId, lastTrackPoint);
}
insertTrackPoint(trackId, handlerServer.createSegmentEnd());
insertTrackPoint(trackId, trackPointCreator.createSegmentEnd());
}
void end(TrackPointCreator handlerServer) {
void end(TrackPointCreator trackPointCreator) {
if (lastTrackPoint != null) {
insertTrackPointIfNewer(trackId, lastTrackPoint);
}
TrackPoint segmentEnd = handlerServer.createSegmentEnd();
TrackPoint segmentEnd = trackPointCreator.createSegmentEnd();
insertTrackPoint(trackId, segmentEnd);
trackId = null;
@@ -103,12 +103,12 @@ class TrackRecordingManager {
isIdle = false;
}
Pair<Track, Pair<TrackPoint, SensorDataSet>> get(TrackPointCreator handlerServer) {
if (handlerServer == null) {
Pair<Track, Pair<TrackPoint, SensorDataSet>> get(TrackPointCreator trackPointCreator) {
if (trackPointCreator == null) {
return null;
}
TrackStatisticsUpdater tmpTrackStatisticsUpdater = getTrackStatisticsUpdater();
Pair<TrackPoint, SensorDataSet> current = handlerServer.createCurrentTrackPoint(lastTrackPoint);
Pair<TrackPoint, SensorDataSet> current = trackPointCreator.createCurrentTrackPoint(lastTrackPoint);
tmpTrackStatisticsUpdater.addTrackPoint(current.first, recordingDistanceInterval);
@@ -112,7 +112,7 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
}
handlerServer.onSharedPreferenceChanged(sharedPreferences, key);
trackPointCreator.onSharedPreferenceChanged(sharedPreferences, key);
trackRecordingManager.onSharedPreferenceChanged(sharedPreferences, key);
}
};
@@ -122,7 +122,7 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
private final Binder binder = new Binder();
private TrackPointCreator handlerServer; //TODO Move to TrackRecordingManager?
private TrackPointCreator trackPointCreator; //TODO Move to TrackRecordingManager?
private RecordingStatus recordingStatus;
private MutableLiveData<RecordingStatus> recordingStatusObservable;
@@ -141,7 +141,7 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
recordingDataObservable = new MutableLiveData<>(NOT_RECORDING);
trackRecordingManager = new TrackRecordingManager(this);
handlerServer = new TrackPointCreator(this);
trackPointCreator = new TrackPointCreator(this);
voiceAnnouncementManager = new VoiceAnnouncementManager(this);
@@ -166,8 +166,8 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
public void onDestroy() {
handler = null;
handlerServer.stop();
handlerServer = null;
trackPointCreator.stop();
trackPointCreator = null;
// Reverse order from onCreate
showNotification(false); //TODO Why?
@@ -219,7 +219,7 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
}
// Set recording status
Track.Id trackId = trackRecordingManager.start(handlerServer.createSegmentStartManual());
Track.Id trackId = trackRecordingManager.start(trackPointCreator.createSegmentStartManual());
updateRecordingStatus(RecordingStatus.record(trackId));
startRecording();
@@ -233,8 +233,8 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
* @param trackId the id of the track to be resumed.
*/
public void resumeTrack(Track.Id trackId) {
handlerServer.resetSensorData();
trackRecordingManager.resume(trackId, handlerServer.createSegmentStartManual());
trackPointCreator.resetSensorData();
trackRecordingManager.resume(trackId, trackPointCreator.createSegmentStartManual());
// Set recording status
updateRecordingStatus(RecordingStatus.record(trackId));
@@ -272,7 +272,7 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
private void startGps() {
wakeLock = SystemUtils.acquireWakeLock(this, wakeLock);
handlerServer.start(this);
trackPointCreator.start(this);
showNotification(true);
}
@@ -291,7 +291,7 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
updateRecordingStatus(STATUS_DEFAULT);
if (!wasPause) {
trackRecordingManager.end(handlerServer);
trackRecordingManager.end(trackPointCreator);
}
ExportUtils.postWorkoutExport(this, trackId, new ExportServiceResultReceiver(new Handler(), this));
@@ -309,7 +309,7 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
// Set recording status
updateRecordingStatus(recordingStatus.pause());
trackRecordingManager.pause(handlerServer);
trackRecordingManager.pause(trackPointCreator);
endRecording(false);
@@ -333,7 +333,7 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
voiceAnnouncementManager.shutdown();
// Update instance variables
handlerServer.stop();
trackPointCreator.stop();
stopGps(trackStopped);
}
@@ -350,7 +350,7 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
void stopGps(boolean shutdown) {
if (!isRecording()) return;
handlerServer.stop();
trackPointCreator.stop();
showNotification(false);
wakeLock = SystemUtils.releaseWakeLock(wakeLock);
if (shutdown) {
@@ -410,8 +410,8 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
@Deprecated
@VisibleForTesting
public TrackPointCreator getHandlerServer() {
return handlerServer;
public TrackPointCreator getTrackPointCreator() {
return trackPointCreator;
}
public LiveData<GpsStatusValue> getGpsStatusObservable() {
@@ -430,15 +430,15 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
// Compute temporary track statistics using sensorData and update time.
TrackPointCreator localHandlerServer = this.handlerServer;
TrackPointCreator localTrackPointCreator = this.trackPointCreator;
VoiceAnnouncementManager localVoiceAnnouncementManager = this.voiceAnnouncementManager;
if (localHandlerServer == null || localVoiceAnnouncementManager == null) {
if (localTrackPointCreator == null || localVoiceAnnouncementManager == null) {
// when this happens, no recording is running and we should not send any notifications.
//TODO This implementation is not a good idea; rather solve the issue for this properly
return;
}
Pair<Track, Pair<TrackPoint, SensorDataSet>> data = trackRecordingManager.get(handlerServer);
Pair<Track, Pair<TrackPoint, SensorDataSet>> data = trackRecordingManager.get(trackPointCreator);
if (data == null) {
Log.w(TAG, "Requesting data if not recording is taking place, should not be done.");
return;
@@ -25,14 +25,14 @@ public class LocationHandler implements LocationListener, GpsStatus.GpsStatusLis
private final String TAG = LocationHandler.class.getSimpleName();
private LocationManager locationManager;
private final TrackPointCreator handlerServer;
private final TrackPointCreator trackPointCreator;
private GpsStatus gpsStatus;
private Duration gpsInterval;
private Distance thresholdHorizontalAccuracy;
private TrackPoint lastTrackPoint;
public LocationHandler(TrackPointCreator handlerServer) {
this.handlerServer = handlerServer;
public LocationHandler(TrackPointCreator trackPointCreator) {
this.trackPointCreator = trackPointCreator;
}
public void onStart(@NonNull Context context, SharedPreferences sharedPreferences) {
@@ -92,7 +92,7 @@ public class LocationHandler implements LocationListener, GpsStatus.GpsStatusLis
}
/**
* Checks if location is valid and builds a track point that will be send through HandlerServer.
* Checks if location is valid and builds a track point that will be send through TrackPointCreator.
*
* @param location {@link Location} object.
*/
@@ -103,7 +103,7 @@ public class LocationHandler implements LocationListener, GpsStatus.GpsStatusLis
return;
}
TrackPoint trackPoint = new TrackPoint(location, handlerServer.createNow());
TrackPoint trackPoint = new TrackPoint(location, trackPointCreator.createNow());
boolean isAccurate = trackPoint.fulfillsAccuracy(thresholdHorizontalAccuracy);
boolean isValid = LocationUtils.isValidLocation(location);
@@ -122,7 +122,7 @@ public class LocationHandler implements LocationListener, GpsStatus.GpsStatusLis
}
lastTrackPoint = trackPoint;
handlerServer.onNewTrackPoint(trackPoint, thresholdHorizontalAccuracy);
trackPointCreator.onNewTrackPoint(trackPoint, thresholdHorizontalAccuracy);
}
@Override
@@ -167,6 +167,6 @@ public class LocationHandler implements LocationListener, GpsStatus.GpsStatusLis
*/
@Override
public void onGpsStatusChanged(GpsStatusValue prevStatus, GpsStatusValue currentStatus) {
handlerServer.sendGpsStatus(currentStatus);
trackPointCreator.sendGpsStatus(currentStatus);
}
}
@@ -77,7 +77,7 @@ public class TrackPointCreator {
altitudeSumManager.reset();
}
//TODO TrackPoint should be created by HandlerServer; instead of in the TrackRecordingService.
//TODO TrackPoint should be created by TrackPointCreator; instead of in the TrackRecordingService.
@Deprecated
public SensorDataSet fill(TrackPoint trackPoint) {
SensorDataSet sensorDataSet = remoteSensorManager.fill(trackPoint);