forked from upstream-mirrors/OpenTracks
Change code style.
This commit is contained in:
@@ -200,7 +200,7 @@ public class TrackEditActivity extends AbstractMyTracksActivity
|
|||||||
myTracksProviderUtils.updateTrack(track);
|
myTracksProviderUtils.updateTrack(track);
|
||||||
TrackRecordingServiceConnectionUtils.updateCalorie(trackRecordingServiceConnection);
|
TrackRecordingServiceConnectionUtils.updateCalorie(trackRecordingServiceConnection);
|
||||||
} else {
|
} else {
|
||||||
CalorieUtils.updateCalorie(getApplicationContext(), -1, track);
|
CalorieUtils.updateCalorie(getApplicationContext(), -1L, track);
|
||||||
|
|
||||||
// Update data with new calorie.
|
// Update data with new calorie.
|
||||||
myTracksProviderUtils.updateTrack(track);
|
myTracksProviderUtils.updateTrack(track);
|
||||||
|
|||||||
@@ -28,14 +28,13 @@ import com.google.android.apps.mytracks.content.TrackDataType;
|
|||||||
import com.google.android.apps.mytracks.content.Waypoint;
|
import com.google.android.apps.mytracks.content.Waypoint;
|
||||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||||
import com.google.android.apps.mytracks.stats.TripStatisticsUpdater;
|
import com.google.android.apps.mytracks.stats.TripStatisticsUpdater;
|
||||||
import com.google.android.apps.mytracks.util.CalorieUtils;
|
import com.google.android.apps.mytracks.util.CalorieUtils.ActivityType;
|
||||||
import com.google.android.apps.mytracks.util.LocationUtils;
|
import com.google.android.apps.mytracks.util.LocationUtils;
|
||||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||||
import com.google.android.apps.mytracks.util.UnitConversions;
|
import com.google.android.apps.mytracks.util.UnitConversions;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
@@ -190,7 +189,7 @@ public class ChartFragment extends Fragment implements TrackDataListener {
|
|||||||
public void onSampledInTrackPoint(Location location) {
|
public void onSampledInTrackPoint(Location location) {
|
||||||
if (isResumed()) {
|
if (isResumed()) {
|
||||||
double[] data = new double[ChartView.NUM_SERIES + 1];
|
double[] data = new double[ChartView.NUM_SERIES + 1];
|
||||||
fillDataPoint(location, data, getActivity());
|
fillDataPoint(location, data);
|
||||||
pendingPoints.add(data);
|
pendingPoints.add(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,14 +197,14 @@ public class ChartFragment extends Fragment implements TrackDataListener {
|
|||||||
@Override
|
@Override
|
||||||
public void onSampledOutTrackPoint(Location location) {
|
public void onSampledOutTrackPoint(Location location) {
|
||||||
if (isResumed()) {
|
if (isResumed()) {
|
||||||
fillDataPoint(location, null, getActivity());
|
fillDataPoint(location, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSegmentSplit(Location location) {
|
public void onSegmentSplit(Location location) {
|
||||||
if (isResumed()) {
|
if (isResumed()) {
|
||||||
fillDataPoint(location, null, getActivity());
|
fillDataPoint(location, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,10 +440,9 @@ public class ChartFragment extends Fragment implements TrackDataListener {
|
|||||||
*
|
*
|
||||||
* @param location the location
|
* @param location the location
|
||||||
* @param data the data point to fill in, can be null
|
* @param data the data point to fill in, can be null
|
||||||
* @param context the context
|
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void fillDataPoint(Location location, double data[], Context context) {
|
void fillDataPoint(Location location, double data[]) {
|
||||||
double timeOrDistance = Double.NaN;
|
double timeOrDistance = Double.NaN;
|
||||||
double elevation = Double.NaN;
|
double elevation = Double.NaN;
|
||||||
double speed = Double.NaN;
|
double speed = Double.NaN;
|
||||||
@@ -454,10 +452,8 @@ public class ChartFragment extends Fragment implements TrackDataListener {
|
|||||||
double power = Double.NaN;
|
double power = Double.NaN;
|
||||||
|
|
||||||
if (tripStatisticsUpdater != null) {
|
if (tripStatisticsUpdater != null) {
|
||||||
tripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false, CalorieUtils
|
tripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
|
||||||
.getActivityType(context,
|
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||||
PreferencesUtils.getLong(context, R.string.recording_track_id_key)), PreferencesUtils
|
|
||||||
.getInt(context, R.string.stats_weight_key, PreferencesUtils.STATS_WEIGHT_DEFAULT));
|
|
||||||
TripStatistics tripStatistics = tripStatisticsUpdater.getTripStatistics();
|
TripStatistics tripStatistics = tripStatisticsUpdater.getTripStatistics();
|
||||||
if (chartByDistance) {
|
if (chartByDistance) {
|
||||||
double distance = tripStatistics.getTotalDistance() * UnitConversions.M_TO_KM;
|
double distance = tripStatistics.getTotalDistance() * UnitConversions.M_TO_KM;
|
||||||
|
|||||||
+4
-12
@@ -24,7 +24,7 @@ import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
|
|||||||
import com.google.android.apps.mytracks.services.TrackRecordingService;
|
import com.google.android.apps.mytracks.services.TrackRecordingService;
|
||||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||||
import com.google.android.apps.mytracks.stats.TripStatisticsUpdater;
|
import com.google.android.apps.mytracks.stats.TripStatisticsUpdater;
|
||||||
import com.google.android.apps.mytracks.util.CalorieUtils;
|
import com.google.android.apps.mytracks.util.CalorieUtils.ActivityType;
|
||||||
import com.google.android.apps.mytracks.util.FileUtils;
|
import com.google.android.apps.mytracks.util.FileUtils;
|
||||||
import com.google.android.apps.mytracks.util.LocationUtils;
|
import com.google.android.apps.mytracks.util.LocationUtils;
|
||||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||||
@@ -243,15 +243,9 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
trackTripStatisticstrackUpdater.addLocation(trackPoint, recordingDistanceInterval, false,
|
trackTripStatisticstrackUpdater.addLocation(trackPoint, recordingDistanceInterval, false,
|
||||||
CalorieUtils.getActivityType(context,
|
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||||
PreferencesUtils.getLong(context, R.string.recording_track_id_key)),
|
|
||||||
PreferencesUtils.getInt(context, R.string.stats_weight_key,
|
|
||||||
PreferencesUtils.STATS_WEIGHT_DEFAULT));
|
|
||||||
markerTripStatisticsUpdater.addLocation(trackPoint, recordingDistanceInterval, false,
|
markerTripStatisticsUpdater.addLocation(trackPoint, recordingDistanceInterval, false,
|
||||||
CalorieUtils.getActivityType(context,
|
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||||
PreferencesUtils.getLong(context, R.string.recording_track_id_key)),
|
|
||||||
PreferencesUtils.getInt(context, R.string.stats_weight_key,
|
|
||||||
PreferencesUtils.STATS_WEIGHT_DEFAULT));
|
|
||||||
}
|
}
|
||||||
if (waypoint.getLocation().getTime() > trackPoint.getTime()) {
|
if (waypoint.getLocation().getTime() > trackPoint.getTime()) {
|
||||||
trackPoint = null;
|
trackPoint = null;
|
||||||
@@ -555,9 +549,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
|||||||
location.getTime() != -1L ? location.getTime() : trackData.importTime);
|
location.getTime() != -1L ? location.getTime() : trackData.importTime);
|
||||||
}
|
}
|
||||||
trackData.tripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
|
trackData.tripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
|
||||||
CalorieUtils.getActivityType(context,
|
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||||
PreferencesUtils.getLong(context, R.string.recording_track_id_key)), PreferencesUtils
|
|
||||||
.getInt(context, R.string.stats_weight_key, PreferencesUtils.STATS_WEIGHT_DEFAULT));
|
|
||||||
|
|
||||||
trackData.bufferedLocations[trackData.numBufferedLocations] = location;
|
trackData.bufferedLocations[trackData.numBufferedLocations] = location;
|
||||||
trackData.numBufferedLocations++;
|
trackData.numBufferedLocations++;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import com.google.android.apps.mytracks.io.gdata.maps.XmlMapsGDataParserFactory;
|
|||||||
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendAsyncTask;
|
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendAsyncTask;
|
||||||
import com.google.android.apps.mytracks.io.sendtogoogle.SendToGoogleUtils;
|
import com.google.android.apps.mytracks.io.sendtogoogle.SendToGoogleUtils;
|
||||||
import com.google.android.apps.mytracks.stats.TripStatisticsUpdater;
|
import com.google.android.apps.mytracks.stats.TripStatisticsUpdater;
|
||||||
import com.google.android.apps.mytracks.util.CalorieUtils;
|
import com.google.android.apps.mytracks.util.CalorieUtils.ActivityType;
|
||||||
import com.google.android.apps.mytracks.util.LocationUtils;
|
import com.google.android.apps.mytracks.util.LocationUtils;
|
||||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||||
import com.google.android.common.gdata.AndroidXmlParserFactory;
|
import com.google.android.common.gdata.AndroidXmlParserFactory;
|
||||||
@@ -278,11 +278,8 @@ public class SendMapsAsyncTask extends AbstractSendAsyncTask {
|
|||||||
sentStartMarker = true;
|
sentStartMarker = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
tripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false, CalorieUtils
|
tripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
|
||||||
.getActivityType(context,
|
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||||
PreferencesUtils.getLong(context, R.string.recording_track_id_key)),
|
|
||||||
PreferencesUtils.getInt(context, R.string.stats_weight_key,
|
|
||||||
PreferencesUtils.STATS_WEIGHT_DEFAULT));
|
|
||||||
if (i % elevationSamplingFrequency == 0) {
|
if (i % elevationSamplingFrequency == 0) {
|
||||||
distances.add(tripStatisticsUpdater.getTripStatistics().getTotalDistance());
|
distances.add(tripStatisticsUpdater.getTripStatistics().getTotalDistance());
|
||||||
elevations.add(tripStatisticsUpdater.getSmoothedElevation());
|
elevations.add(tripStatisticsUpdater.getSmoothedElevation());
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.google.android.apps.mytracks.services.tasks.SplitPeriodicTaskFactory;
|
|||||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||||
import com.google.android.apps.mytracks.stats.TripStatisticsUpdater;
|
import com.google.android.apps.mytracks.stats.TripStatisticsUpdater;
|
||||||
import com.google.android.apps.mytracks.util.CalorieUtils;
|
import com.google.android.apps.mytracks.util.CalorieUtils;
|
||||||
|
import com.google.android.apps.mytracks.util.CalorieUtils.ActivityType;
|
||||||
import com.google.android.apps.mytracks.util.IntentUtils;
|
import com.google.android.apps.mytracks.util.IntentUtils;
|
||||||
import com.google.android.apps.mytracks.util.LocationUtils;
|
import com.google.android.apps.mytracks.util.LocationUtils;
|
||||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||||
@@ -661,16 +662,10 @@ public class TrackRecordingService extends Service {
|
|||||||
do {
|
do {
|
||||||
Location location = myTracksProviderUtils.createTrackPoint(cursor);
|
Location location = myTracksProviderUtils.createTrackPoint(cursor);
|
||||||
trackTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
|
trackTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
|
||||||
CalorieUtils.getActivityType(context,
|
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||||
PreferencesUtils.getLong(context, R.string.recording_track_id_key)),
|
|
||||||
PreferencesUtils.getInt(context, R.string.stats_weight_key,
|
|
||||||
PreferencesUtils.STATS_WEIGHT_DEFAULT));
|
|
||||||
if (location.getTime() > markerStartTime) {
|
if (location.getTime() > markerStartTime) {
|
||||||
markerTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
|
markerTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
|
||||||
CalorieUtils.getActivityType(context,
|
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||||
PreferencesUtils.getLong(context, R.string.recording_track_id_key)),
|
|
||||||
PreferencesUtils.getInt(context, R.string.stats_weight_key,
|
|
||||||
PreferencesUtils.STATS_WEIGHT_DEFAULT));
|
|
||||||
}
|
}
|
||||||
} while (cursor.moveToPrevious());
|
} while (cursor.moveToPrevious());
|
||||||
}
|
}
|
||||||
@@ -1014,9 +1009,7 @@ public class TrackRecordingService extends Service {
|
|||||||
CalorieUtils.getActivityType(context, track.getId()), PreferencesUtils.getInt(context,
|
CalorieUtils.getActivityType(context, track.getId()), PreferencesUtils.getInt(context,
|
||||||
R.string.stats_weight_key, PreferencesUtils.STATS_WEIGHT_DEFAULT));
|
R.string.stats_weight_key, PreferencesUtils.STATS_WEIGHT_DEFAULT));
|
||||||
markerTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
|
markerTripStatisticsUpdater.addLocation(location, recordingDistanceInterval, false,
|
||||||
CalorieUtils.getActivityType(context,
|
ActivityType.INVALID, PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||||
PreferencesUtils.getLong(context, R.string.recording_track_id_key)), PreferencesUtils
|
|
||||||
.getInt(context, R.string.stats_weight_key, PreferencesUtils.STATS_WEIGHT_DEFAULT));
|
|
||||||
updateRecordingTrack(track, trackPointId, LocationUtils.isValidLocation(location));
|
updateRecordingTrack(track, trackPointId, LocationUtils.isValidLocation(location));
|
||||||
} catch (SQLiteException e) {
|
} catch (SQLiteException e) {
|
||||||
/*
|
/*
|
||||||
@@ -1378,7 +1371,7 @@ public class TrackRecordingService extends Service {
|
|||||||
if (currentTrack == null) {
|
if (currentTrack == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double newCalorie = CalorieUtils.updateCalorie(getApplicationContext(), -1, currentTrack);
|
double newCalorie = CalorieUtils.updateCalorie(getApplicationContext(), -1L, currentTrack);
|
||||||
trackTripStatisticsUpdater.updateCalorie(newCalorie);
|
trackTripStatisticsUpdater.updateCalorie(newCalorie);
|
||||||
|
|
||||||
// Update to database.
|
// Update to database.
|
||||||
|
|||||||
@@ -277,8 +277,8 @@ public class CalorieUtils {
|
|||||||
*
|
*
|
||||||
* @param context the context
|
* @param context the context
|
||||||
* @param track the track to calculate
|
* @param track the track to calculate
|
||||||
* @param startTrackPointId the starting track point id. Make this value less
|
* @param startTrackPointId the starting track point id. Make this value 1L to
|
||||||
* than 1 to calculate the entire track
|
* calculate the entire track
|
||||||
* @return the calorie value of track
|
* @return the calorie value of track
|
||||||
*/
|
*/
|
||||||
public static double updateCalorie(Context context,
|
public static double updateCalorie(Context context,
|
||||||
@@ -297,8 +297,7 @@ public class CalorieUtils {
|
|||||||
tripStatisticsUpdater.addLocation(points.next(), PreferencesUtils.getInt(context,
|
tripStatisticsUpdater.addLocation(points.next(), PreferencesUtils.getInt(context,
|
||||||
R.string.recording_distance_interval_key,
|
R.string.recording_distance_interval_key,
|
||||||
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT), false, activityType,
|
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT), false, activityType,
|
||||||
PreferencesUtils.getInt(context, R.string.stats_weight_key,
|
PreferencesUtils.STATS_WEIGHT_DEFAULT);
|
||||||
PreferencesUtils.STATS_WEIGHT_DEFAULT));
|
|
||||||
} else {
|
} else {
|
||||||
tripStatisticsUpdater.addLocation(points.next(), PreferencesUtils.getInt(context,
|
tripStatisticsUpdater.addLocation(points.next(), PreferencesUtils.getInt(context,
|
||||||
R.string.recording_distance_interval_key,
|
R.string.recording_distance_interval_key,
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ public class ChartFragmentTest extends AndroidTestCase {
|
|||||||
*/
|
*/
|
||||||
private double[] fillDataPointTestHelper(Location location) {
|
private double[] fillDataPointTestHelper(Location location) {
|
||||||
double[] point = new double[ChartView.NUM_SERIES + 1];
|
double[] point = new double[ChartView.NUM_SERIES + 1];
|
||||||
chartFragment.fillDataPoint(location, point, getContext());
|
chartFragment.fillDataPoint(location, point);
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user