[chronojump] Fixes on last commit
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Fixes on last commit
- Date: Tue, 19 Sep 2017 10:16:28 +0000 (UTC)
commit c24e186998b2327bff7537f54aa71d38efd92257
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Sep 19 12:16:11 2017 +0200
Fixes on last commit
src/restTime.cs | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/src/restTime.cs b/src/restTime.cs
index a0502f8..6d2586e 100644
--- a/src/restTime.cs
+++ b/src/restTime.cs
@@ -153,8 +153,28 @@ public class RestTime
//listLastMin
if(exists(listLastMin, personID))
modifyRestTime(listLastMin, personID);
- else
+ else {
+ //add but have only five values
+ if(listLastMin.Count == 5)
+ {
+ int secondsMax = 0;
+ int seconds;
+ int highestTimePos = 0;
+ for (int i = listLastMin.Count - 1; i >= 0; i--)
+ {
+ seconds = LastTestTime.GetSeconds(listLastMin[i].RestedTime);
+ if(seconds > secondsMax)
+ {
+ secondsMax = seconds;
+ highestTimePos = i;
+ }
+ }
+ listLastMin.RemoveAt(highestTimePos);
+ }
+
+ //add the new value
addRestTime(listLastMin, personID, personName);
+ }
}
private bool exists(List<LastTestTime> l, int personID)
@@ -180,10 +200,11 @@ public class RestTime
public List<LastTestTime> LastMinList()
{
- foreach(LastTestTime ltt in listLastMin)
+ //remove reverse in order to not hung the program on removing while iteratin
+ for (int i = listLastMin.Count - 1; i >= 0; i--)
{
- if(ltt.GetTotalMinutes() > 20) //20 minutes
- listLastMin.Remove(ltt);
+ if(listLastMin[i].GetTotalMinutes() > 9 )//10 minutes
+ listLastMin.RemoveAt(i);
}
return listLastMin;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]