Skip to content

Commit

Permalink
[Mobile] Added safety check to Retrofit response processing code.
Browse files Browse the repository at this point in the history
  • Loading branch information
thecosmicfrog committed Mar 22, 2017
1 parent 0e8ac8d commit d994cd3
Showing 1 changed file with 11 additions and 8 deletions.
Expand Up @@ -801,17 +801,20 @@ private void loadStopForecast(String stopName) {
public void success(ApiTimes apiTimes, Response response) {
/* Check Fragment is attached to Activity to avoid NullPointerExceptions. */
if (isAdded()) {
/* Then create a stop forecast with this data. */
StopForecast stopForecast = StopForecastUtil.createStopForecast(apiTimes);
/* If the server returned times. */
if (apiTimes != null) {
/* Then create a stop forecast with this data. */
StopForecast stopForecast = StopForecastUtil.createStopForecast(apiTimes);

clearStopForecast();
clearStopForecast();

/* Update the stop forecast. */
updateStopForecast(stopForecast);
/* Update the stop forecast. */
updateStopForecast(stopForecast);

/* Stop the refresh animations. */
setIsLoading(false);
swipeRefreshLayout.setRefreshing(false);
/* Stop the refresh animations. */
setIsLoading(false);
swipeRefreshLayout.setRefreshing(false);
}
}
}

Expand Down

0 comments on commit d994cd3

Please sign in to comment.