Android Open Source - SleepGuard Peak






From Project

Back to project page SleepGuard.

License

The source code is released under:

GNU General Public License

If you think the Android project SleepGuard 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.szabolcs.szijarto.sleepguard;
//from ww w .java2 s.c o  m
import java.util.Date;

public class Peak implements java.io.Serializable {
  private static final long serialVersionUID = 19743001L;
  public Date start_time;
  public Date end_time;
  public int start_index;
  public int end_index;
  public short max_pulse;
  public long duration;    // in sec

  public Peak (HeartRateRec r, int index) {
    start_time = r.timestamp;
    end_time = null;
    start_index = index;
    end_index = -1;
    max_pulse=r.pulse;
    duration = 0;
  }

  public void add(HeartRateRec r) {
    if (r.pulse > max_pulse) { max_pulse = r.pulse; };
    end_time=r.timestamp;
    duration = (end_time.getTime() - start_time.getTime()) / 1000 ;
  }

  public void close(int end) {
    end_index=end;
    duration = (end_time.getTime() - start_time.getTime()) / 1000 ;
  }
  
  public String getDurationString() {
    if ( (start_time == null) || (end_time == null) ) {
      return "";
    }
    long dur = (end_time.getTime() - start_time.getTime()) / 1000 ;
    int hour  = (int) ( dur / 3600 ) ;
    int min   = (int) ( dur - (hour*3600) ) / 60 ;
    int sec   = (int) ( dur - (hour*3600) ) % 60 ;
    return ( hour + ":" + min + ":" + sec );
  }
}




Java Source Code List

com.szabolcs.szijarto.sleepguard.Activity_Main.java
com.szabolcs.szijarto.sleepguard.Activity_ShowRecording.java
com.szabolcs.szijarto.sleepguard.GenericWatcherException.java
com.szabolcs.szijarto.sleepguard.GenericWatcher.java
com.szabolcs.szijarto.sleepguard.HeartRateRec.java
com.szabolcs.szijarto.sleepguard.HeartRateWatcher.java
com.szabolcs.szijarto.sleepguard.Peak.java
com.szabolcs.szijarto.sleepguard.RecordingFile.java
com.szabolcs.szijarto.sleepguard.RecordingListView.java
com.szabolcs.szijarto.sleepguard.Recording.java
com.szabolcs.szijarto.sleepguard.SleepChart.java