internal void addRecord(Record record) { if (sleepElements.Count == 0) { SleepElement newSleepElement = new SleepElement(); newSleepElement.addRecord(record); sleepElements.Add(newSleepElement); date = setCurrentDate(record); return; } SleepElement[] sleeps = sleepElements.ToArray(); SleepElement lastElement = sleeps[sleeps.Length - 1]; Record[] records = lastElement.GetRecords().ToArray(); Record lastRecord = records[records.Length - 1]; if (lastRecord.getStartDateTime().AddHours(-2) < record.getEndDateTime()) { lastElement.addRecord(record); return; } SleepElement element = new SleepElement(); element.addRecord(record); sleepElements.Add(element); }
public void configure(DayElement dayElement, SleepElement sleepElement) { this.dayElement = dayElement; this.sleepElement = sleepElement; dayElemetUi.GetComponent <DayElementController>().configure(dayElement, () => { ObjectFactory.createDayView(dayElement); }); sleepElementUi.GetComponent <SleepElementController>().configure(dayElement, sleepElement, false); elements = sleepElement.GetRecords(); }
public void configure(DayElement dayElement, SleepElement sleepElement, bool interactable) { this.dayElement = dayElement; this.sleepElement = sleepElement; this.interactable = interactable; String count = ""; if (sleepElement.GetRecords().Count > 1) { count = (sleepElement.GetRecords().Count - 1) + ""; } this.sleepUnits.text = count; this.duration.text = TimeRecordUtility.MiliSecToDuration(sleepElement.GetTotalSleepTime()); Record[] array = sleepElement.GetRecords().ToArray(); String startDateTime = TimeRecordUtility.DateTimeToTimeString(array[array.Length - 1].getStartDateTime()); String endDateTime = TimeRecordUtility.DateTimeToTimeString(array[0].getEndDateTime()); this.fromTo.text = startDateTime + " - " + endDateTime; }