Permalink
Browse files

[Mobile] Added safety check to Retrofit response processing code.

  • Loading branch information...
thecosmicfrog committed Mar 22, 2017
1 parent 0e8ac8d commit d994cd318d79a59090790412ca7f095847d56165
Showing with 11 additions and 8 deletions.
  1. +11 −8 mobile/src/main/java/org/thecosmicfrog/luasataglance/activity/LineFragment.java
@@ -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);
}
}
}

0 comments on commit d994cd3

Please sign in to comment.