forked from upstream-mirrors/OpenTracks
GPSStatus: update initial and final status.
This commit is contained in:
@@ -577,7 +577,10 @@ public class TrackRecordingService extends Service implements HandlerServer.Hand
|
||||
public void newGpsStatus(GpsStatusValue gpsStatusValue) {
|
||||
notificationManager.updateContent(getString(gpsStatusValue.message));
|
||||
|
||||
gpsStatusObservable.postValue(gpsStatusValue);
|
||||
//TODO This check should not be necessary, but prevents a crash; somehow the shutdown is not working correctly as we should not receive a notification then.
|
||||
if (gpsStatusObservable != null) {
|
||||
gpsStatusObservable.postValue(gpsStatusValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -767,13 +770,14 @@ public class TrackRecordingService extends Service implements HandlerServer.Hand
|
||||
return isRecording() && !isPaused();
|
||||
}
|
||||
|
||||
public RecordingStatus pause() {
|
||||
return new RecordingStatus(getTrackId(), true);
|
||||
}
|
||||
|
||||
public RecordingStatus record(@NonNull Track.Id track) {
|
||||
return new RecordingStatus(trackId, false);
|
||||
}
|
||||
// TODO Use
|
||||
// public RecordingStatus pause() {
|
||||
// return new RecordingStatus(getTrackId(), true);
|
||||
// }
|
||||
//
|
||||
// public RecordingStatus record(@NonNull Track.Id trackId) {
|
||||
// return new RecordingStatus(trackId, false);
|
||||
// }
|
||||
|
||||
public RecordingStatus stop() {
|
||||
return STATUS_DEFAULT;
|
||||
|
||||
@@ -14,7 +14,7 @@ import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||
import de.dennisguse.opentracks.util.PreferencesUtils;
|
||||
|
||||
/**
|
||||
* This class handle GPS status according to received locations and some thresholds.
|
||||
* This class handle GPS status according to received locations` and some thresholds.
|
||||
*/
|
||||
//TODO should handle sharedpreference changes
|
||||
class GpsStatus {
|
||||
@@ -56,6 +56,7 @@ class GpsStatus {
|
||||
|
||||
public void stop() {
|
||||
stopped = true;
|
||||
sendStatus(gpsStatus, GpsStatusValue.GPS_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,10 +76,15 @@ class GpsStatus {
|
||||
gpsStatusHandler = new Handler();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
client.onGpsStatusChanged(GpsStatusValue.GPS_NONE, GpsStatusValue.GPS_ENABLED);
|
||||
}
|
||||
|
||||
/**
|
||||
* The client that uses GpsStatus has to call this method to stop the Runnable if needed.
|
||||
*/
|
||||
public void stop() {
|
||||
client.onGpsStatusChanged(gpsStatus, GpsStatusValue.GPS_NONE);
|
||||
client = null;
|
||||
if (gpsStatusRunner != null) {
|
||||
gpsStatusRunner.stop();
|
||||
|
||||
@@ -63,10 +63,6 @@ public class HandlerServer {
|
||||
service.newGpsStatus(gpsStatusValue);
|
||||
}
|
||||
|
||||
public GpsStatusValue getGpsStatus() {
|
||||
return locationHandler.getGpsStatus();
|
||||
}
|
||||
|
||||
public interface HandlerServerInterface {
|
||||
void newTrackPoint(TrackPoint trackPoint, int gpsAccuracy);
|
||||
void newGpsStatus(GpsStatusValue gpsStatusValue);
|
||||
|
||||
@@ -38,6 +38,7 @@ class LocationHandler implements HandlerServer.Handler, LocationListener, GpsSta
|
||||
gpsStatus = new GpsStatus(context, this);
|
||||
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
registerLocationListener();
|
||||
gpsStatus.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user