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

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

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

revision 307 by torben, Thu Sep 10 18:11:53 2009 UTC revision 321 by torben, Sun Sep 13 20:17:32 2009 UTC
# Line 1  Line 1 
1  package dk.thoerup.traininfoservice.banedk;  package dk.thoerup.traininfoservice.banedk;
2    
3  public class DepartureBean implements Comparable {  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;
# Line 61  public class DepartureBean implements Co Line 61  public class DepartureBean implements Co
61          }          }
62                    
63          @Override          @Override
64          public int compareTo(Object arg0) {          public int compareTo(DepartureBean otherBean) {
                 DepartureBean otherBean = (DepartureBean) arg0;  
65                                    
66                  int time1 = Integer.parseInt(time.replace(":", ""));                  int time1 = Integer.parseInt(time.replace(":", ""));
67                  int time2 = Integer.parseInt(otherBean.time.replace(":", ""));                  int time2 = Integer.parseInt(otherBean.time.replace(":", ""));
68                  if (time1 > time2)                  
69                          return 1;                  //work correctly when clock wraps around at midnight
70                  else                  if (Math.abs(time1-time2) < 1200) {
71                          return -1;                          if (time1 > time2)
72                                    return 1;
73                            else
74                                    return -1;
75                    } else {
76                            if (time1 < time2)
77                                    return 1;
78                            else
79                                    return -1;
80    
81                    }
82                                    
83          }          }
84                    
85            public String getUpdatedString() {
86                    String updStr;
87                    
88                    switch (updated) {
89                    case 1:
90                            updStr = "&lt; 3 min";
91                            break;
92                    case 2:
93                            updStr = "3-10 min";
94                            break;
95                    case 3:
96                            updStr = "&gt; 10 min";
97                            break;
98                    case 4:
99                            updStr = "No info";
100                            break;
101                    default:
102                            updStr = "Unknown:" + updated;                  
103                    }
104                    
105                    return updStr;
106            }
107                    
108  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.20