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; |
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() && i == 0) { |
159 |
|
current.setDeparture(cancelledString); |
160 |
|
} else if (current.isCancelled() && i == lastIdx) { |
161 |
|
current.setArrival(cancelledString); |
162 |
|
} else if (current.isCancelled() && i>0 && i<lastIdx) { |
163 |
|
TimetableBean next = timetableList.get(i+1); |
164 |
|
TimetableBean prev = timetableList.get(i-1); |
165 |
|
|
166 |
|
if (next.isCancelled()) |
167 |
|
current.setDeparture(cancelledString); |
168 |
|
if (prev.isCancelled()) |
169 |
|
current.setArrival(cancelledString); |
170 |
|
} |
171 |
} |
} |
172 |
|
|
173 |
} else { |
} else { |