1 |
package dk.thoerup.traininfoservice.banedk; |
package dk.thoerup.traininfoservice.banedk; |
2 |
|
|
3 |
public class DepartureBean { |
public class DepartureBean implements Comparable<DepartureBean> { |
4 |
private String time; |
private String time; |
5 |
private int updated; |
private int updated; |
6 |
private String trainNumber; |
private String trainNumber; |
60 |
this.note = note; |
this.note = note; |
61 |
} |
} |
62 |
|
|
63 |
|
@Override |
64 |
|
public int compareTo(DepartureBean otherBean) { |
65 |
|
|
66 |
|
int time1 = Integer.parseInt(time.replace(":", "")); |
67 |
|
int time2 = Integer.parseInt(otherBean.time.replace(":", "")); |
68 |
|
if (time1 > time2) |
69 |
|
return 1; |
70 |
|
else |
71 |
|
return -1; |
72 |
|
|
73 |
|
} |
74 |
|
|
75 |
|
public String getUpdatedString() { |
76 |
|
String updStr; |
77 |
|
|
78 |
|
switch (updated) { |
79 |
|
case 1: |
80 |
|
updStr = "< 3 min"; |
81 |
|
break; |
82 |
|
case 2: |
83 |
|
updStr = "< 3 min"; |
84 |
|
break; |
85 |
|
case 3: |
86 |
|
updStr = "> 10 min"; |
87 |
|
break; |
88 |
|
case 4: |
89 |
|
updStr = "No info"; |
90 |
|
break; |
91 |
|
default: |
92 |
|
updStr = "Unknown:" + updated; |
93 |
|
} |
94 |
|
|
95 |
|
return updStr; |
96 |
|
} |
97 |
|
|
98 |
} |
} |