forked from upstream-mirrors/OpenTracks
Cleanup.
This commit is contained in:
@@ -42,8 +42,11 @@ class LocationHandler implements LocationListener, GpsStatus.GpsStatusListener {
|
||||
}
|
||||
|
||||
public void onStop() {
|
||||
unregisterLocationListener();
|
||||
locationManager = null;
|
||||
if (locationManager != null) {
|
||||
locationManager.removeUpdates(this);
|
||||
locationManager = null;
|
||||
}
|
||||
|
||||
if (gpsStatus != null) {
|
||||
gpsStatus.stop();
|
||||
gpsStatus = null;
|
||||
@@ -63,9 +66,7 @@ class LocationHandler implements LocationListener, GpsStatus.GpsStatusListener {
|
||||
locationListenerPolicy = new AbsoluteLocationListenerPolicy(Duration.ofSeconds(minRecordingInterval));
|
||||
}
|
||||
|
||||
if (locationManager != null) {
|
||||
registerLocationListener();
|
||||
}
|
||||
registerLocationListener();
|
||||
}
|
||||
if (PreferencesUtils.isKey(context, R.string.recording_gps_accuracy_key, key)) {
|
||||
recordingGpsAccuracy = PreferencesUtils.getRecordingGPSAccuracy(sharedPreferences, context);
|
||||
@@ -153,15 +154,6 @@ class LocationHandler implements LocationListener, GpsStatus.GpsStatusListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void unregisterLocationListener() {
|
||||
if (locationManager == null) {
|
||||
Log.e(TAG, "locationManager is null.");
|
||||
return;
|
||||
}
|
||||
locationManager.removeUpdates(this);
|
||||
locationManager = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from {@link GpsStatus} to inform that GPS status has changed from prevStatus to currentStatus.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user