forked from upstream-mirrors/OpenTracks
Cleanup: removed SensorConnector interface.
Preparation for refactoring.
This commit is contained in:
@@ -34,7 +34,7 @@ import de.dennisguse.opentracks.settings.PreferencesUtils;
|
|||||||
* TODO: listen for Bluetooth enabled/disabled events.
|
* TODO: listen for Bluetooth enabled/disabled events.
|
||||||
* @author Sandor Dornbush
|
* @author Sandor Dornbush
|
||||||
*/
|
*/
|
||||||
public class BluetoothRemoteSensorManager implements SensorConnector, SharedPreferences.OnSharedPreferenceChangeListener {
|
public class BluetoothRemoteSensorManager implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
private static final String TAG = BluetoothRemoteSensorManager.class.getSimpleName();
|
private static final String TAG = BluetoothRemoteSensorManager.class.getSimpleName();
|
||||||
|
|
||||||
@@ -62,16 +62,14 @@ public class BluetoothRemoteSensorManager implements SensorConnector, SharedPref
|
|||||||
this.runningSpeedAndCadence = new BluetoothConnectionManager(bluetoothAdapter, observer, new BluetoothHandlerRunningSpeedAndCadence());
|
this.runningSpeedAndCadence = new BluetoothConnectionManager(bluetoothAdapter, observer, new BluetoothHandlerRunningSpeedAndCadence());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void start() {
|
||||||
public void start(Context context, Handler handler) {
|
|
||||||
started = true;
|
started = true;
|
||||||
|
|
||||||
// Triggers connection startup
|
// Triggers connection startup
|
||||||
onSharedPreferenceChanged(null, null);
|
onSharedPreferenceChanged(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public synchronized void stop() {
|
||||||
public synchronized void stop(Context context) {
|
|
||||||
heartRate.disconnect();
|
heartRate.disconnect();
|
||||||
temperature.disconnect();
|
temperature.disconnect();
|
||||||
cyclingCadence.disconnect();
|
cyclingCadence.disconnect();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import de.dennisguse.opentracks.settings.PreferencesUtils;
|
|||||||
/**
|
/**
|
||||||
* Estimates the altitude gain and altitude loss using the device's pressure sensor (i.e., barometer).
|
* Estimates the altitude gain and altitude loss using the device's pressure sensor (i.e., barometer).
|
||||||
*/
|
*/
|
||||||
public class GainManager implements SensorConnector {
|
public class GainManager {
|
||||||
|
|
||||||
private static final String TAG = GainManager.class.getSimpleName();
|
private static final String TAG = GainManager.class.getSimpleName();
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ public class GainManager implements SensorConnector {
|
|||||||
PreferencesUtils.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
|
PreferencesUtils.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop(Context context) {
|
public void stop() {
|
||||||
Log.d(TAG, "Stop");
|
Log.d(TAG, "Stop");
|
||||||
this.context = null;
|
this.context = null;
|
||||||
this.handler = null;
|
this.handler = null;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import de.dennisguse.opentracks.settings.PreferencesUtils;
|
|||||||
import de.dennisguse.opentracks.util.PermissionRequester;
|
import de.dennisguse.opentracks.util.PermissionRequester;
|
||||||
|
|
||||||
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
|
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
|
||||||
public class GpsManager implements SensorConnector, LocationListenerCompat, GpsStatusManager.GpsStatusListener, SharedPreferences.OnSharedPreferenceChangeListener {
|
public class GpsManager implements LocationListenerCompat, GpsStatusManager.GpsStatusListener, SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
private final String TAG = GpsManager.class.getSimpleName();
|
private final String TAG = GpsManager.class.getSimpleName();
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ public class GpsManager implements SensorConnector, LocationListenerCompat, GpsS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"MissingPermission"})
|
@SuppressWarnings({"MissingPermission"})
|
||||||
public void stop(Context context) {
|
public void stop() {
|
||||||
if (isStarted()) {
|
if (isStarted()) {
|
||||||
LocationManagerCompat.removeUpdates(locationManager, this);
|
LocationManagerCompat.removeUpdates(locationManager, this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Handler;
|
|
||||||
|
|
||||||
public interface SensorConnector {
|
|
||||||
|
|
||||||
void start(Context context, Handler handler);
|
|
||||||
|
|
||||||
void stop(Context context);
|
|
||||||
}
|
|
||||||
@@ -85,19 +85,19 @@ public class SensorManager implements SharedPreferences.OnSharedPreferenceChange
|
|||||||
|
|
||||||
gpsManager.start(context, handler);
|
gpsManager.start(context, handler);
|
||||||
altitudeSumManager.start(context, handler);
|
altitudeSumManager.start(context, handler);
|
||||||
bluetoothSensorManager.start(context, handler);
|
bluetoothSensorManager.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop(Context context) {
|
public void stop(Context context) {
|
||||||
wakeLock = SystemUtils.releaseWakeLock(wakeLock);
|
wakeLock = SystemUtils.releaseWakeLock(wakeLock);
|
||||||
|
|
||||||
bluetoothSensorManager.stop(context);
|
bluetoothSensorManager.stop();
|
||||||
bluetoothSensorManager = null;
|
bluetoothSensorManager = null;
|
||||||
|
|
||||||
altitudeSumManager.stop(context);
|
altitudeSumManager.stop();
|
||||||
altitudeSumManager = null;
|
altitudeSumManager = null;
|
||||||
|
|
||||||
gpsManager.stop(context);
|
gpsManager.stop();
|
||||||
gpsManager = null;
|
gpsManager = null;
|
||||||
|
|
||||||
sensorDataAggregator.clear();
|
sensorDataAggregator.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user