/[projects]/android/TrainInfoCommon/src/dk/thoerup/android/traininfo/common/DepartureEntry.java
ViewVC logotype

Diff of /android/TrainInfoCommon/src/dk/thoerup/android/traininfo/common/DepartureEntry.java

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

revision 1561 by torben, Wed Apr 20 06:44:18 2011 UTC revision 1562 by torben, Fri Jul 8 16:26:09 2011 UTC
# Line 6  import org.simpleframework.xml.Element; Line 6  import org.simpleframework.xml.Element;
6  import org.simpleframework.xml.Root;  import org.simpleframework.xml.Root;
7    
8  @Root(name="train", strict=false)  @Root(name="train", strict=false)
9  public class DepartureEntry implements Comparable<DepartureEntry>, Serializable {  public class DepartureEntry implements  Serializable {
10                    
11          @Element          @Element
12          private String time;          private String time;
# Line 93  public class DepartureEntry implements C Line 93  public class DepartureEntry implements C
93                  this.type = type;                  this.type = type;
94          }          }
95                    
         @Override  
         public int compareTo(DepartureEntry otherBean) {  
                 String timeStr1 = time.replace(":","").trim();  
                 String timeStr2 = otherBean.time.replace(":","").trim();  
                   
                 int time1 = 0;  
                 int time2 = 0;  
                   
                 if (timeStr1.length() > 0)  
                         time1 = Integer.parseInt(timeStr1);  
                   
                 if (timeStr2.length() > 0)  
                         time2 = Integer.parseInt(timeStr2);  
                   
                 //work correctly when clock wraps around at midnight  
                 if (Math.abs(time1-time2) < 1200) {  
                         if (time1 > time2)  
                                 return 1;  
                         else  
                                 return -1;  
                 } else {  
                         if (time1 < time2)  
                                 return 1;  
                         else  
                                 return -1;  
   
                 }  
                   
         }        
96  }  }

Legend:
Removed from v.1561  
changed lines
  Added in v.1562

  ViewVC Help
Powered by ViewVC 1.1.20