/[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

android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureBean.java revision 321 by torben, Sun Sep 13 20:17:32 2009 UTC android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureEntry.java revision 1060 by torben, Thu Sep 16 13:32:10 2010 UTC
# Line 1  Line 1 
1  package dk.thoerup.traininfoservice.banedk;  package dk.thoerup.traininfoservice.banedk;
2    
3  public class DepartureBean implements Comparable<DepartureBean> {  import org.simpleframework.xml.Element;
4          private String time;      import org.simpleframework.xml.Root;
5          private int updated;      
6    @Root(name="train")
7    public class DepartureEntry implements Comparable<DepartureEntry> {
8            
9            @Element
10            private String time;
11            
12            @Element
13            private int updated;
14            
15            @Element(name="trainnumber")
16          private String trainNumber;          private String trainNumber;
17            
18            @Element
19          private String destination;          private String destination;
20          private String origin;            
21          private String location;                  @Element
22          private String status;            private String origin;
23            
24            @Element
25            private String location;
26            
27            @Element
28            private String status;
29            
30            @Element
31          private String note;          private String note;
32                    
33            @Element
34            private String type;
35            
36                    
37          public String getTime() {          public String getTime() {
38                  return time;                  return time;
# Line 60  public class DepartureBean implements Co Line 83  public class DepartureBean implements Co
83                  this.note = note;                  this.note = note;
84          }          }
85                    
86            public String getType() {
87                    return type;
88            }
89            
90            public void setType(String type) {
91                    this.type = type;
92            }
93            
94          @Override          @Override
95          public int compareTo(DepartureBean otherBean) {          public int compareTo(DepartureEntry otherBean) {
96                    String timeStr1 = time.replace(":","").trim();
97                    String timeStr2 = otherBean.time.replace(":","").trim();
98                                    
99                  int time1 = Integer.parseInt(time.replace(":", ""));                  int time1 = 0;
100                  int time2 = Integer.parseInt(otherBean.time.replace(":", ""));                  int time2 = 0;
101                    
102                    if (timeStr1.length() > 0)
103                            time1 = Integer.parseInt(timeStr1);
104                    
105                    if (timeStr2.length() > 0)
106                            time2 = Integer.parseInt(timeStr2);
107                                    
108                  //work correctly when clock wraps around at midnight                  //work correctly when clock wraps around at midnight
109                  if (Math.abs(time1-time2) < 1200) {                  if (Math.abs(time1-time2) < 1200) {
# Line 81  public class DepartureBean implements Co Line 120  public class DepartureBean implements Co
120                  }                  }
121                                    
122          }          }
123            
124          public String getUpdatedString() {          public String getUpdatedString() {
125                  String updStr;                  String updStr;
126                                    

Legend:
Removed from v.321  
changed lines
  Added in v.1060

  ViewVC Help
Powered by ViewVC 1.1.20