Handle possibily empty lists when iterating
Created by: joshproehl
In MapsActivity.drawHighway for example, we use for loops to run through the list, and assume that the list will contain elements! This is only one example, the entire application should be checked for for loops like this which have the possibility of causing a NullPointerException!
This can cause the application to crash. A better use would be to use list iterators and account for the possibility that the list is empty.
Steps to reproduce:
- Edit APIEntity.getNestedEntityUrlComponent(), change the URL. (Add an extra s before "s/") (This will force calls to highways/x/stations to fail.)
- Observe in the log output that the application will handle the failures, but that this causes the list of highways to be empty.
- Observe that the application crashes with a NullPointerException, caused by the for loop assuming that the list is non-empty.