udacity / ud851-Sunshine

Apache License 2.0
2k stars 4.51k forks source link

S05.01 mWeatherData is always null #205

Closed jameskeith closed 5 years ago

jameskeith commented 5 years ago

app/src/main/java/com/example/android/sunshine/MainActivity.java

mWeatherData gets re-initialised to null each time onCreateLoader is executed since it resides within the anonymous class that gets created afresh each time. This defeats the point of the Caching lessons, since it doesn't actually reuse the cached result when the user presses refresh. Moving mWeatherData to be a member variable of the MainActivity class would resolve that issue.