Android Open Source - SimpleCardioLog Log Entry






From Project

Back to project page SimpleCardioLog.

License

The source code is released under:

MIT License

If you think the Android project SimpleCardioLog listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.nomachetejuggling.scl.model;
//from  ww  w  .  j a va  2 s.c  om
import java.io.Serializable;
import java.math.BigDecimal;

import org.joda.time.Period;
import org.joda.time.format.PeriodFormatter;
import org.joda.time.format.PeriodFormatterBuilder;

public class LogEntry implements Serializable, Comparable<LogEntry> {
  private static final long serialVersionUID = 5995809185162465374L;
  
  public String exercise;
  public int minutes;
  public BigDecimal units = null; //For unitless
  public int calories;
  public String entryTime;
  
  private static final transient PeriodFormatter PERIOD_FORMATTER = new PeriodFormatterBuilder()
    .printZeroNever()
    .appendHours()
    .appendSuffix("hr")
    .printZeroNever()
    .appendMinutes()
    .appendSuffix("min")
    .toFormatter();
  
  public String formatAsHtml(String unitName) {
    Period period = Period.minutes(minutes).normalizedStandard();

    String periodFormatted = period.toString(PERIOD_FORMATTER);

    StringBuilder sb = new StringBuilder();

    if (units == null) {
      sb.append("<b>" + periodFormatted + "</b>");
    } else {
      sb.append("<b>" + units + " " + unitName + " in " + periodFormatted + "</b>");
    }

    sb.append(" (" + calories + " cal)");
    return sb.toString();
  }

  @Override
  public int compareTo(LogEntry other) {
      if(entryTime == null && other.entryTime == null) return 0;
      if(entryTime == null) return 1;
      if(other.entryTime == null) return -1;
      return entryTime.compareTo(other.entryTime);
  }
}




Java Source Code List

com.nomachetejuggling.scl.AddActivity.java
com.nomachetejuggling.scl.ExerciseList.java
com.nomachetejuggling.scl.LogActivity.java
com.nomachetejuggling.scl.SettingsActivity.java
com.nomachetejuggling.scl.Tags.java
com.nomachetejuggling.scl.Util.java
com.nomachetejuggling.scl.model.Exercise.java
com.nomachetejuggling.scl.model.LogEntry.java