Change code style.

This commit is contained in:
youtaol
2013-10-30 17:42:24 +08:00
parent 7cc1f878b4
commit 4907dc26a0
4 changed files with 26 additions and 18 deletions
@@ -200,7 +200,7 @@ public class TrackEditActivity extends AbstractMyTracksActivity
myTracksProviderUtils.updateTrack(track);
TrackRecordingServiceConnectionUtils.updateCalorie(trackRecordingServiceConnection);
} else {
CalorieUtils.updateTrackStatistics(getApplicationContext(), -1, track);
CalorieUtils.updateCalorie(getApplicationContext(), -1, track);
// Update data with new calorie.
myTracksProviderUtils.updateTrack(track);
@@ -1358,13 +1358,11 @@ public class TrackRecordingService extends Service {
}
/**
* Updates the calorie of current recording track after the current
* track is edited by user.
* Updates the calorie of current recording track after the current track is
* edited by user.
*/
public void updateCalorie() {
if (myTracksLocationManager == null || executorService == null
|| !myTracksLocationManager.isAllowed() || executorService.isShutdown()
|| executorService.isTerminated()) {
if (executorService == null || executorService.isShutdown() || executorService.isTerminated()) {
return;
}
executorService.submit(new Runnable() {
@@ -1373,23 +1371,32 @@ public class TrackRecordingService extends Service {
// Update track statistics.
long trackId = PreferencesUtils.getLong(getApplicationContext(),
R.string.recording_track_id_key);
if (trackId == PreferencesUtils.RECORDING_TRACK_ID_DEFAULT) {
return;
}
Track currentTrack = myTracksProviderUtils.getTrack(trackId);
CalorieUtils.updateTrackStatistics(getApplicationContext(), -1, currentTrack);
trackTripStatisticsUpdater.updateCalorie(currentTrack.getTripStatistics().getCalorie());
if (currentTrack == null) {
return;
}
double newCalorie = CalorieUtils.updateCalorie(getApplicationContext(), -1, currentTrack);
trackTripStatisticsUpdater.updateCalorie(newCalorie);
// Update to database.
MyTracksProviderUtils.Factory.get(context).updateTrack(currentTrack);
myTracksProviderUtils.updateTrack(currentTrack);
// Update marker statistics.
Waypoint lastWayPoint = myTracksProviderUtils.getLastWaypoint(trackId,
WaypointType.WAYPOINT);
if (lastWayPoint == null) {
return;
}
long lastWayPoint_pointId = myTracksProviderUtils.getTrackPointId(trackId,
lastWayPoint.getLocation());
if (lastWayPoint_pointId > 0) {
CalorieUtils.updateTrackStatistics(getApplicationContext(), lastWayPoint_pointId,
newCalorie = CalorieUtils.updateCalorie(getApplicationContext(), lastWayPoint_pointId,
currentTrack);
}
markerTripStatisticsUpdater.updateCalorie(currentTrack.getTripStatistics().getCalorie());
markerTripStatisticsUpdater.updateCalorie(newCalorie);
}
});
}
@@ -124,14 +124,14 @@ public class TripStatisticsUpdater {
*
* @param location the location
* @param minRecordingDistance the min recording distance
* @param isCalculateCalorie true means calculate calorie
* @param calculateCalorie true means calculate calorie
* @param activityType the activity type of current track which is used to
* calculate calorie
* @param weight the weight to calculate calorie which is used to calculate
* calorie
*/
public void addLocation(Location location, int minRecordingDistance,
boolean isCalculateCalorie, ActivityType activityType, int weight) {
boolean calculateCalorie, ActivityType activityType, int weight) {
// Always update time
updateTime(location.getTime());
if (!LocationUtils.isValidLocation(location)) {
@@ -195,7 +195,7 @@ public class TripStatisticsUpdater {
location.getTime(), location.getSpeed(), lastLocation.getTime(), lastLocation.getSpeed());
}
if (isCalculateCalorie) {
if (calculateCalorie) {
// Update calorie
double calorie = CalorieUtils.getCalorie(lastMovingLocation, location,
gradeBuffer.getAverage(), weight, activityType);
@@ -277,10 +277,11 @@ public class CalorieUtils {
*
* @param context the context
* @param track the track to calculate
* @param startTrackPointId the starting track point id. -1L to ignore
* @return the TripStatisticsUpdater of track
* @param startTrackPointId the starting track point id. Make this value less
* than 1 to calculate the entire track
* @return the calorie value of track
*/
public static TripStatisticsUpdater updateTrackStatistics(Context context,
public static double updateCalorie(Context context,
long startTrackPointId, Track track) {
ActivityType activityType = getActivityType(context, track.getCategory());
@@ -307,6 +308,6 @@ public class CalorieUtils {
}
}
track.setTripStatistics(tripStatisticsUpdater.getTripStatistics());
return tripStatisticsUpdater;
return tripStatisticsUpdater.getTripStatistics().getCalorie();
}
}