Change code style.

This commit is contained in:
youtaol
2013-08-19 11:30:56 +08:00
parent 4cf647b02c
commit cbd6d8158a
11 changed files with 97 additions and 85 deletions
@@ -87,7 +87,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
int modifiedTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MODIFIEDTIME);
int sharedWithMeIndex = cursor.getColumnIndexOrThrow(TracksColumns.SHAREDWITHME);
int sharedOwnerIndex = cursor.getColumnIndexOrThrow(TracksColumns.SHAREDOWNER);
int caloriesIndex = cursor.getColumnIndexOrThrow(TracksColumns.CALORIES);
int caloriesIndex = cursor.getColumnIndexOrThrow(TracksColumns.CALORIE);
Track track = new Track();
TripStatistics tripStatistics = track.getTripStatistics();
@@ -154,7 +154,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
tripStatistics.setMaxGrade(cursor.getFloat(maxGradeIndex));
}
if (!cursor.isNull(caloriesIndex)) {
tripStatistics.setCaloricExpenditure(cursor.getFloat(caloriesIndex));
tripStatistics.setCalorie(cursor.getFloat(caloriesIndex));
}
if (!cursor.isNull(iconIndex)) {
track.setIcon(cursor.getString(iconIndex));
@@ -320,7 +320,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
values.put(TracksColumns.MODIFIEDTIME, track.getModifiedTime());
values.put(TracksColumns.SHAREDWITHME, track.isSharedWithMe());
values.put(TracksColumns.SHAREDOWNER, track.getSharedOwner());
values.put(TracksColumns.CALORIES, tripStatistics.getCaloricExpenditure());
values.put(TracksColumns.CALORIE, tripStatistics.getCalorie());
return values;
}
@@ -66,7 +66,6 @@ public interface TracksColumns extends BaseColumns {
public static final String MINLON = "minlon"; // minimum longitude
public static final String MAXLON = "maxlon"; // maximum longitude
public static final String AVGSPEED = "avgspeed"; // average speed
public static final String CALORIES = "calories"; // calories
// average moving speed
public static final String AVGMOVINGSPEED = "avgmovingspeed";
@@ -89,6 +88,9 @@ public interface TracksColumns extends BaseColumns {
// The owner of the shared with me track
public static final String SHAREDOWNER = "sharedOwner";
// Calorie expenditure of the track
public static final String CALORIE = "calories";
public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" // table
+ _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " // id
@@ -122,7 +124,7 @@ public interface TracksColumns extends BaseColumns {
+ MODIFIEDTIME + " INTEGER, " // modified time
+ SHAREDWITHME + " INTEGER, " // shared with me
+ SHAREDOWNER + " STRING, " // shared owner
+ CALORIES + " INTEGER);"; // calories
+ CALORIE + " INTEGER);"; // calories
public static final String[] COLUMNS = { _ID, // id
NAME, // name
@@ -155,7 +157,7 @@ public interface TracksColumns extends BaseColumns {
MODIFIEDTIME, // modified time
SHAREDWITHME, // shared with me
SHAREDOWNER,// shared owner
CALORIES }; // calories
CALORIE }; // calories
public static final byte[] COLUMN_TYPES = { ContentTypeIds.LONG_TYPE_ID, // id
ContentTypeIds.STRING_TYPE_ID, // name
@@ -63,7 +63,7 @@ public class TripStatistics implements Parcelable {
private final ExtremityMonitor gradeExtremities = new ExtremityMonitor();
// The calorie expenditure of current track.
private double caloricExpenditure = 0;
private double calorie = 0;
/**
* Default constructor.
@@ -89,7 +89,7 @@ public class TripStatistics implements Parcelable {
other.elevationExtremities.getMin(), other.elevationExtremities.getMax());
totalElevationGain = other.totalElevationGain;
gradeExtremities.set(other.gradeExtremities.getMin(), other.gradeExtremities.getMax());
caloricExpenditure = other.caloricExpenditure;
calorie = other.calorie;
}
/**
@@ -122,7 +122,7 @@ public class TripStatistics implements Parcelable {
gradeExtremities.update(other.gradeExtremities.getMin());
gradeExtremities.update(other.gradeExtremities.getMax());
}
caloricExpenditure += other.caloricExpenditure;
calorie += other.calorie;
}
/**
@@ -493,7 +493,8 @@ public class TripStatistics implements Parcelable {
+ "; Max Longitude: " + getRightDegrees() + "; Max Speed: " + getMaxSpeed()
+ "; Min Elevation: " + getMinElevation() + "; Max Elevation: " + getMaxElevation()
+ "; Elevation Gain: " + getTotalElevationGain() + "; Min Grade: " + getMinGrade()
+ "; Max Grade: " + getMaxGrade() + "}";
+ "; Max Grade: " + getMaxGrade() + "; Calorie expenditure: " + getCalorie()
+ "}";
}
/**
@@ -529,6 +530,9 @@ public class TripStatistics implements Parcelable {
double minGrade = source.readDouble();
double maxGrade = source.readDouble();
data.gradeExtremities.set(minGrade, maxGrade);
double calorie = source.readDouble();
data.setCalorie(calorie);
return data;
}
@@ -566,28 +570,29 @@ public class TripStatistics implements Parcelable {
dest.writeDouble(totalElevationGain);
dest.writeDouble(gradeExtremities.getMin());
dest.writeDouble(gradeExtremities.getMax());
dest.writeDouble(calorie);
}
/**
* Adds calories value.
* Adds calorie value.
*
* @param calories
* @param calorieAdded
*/
public void addCaloticExpenditure(double calories) {
caloricExpenditure = caloricExpenditure + calories;
public void addCalorie(double calorieAdded) {
this.calorie += calorieAdded;
}
/**
* Sets calories value.
* Sets calorie value.
*/
public void setCaloricExpenditure(double value) {
caloricExpenditure = value;
public void setCalorie(double newCalorie) {
calorie = newCalorie;
}
/**
* Gets calories value.
*/
public double getCaloricExpenditure() {
return caloricExpenditure;
public double getCalorie() {
return calorie;
}
}