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

Annotation of /android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureBean.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 373 - (hide annotations) (download)
Wed Sep 30 19:49:25 2009 UTC (14 years, 8 months ago) by torben
File size: 2333 byte(s)
Work arouund a bug in bane.dk (a departure at midnight sometimes occurs as a empty string)
1 torben 305 package dk.thoerup.traininfoservice.banedk;
2    
3 torben 308 public class DepartureBean implements Comparable<DepartureBean> {
4 torben 305 private String time;
5     private int updated;
6     private String trainNumber;
7     private String destination;
8     private String origin;
9     private String location;
10     private String status;
11     private String note;
12    
13    
14     public String getTime() {
15     return time;
16     }
17     public void setTime(String time) {
18     this.time = time;
19     }
20     public int getUpdated() {
21     return updated;
22     }
23     public void setUpdated(int updated) {
24     this.updated = updated;
25     }
26     public String getTrainNumber() {
27     return trainNumber;
28     }
29     public void setTrainNumber(String trainNumber) {
30     this.trainNumber = trainNumber;
31     }
32     public String getDestination() {
33     return destination;
34     }
35     public void setDestination(String destination) {
36     this.destination = destination;
37     }
38     public String getOrigin() {
39     return origin;
40     }
41     public void setOrigin(String origin) {
42     this.origin = origin;
43     }
44     public String getLocation() {
45     return location;
46     }
47     public void setLocation(String location) {
48     this.location = location;
49     }
50     public String getStatus() {
51     return status;
52     }
53     public void setStatus(String status) {
54     this.status = status;
55     }
56     public String getNote() {
57     return note;
58     }
59     public void setNote(String note) {
60     this.note = note;
61     }
62    
63 torben 307 @Override
64 torben 308 public int compareTo(DepartureBean otherBean) {
65 torben 373 String timeStr1 = time.replace(":","").trim();
66     String timeStr2 = otherBean.time.replace(":","").trim();
67 torben 307
68 torben 373 int time1 = 0;
69     int time2 = 0;
70 torben 307
71 torben 373 if (timeStr1.length() > 0)
72     time1 = Integer.parseInt(timeStr1);
73    
74     if (timeStr2.length() > 0)
75     time2 = Integer.parseInt(timeStr2);
76    
77 torben 321 //work correctly when clock wraps around at midnight
78     if (Math.abs(time1-time2) < 1200) {
79     if (time1 > time2)
80     return 1;
81     else
82     return -1;
83     } else {
84     if (time1 < time2)
85     return 1;
86     else
87     return -1;
88    
89     }
90    
91 torben 307 }
92 torben 305
93 torben 312 public String getUpdatedString() {
94     String updStr;
95    
96     switch (updated) {
97     case 1:
98     updStr = "&lt; 3 min";
99     break;
100     case 2:
101 torben 321 updStr = "3-10 min";
102 torben 312 break;
103     case 3:
104     updStr = "&gt; 10 min";
105     break;
106     case 4:
107     updStr = "No info";
108     break;
109     default:
110     updStr = "Unknown:" + updated;
111     }
112    
113     return updStr;
114     }
115 torben 307
116 torben 305 }

  ViewVC Help
Powered by ViewVC 1.1.20