forked from upstream-mirrors/OpenTracks
Removed unnecessary RemoteSensorManagerFactory.
TrackRecordingService is only using BluetoothRemoteSensorManager and thus factory pattern is not required.
This commit is contained in:
@@ -58,7 +58,6 @@ import de.dennisguse.opentracks.content.Waypoint.WaypointType;
|
||||
import de.dennisguse.opentracks.content.WaypointCreationRequest;
|
||||
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
||||
import de.dennisguse.opentracks.services.sensors.BluetoothRemoteSensorManager;
|
||||
import de.dennisguse.opentracks.services.sensors.RemoteSensorManagerFactory;
|
||||
import de.dennisguse.opentracks.services.tasks.AnnouncementPeriodicTaskFactory;
|
||||
import de.dennisguse.opentracks.services.tasks.PeriodicTaskExecutor;
|
||||
import de.dennisguse.opentracks.services.tasks.SplitPeriodicTaskFactory;
|
||||
@@ -266,7 +265,7 @@ public class TrackRecordingService extends Service {
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (remoteSensorManager != null) {
|
||||
RemoteSensorManagerFactory.releaseSystemSensorManager();
|
||||
remoteSensorManager.stop();
|
||||
remoteSensorManager = null;
|
||||
}
|
||||
|
||||
@@ -595,7 +594,7 @@ public class TrackRecordingService extends Service {
|
||||
*/
|
||||
private void startRecording(boolean trackStarted) {
|
||||
// Update instance variables
|
||||
remoteSensorManager = RemoteSensorManagerFactory.getSystemSensorManager(this);
|
||||
remoteSensorManager = new BluetoothRemoteSensorManager(this);
|
||||
lastLocation = null;
|
||||
currentSegmentHasLocation = false;
|
||||
isIdle = false;
|
||||
@@ -693,7 +692,7 @@ public class TrackRecordingService extends Service {
|
||||
|
||||
// Update instance variables
|
||||
if (remoteSensorManager != null) {
|
||||
RemoteSensorManagerFactory.releaseSystemSensorManager();
|
||||
remoteSensorManager.stop();
|
||||
remoteSensorManager = null;
|
||||
}
|
||||
lastLocation = null;
|
||||
|
||||
+4
-2
@@ -34,7 +34,8 @@ import de.dennisguse.opentracks.util.PreferencesUtils;
|
||||
import de.dennisguse.opentracks.util.UnitConversions;
|
||||
|
||||
/**
|
||||
* Bluetooth sensor manager.
|
||||
* Bluetooth LE sensor manager.
|
||||
* Should only be instantiated once!
|
||||
*
|
||||
* @author Sandor Dornbush
|
||||
*/
|
||||
@@ -49,6 +50,7 @@ public class BluetoothRemoteSensorManager {
|
||||
private final Context context;
|
||||
|
||||
private final SharedPreferences sharedPreferences;
|
||||
|
||||
// Handler that gets information back from the bluetoothConnectionManager
|
||||
private final Handler messageHandler = new Handler(Looper.getMainLooper()) {
|
||||
@Override
|
||||
@@ -107,7 +109,7 @@ public class BluetoothRemoteSensorManager {
|
||||
/**
|
||||
* @param context the context
|
||||
*/
|
||||
BluetoothRemoteSensorManager(Context context) {
|
||||
public BluetoothRemoteSensorManager(Context context) {
|
||||
this.context = context;
|
||||
sharedPreferences = PreferencesUtils.getSharedPreferences(context);
|
||||
}
|
||||
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright 2009 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package de.dennisguse.opentracks.services.sensors;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* A factory of {@link BluetoothRemoteSensorManager}.
|
||||
*
|
||||
* @author Sandor Dornbush
|
||||
*/
|
||||
public class RemoteSensorManagerFactory {
|
||||
|
||||
private static BluetoothRemoteSensorManager remoteSensorManagerSystem = null;
|
||||
|
||||
|
||||
private RemoteSensorManagerFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the system sensor manager.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
public static BluetoothRemoteSensorManager getSystemSensorManager(Context context) {
|
||||
releaseSystemSensorManager();
|
||||
remoteSensorManagerSystem = getSensorManager(context);
|
||||
remoteSensorManagerSystem.start();
|
||||
return remoteSensorManagerSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases the system sensor manager.
|
||||
*/
|
||||
public static void releaseSystemSensorManager() {
|
||||
if (remoteSensorManagerSystem != null) {
|
||||
remoteSensorManagerSystem.stop();
|
||||
}
|
||||
remoteSensorManagerSystem = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sensor manager.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
private static BluetoothRemoteSensorManager getSensorManager(Context context) {
|
||||
return new BluetoothRemoteSensorManager(context);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user