Protect against null fares

This commit is contained in:
Doug Keen 2016-11-02 18:14:49 -07:00
parent 1c3816fc49
commit 62df6c476e
2 changed files with 5 additions and 5 deletions

View File

@ -197,15 +197,13 @@ public class RoutesListActivity extends AppCompatActivity implements TickSubscri
lastUpdate.setTimeZone(PACIFIC_TIME);
// Update every day
if (now.get(Calendar.DAY_OF_YEAR) != lastUpdate
.get(Calendar.DAY_OF_YEAR)
if (now.get(Calendar.DAY_OF_YEAR) != lastUpdate.get(Calendar.DAY_OF_YEAR)
|| now.get(Calendar.YEAR) != lastUpdate.get(Calendar.YEAR)) {
GetRouteFareTask fareTask = new GetRouteFareTask() {
@Override
public void onResult(String fare) {
stationPair.setFare(fare);
stationPair.setFareLastUpdated(System
.currentTimeMillis());
stationPair.setFareLastUpdated(System.currentTimeMillis());
getListAdapter().notifyDataSetChanged();
}

View File

@ -26,7 +26,9 @@ public class FareContentHandler extends DefaultHandler {
for (int i = attributes.getLength() - 1; i >= 0; i--) {
attributeMap.put(attributes.getLocalName(i), attributes.getValue(i));
}
if (attributeMap.containsKey("class") && attributeMap.get("class").equals("cash")) {
if (attributeMap.containsKey("class")
&& attributeMap.get("class").equals("cash")
&& attributeMap.get("amount") != null) {
fare = "$" + attributeMap.get("amount");
}
}