merge heads

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