--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureBean.java 2009/09/11 05:32:04 312 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureBean.java 2010/05/03 07:42:02 697 @@ -9,6 +9,7 @@ private String location; private String status; private String note; + private String type; public String getTime() { @@ -60,15 +61,41 @@ this.note = note; } + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + @Override public int compareTo(DepartureBean otherBean) { + String timeStr1 = time.replace(":","").trim(); + String timeStr2 = otherBean.time.replace(":","").trim(); + + int time1 = 0; + int time2 = 0; + + if (timeStr1.length() > 0) + time1 = Integer.parseInt(timeStr1); + + if (timeStr2.length() > 0) + time2 = Integer.parseInt(timeStr2); - int time1 = Integer.parseInt(time.replace(":", "")); - int time2 = Integer.parseInt(otherBean.time.replace(":", "")); - if (time1 > time2) - return 1; - else - return -1; + //work correctly when clock wraps around at midnight + if (Math.abs(time1-time2) < 1200) { + if (time1 > time2) + return 1; + else + return -1; + } else { + if (time1 < time2) + return 1; + else + return -1; + + } } @@ -80,7 +107,7 @@ updStr = "< 3 min"; break; case 2: - updStr = "< 3 min"; + updStr = "3-10 min"; break; case 3: updStr = "> 10 min";