otbeta/com.iamthefij.otbeta/src/main/java/com/iamthefij/otbeta/api/Interval.java

157 lines
3.9 KiB
Java

package com.iamthefij.otbeta.api;
import org.json.JSONObject;
/**
* Interval is a workout summary
*/
public class Interval {
private static String sSpeedUnit;
private static String sDistanceUnit;
private Double mAvgHeartRate;
private Double mAvgResistance;
private Double mAvgSpeed;
private String mPointsLabel;
private String mStartDateLocal;
private Double mStartDateUtc;
private Integer mTotalCalories;
private Double mTotalDistance;
private Integer mTotalDuration;
private Integer mTotalPoints;
private Integer mTotalWorkout;
private String mDeviceType;
private String mEquipmentType;
private final Integer mId;
private Boolean mNoted;
private String mTimezone;
private String mWorkoutCategory;
private String mWorkoutSource;
public static String getSpeedUnit() {
return sSpeedUnit;
}
public static void setSpeedUnit(String sSpeedUnit) {
Interval.sSpeedUnit = sSpeedUnit;
}
public static String getDistanceUnit() {
return sDistanceUnit;
}
public static void setDistanceUnit(String sDistanceUnit) {
Interval.sDistanceUnit = sDistanceUnit;
}
public Double getAvgHeartRate() {
return mAvgHeartRate;
}
public Double getAvgResistance() {
return mAvgResistance;
}
public Double getAvgSpeed() {
return mAvgSpeed;
}
public String getPointsLabel() {
return mPointsLabel;
}
public String getStartDateLocal() {
return mStartDateLocal;
}
public Double getStartDateUtc() {
return mStartDateUtc;
}
public Integer getTotalCalories() {
return mTotalCalories;
}
public Double getTotalDistance() {
return mTotalDistance;
}
public Integer getTotalDuration() {
return mTotalDuration;
}
public Integer getTotalPoints() {
return mTotalPoints;
}
public Integer getTotalWorkout() {
return mTotalWorkout;
}
public String getDeviceType() {
return mDeviceType;
}
public String getEquipmentType() {
return mEquipmentType;
}
public Integer getId() {
return mId;
}
public Boolean getNoted() {
return mNoted;
}
public String getTimezone() {
return mTimezone;
}
public String getWorkoutCategory() {
return mWorkoutCategory;
}
public String getWorkoutSource() {
return mWorkoutSource;
}
/**
* Minimal constructor for use in getting details
*
* @param intervalId int id of interval to be used
*/
public Interval(int intervalId) {
mId = intervalId;
}
/**
* Constructs an Interval with the response from any kind of workout list request
*
* @param interval {@link JSONObject} response from any interval request
*/
public Interval(JSONObject interval) {
mAvgHeartRate = interval.optDouble("avgHeartRate");
mAvgResistance = interval.optDouble("avgResistance");
mAvgSpeed = interval.optDouble("avgSpeed");
mPointsLabel = interval.optString("pointsLabel");
mStartDateLocal = interval.optString("startDateLocal");
mStartDateUtc = interval.optDouble("startDateUtc");
mTotalCalories = interval.optInt("totalCalories");
mTotalDistance = interval.optDouble("totalDistance");
mTotalDuration = interval.optInt("totalDuration");
mTotalPoints = interval.optInt("totalPoints");
mTotalWorkout = interval.optInt("totalWorkout");
mDeviceType = interval.optString("deviceType");
mEquipmentType = interval.optString("equipmentType");
mId = interval.optInt("id");
mNoted = interval.optBoolean("noted");
mTimezone = interval.optString("timezone");
mWorkoutCategory = interval.optString("workoutCategory");
mWorkoutSource = interval.optString("workoutSource");
}
}