/[projects]/android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureEntry.java
ViewVC logotype

Diff of /android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureEntry.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 312 by torben, Fri Sep 11 05:32:04 2009 UTC revision 697 by torben, Mon May 3 07:42:02 2010 UTC
# Line 9  public class DepartureBean implements Co Line 9  public class DepartureBean implements Co
9          private String location;                  private String location;        
10          private String status;            private String status;  
11          private String note;          private String note;
12            private String type;
13                    
14                    
15          public String getTime() {          public String getTime() {
# Line 60  public class DepartureBean implements Co Line 61  public class DepartureBean implements Co
61                  this.note = note;                  this.note = note;
62          }          }
63                    
64            public String getType() {
65                    return type;
66            }
67            
68            public void setType(String type) {
69                    this.type = type;
70            }
71            
72          @Override          @Override
73          public int compareTo(DepartureBean otherBean) {          public int compareTo(DepartureBean otherBean) {
74                    String timeStr1 = time.replace(":","").trim();
75                    String timeStr2 = otherBean.time.replace(":","").trim();
76                    
77                    int time1 = 0;
78                    int time2 = 0;
79                    
80                    if (timeStr1.length() > 0)
81                            time1 = Integer.parseInt(timeStr1);
82                    
83                    if (timeStr2.length() > 0)
84                            time2 = Integer.parseInt(timeStr2);
85                                    
86                  int time1 = Integer.parseInt(time.replace(":", ""));                  //work correctly when clock wraps around at midnight
87                  int time2 = Integer.parseInt(otherBean.time.replace(":", ""));                  if (Math.abs(time1-time2) < 1200) {
88                  if (time1 > time2)                          if (time1 > time2)
89                          return 1;                                  return 1;
90                  else                          else
91                          return -1;                                  return -1;
92                    } else {
93                            if (time1 < time2)
94                                    return 1;
95                            else
96                                    return -1;
97    
98                    }
99                                    
100          }          }
101                    
# Line 80  public class DepartureBean implements Co Line 107  public class DepartureBean implements Co
107                          updStr = "&lt; 3 min";                          updStr = "&lt; 3 min";
108                          break;                          break;
109                  case 2:                  case 2:
110                          updStr = "< 3 min";                          updStr = "3-10 min";
111                          break;                          break;
112                  case 3:                  case 3:
113                          updStr = "&gt; 10 min";                          updStr = "&gt; 10 min";

Legend:
Removed from v.312  
changed lines
  Added in v.697

  ViewVC Help
Powered by ViewVC 1.1.20