Integrate most of Rodrigo's comments.

This commit is contained in:
Sandor Dornbush
2010-08-11 22:02:49 -07:00
parent 3960341640
commit 7bae8c34a7
9 changed files with 72 additions and 73 deletions
@@ -87,10 +87,12 @@ public class VersionChecker {
try {
PackageInfo pi =
parentActivity.getPackageManager().getPackageInfo(
"com.google.android.maps.mytracks", PackageManager.GET_META_DATA);
"com.google.android.maps.mytracks",
PackageManager.GET_META_DATA);
currentVersion = pi.versionName;
} catch (NameNotFoundException e) {
Log.w(MyTracksConstants.TAG, "Failed to get version info.", e);
return;
}
GDataParser parser = client.getParserForFeed(
@@ -109,7 +109,8 @@ public class ExportAllTracks {
context.getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0);
long recordingTrackId = -1;
if (prefs != null) {
recordingTrackId = prefs.getLong(context.getString(R.string.recording_track_key), -1);
recordingTrackId =
prefs.getLong(context.getString(R.string.recording_track_key), -1);
}
if (recordingTrackId != -1) {
acquireWakeLock();
@@ -26,7 +26,7 @@ import android.view.MenuItem;
*
* @author Sandor Dornbush
*/
public class MenuManager {
class MenuManager {
private MyTracks activity;
@@ -64,7 +64,6 @@ public abstract class MyTracksConstants {
public static final int SHOW_WAYPOINT = 25;
public static final int EDIT_WAYPOINT = 26;
public static final int WELCOME = 27;
public static final int REQUEST_ENABLE_BT = 28;
/*
* Menu ids:
@@ -215,30 +215,26 @@ public class MyTracksMap extends MapActivity
while (lastSeenLocationId < selectedTrack.getStopId()) {
cursor = providerUtils.getLocationsCursor(
selectedTrack.getId(), lastSeenLocationId, bufferSize, false);
if (cursor != null) {
if (cursor.moveToFirst()) {
final int idColumnIdx =
cursor.getColumnIndexOrThrow(TrackPointsColumns._ID);
while (cursor.moveToNext()) {
points++;
Location location = providerUtils.createLocation(cursor);
if (MyTracksUtils.isValidLocation(location)) {
lastSeenLocationId = cursor.getLong(idColumnIdx);
// Include a point if it fits one of the following criteria:
// - Has the mod for the sampling frequency.
// - Is the first point.
// - Is the last point and we are not recording this track.
if (points % samplingFrequency == 0 ||
points == 0 ||
(recordingTrackId != selectedTrack.getId() &&
points == (totalLocations - 1))) {
mapOverlay.addLocation(location);
}
}
}
} else {
lastSeenLocationId += bufferSize;
}
if (cursor != null && cursor.moveToFirst()) {
final int idColumnIdx =
cursor.getColumnIndexOrThrow(TrackPointsColumns._ID);
while (cursor.moveToNext()) {
points++;
Location location = providerUtils.createLocation(cursor);
if (MyTracksUtils.isValidLocation(location)) {
lastSeenLocationId = cursor.getLong(idColumnIdx);
// Include a point if it fits one of the following criteria:
// - Has the mod for the sampling frequency.
// - Is the first point.
// - Is the last point and we are not recording this track.
if (points % samplingFrequency == 0 ||
points == 0 ||
(recordingTrackId != selectedTrack.getId() &&
points == (totalLocations - 1))) {
mapOverlay.addLocation(location);
}
}
}
} else {
lastSeenLocationId += bufferSize;
}
@@ -55,7 +55,7 @@ public class MyTracksOverlay extends Overlay {
private final Paint errorCirclePaint;
private final Context context;
private final ArrayList<Waypoint> waypoints = new ArrayList<Waypoint>();
private final ArrayList<Location> points = new ArrayList<Location>();
private final ArrayList<Location> points = new ArrayList<Location>(1024);
private Track selectedTrack;
private int lastHeading = 0;
@@ -94,6 +94,9 @@ public class StatsActivity extends Activity
*/
private boolean showCurrentSegment = false;
private final MyTracksProviderUtils providerUtils;
private Track track = null;
/**
* A runnable for posting to the UI thread. Will update the total time field.
*/
@@ -131,9 +134,6 @@ public class StatsActivity extends Activity
}
}
private MyTracksProviderUtils providerUtils;
private Track track = null;
public StatsActivity() {
utils = new StatsUtilities(this);
providerUtils = new MyTracksProviderUtilsImpl(this);