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

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

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

revision 970 by torben, Fri Jul 9 21:23:48 2010 UTC revision 976 by torben, Sat Jul 10 09:10:50 2010 UTC
# Line 137  public class TimetableFetcher { Line 137  public class TimetableFetcher {
137                          bean.setArrival( fields.get(1).asText() );                          bean.setArrival( fields.get(1).asText() );
138                          bean.setDeparture( fields.get(2).asText() );                          bean.setDeparture( fields.get(2).asText() );
139                                                    
140                            boolean cancelled = fields.get(3).asText().equalsIgnoreCase("aflyst");
141                            bean.setCancelled(cancelled);
142                            
143                          if (currentStation == true && currentStationSaved == false ) {                          if (currentStation == true && currentStationSaved == false ) {
144                                  bean.setCurrent(currentStation);                                  bean.setCurrent(currentStation);
145                                  currentStationSaved = true;                                  currentStationSaved = true;
# Line 145  public class TimetableFetcher { Line 148  public class TimetableFetcher {
148                          bean.setStationId( getStationId( station ));                          bean.setStationId( getStationId( station ));
149                                                    
150                          timetableList.add(bean);                          timetableList.add(bean);
151                    }
152                    
153                    final String cancelledString = "Aflyst";
154                    for (int i=0;i<timetableList.size(); i++) { //handle cancelled labels
155                            final int lastIdx = (timetableList.size() - 1);
156                            
157                            TimetableBean current = timetableList.get(i);
158                            if (current.isCancelled()) {
159                                    if (i == 0) {
160                                            current.setDeparture(cancelledString);
161                                    } else if (i == lastIdx) {
162                                            current.setArrival(cancelledString);
163                                    } else if (i>0 && i<lastIdx) {
164                                            TimetableBean next = timetableList.get(i+1);
165                                            TimetableBean prev = timetableList.get(i-1);
166                                            
167                                            if (next.isCancelled())
168                                                    current.setDeparture(cancelledString);
169                                            if (prev.isCancelled())
170                                                    current.setArrival(cancelledString);
171                                    }
172                            }
173                  }                  }
174                                    
175              } else {              } else {

Legend:
Removed from v.970  
changed lines
  Added in v.976

  ViewVC Help
Powered by ViewVC 1.1.20