Address one last comment.

This commit is contained in:
Sandor Dornbush
2010-12-15 16:53:38 -08:00
parent fa713eac4a
commit 0da0280156
@@ -965,33 +965,31 @@ public class TrackRecordingService extends Service implements LocationListener {
@Override @Override
public boolean isRecording() { public boolean isRecording() {
checkService();
return service.isRecording();
}
private void checkService() {
if (service == null) { if (service == null) {
throw new IllegalStateException("The service has been already detached!"); throw new IllegalStateException("The service has been already detached!");
} }
return service.isRecording();
} }
@Override @Override
public long getRecordingTrackId() { public long getRecordingTrackId() {
if (service == null) { checkService();
throw new IllegalStateException("The service has been already detached!");
}
return service.recordingTrackId; return service.recordingTrackId;
} }
@Override @Override
public boolean hasRecorded() { public boolean hasRecorded() {
if (service == null) { checkService();
throw new IllegalStateException("The service has been already detached!");
}
return service.providerUtils.getLastTrackId() >= 0; return service.providerUtils.getLastTrackId() >= 0;
} }
@Override @Override
public long startNewTrack() { public long startNewTrack() {
if (service == null) { checkService();
throw new IllegalStateException("The service has been already detached!");
}
return service.startNewTrack(); return service.startNewTrack();
} }
@@ -1002,25 +1000,19 @@ public class TrackRecordingService extends Service implements LocationListener {
* @return the unique ID of the inserted marker * @return the unique ID of the inserted marker
*/ */
public long insertWaypoint(WaypointCreationRequest request) { public long insertWaypoint(WaypointCreationRequest request) {
if (service == null) { checkService();
throw new IllegalStateException("The service has been already detached!");
}
return service.insertWaypoint(request); return service.insertWaypoint(request);
} }
@Override @Override
public void endCurrentTrack() { public void endCurrentTrack() {
if (service == null) { checkService();
throw new IllegalStateException("The service has been already detached!");
}
service.endCurrentTrack(); service.endCurrentTrack();
} }
@Override @Override
public void deleteAllTracks() { public void deleteAllTracks() {
if (service == null) { checkService();
throw new IllegalStateException("The service has been already detached!");
}
if (isRecording()) { if (isRecording()) {
throw new IllegalStateException("Cannot delete all tracks while recording!"); throw new IllegalStateException("Cannot delete all tracks while recording!");
} }
@@ -1029,14 +1021,13 @@ public class TrackRecordingService extends Service implements LocationListener {
@Override @Override
public void recordLocation(Location loc) { public void recordLocation(Location loc) {
if (service == null) { checkService();
throw new IllegalStateException("The service has been already detached!");
}
service.onLocationChanged(loc); service.onLocationChanged(loc);
} }
@Override @Override
public byte[] getSensorData() { public byte[] getSensorData() {
checkService();
if (service.sensorManager == null) { if (service.sensorManager == null) {
Log.d(MyTracksConstants.TAG, "No sensor manager for data."); Log.d(MyTracksConstants.TAG, "No sensor manager for data.");
return null; return null;
@@ -1050,6 +1041,7 @@ public class TrackRecordingService extends Service implements LocationListener {
@Override @Override
public int getSensorState() { public int getSensorState() {
checkService();
if (service.sensorManager == null) { if (service.sensorManager == null) {
Log.d(MyTracksConstants.TAG, "No sensor manager for data."); Log.d(MyTracksConstants.TAG, "No sensor manager for data.");
return Sensor.SensorState.NONE.getNumber(); return Sensor.SensorState.NONE.getNumber();