WeatherInformation: getApplicationContext() works even with screen rotations
authorgu.martinm@gmail.com <gu.martinm@gmail.com>
Mon, 15 Sep 2014 18:06:24 +0000 (20:06 +0200)
committergu.martinm@gmail.com <gu.martinm@gmail.com>
Mon, 15 Sep 2014 18:06:24 +0000 (20:06 +0200)
Android/WeatherInformation/src/de/example/exampletdd/fragment/current/CurrentFragment.java
Android/WeatherInformation/src/de/example/exampletdd/fragment/overview/OverviewFragment.java

index ca61875..2292985 100644 (file)
@@ -378,8 +378,8 @@ public class CurrentFragment extends Fragment {
                 final CustomHTTPClient HTTPClient, final ServiceParser serviceParser)
                         throws URISyntaxException, ClientProtocolException, JsonParseException, IOException {
 
-               final String APIVersion = getResources().getString(R.string.api_version);
-            final String urlAPI = getResources().getString(R.string.uri_api_weather_today);
+               final String APIVersion = localContext.getResources().getString(R.string.api_version);
+            final String urlAPI = localContext.getResources().getString(R.string.uri_api_weather_today);
             final String url = weatherService.createURIAPICurrent(urlAPI, APIVersion, latitude, longitude);
             final String jsonData = weatherHTTPClient.retrieveDataAsString(new URL(url));
             final Current current = weatherService
index bb9b881..2759120 100644 (file)
@@ -355,8 +355,8 @@ public class OverviewFragment extends ListFragment {
                 final CustomHTTPClient HTTPClient, final ServiceParser serviceParser)
                         throws URISyntaxException, ClientProtocolException, JsonParseException, IOException {
 
-            final String APIVersion = getResources().getString(R.string.api_version);
-            final String urlAPI = getResources().getString(R.string.uri_api_weather_forecast);
+            final String APIVersion = localContext.getResources().getString(R.string.api_version);
+            final String urlAPI = localContext.getResources().getString(R.string.uri_api_weather_forecast);
             // TODO: number as resource
             final String url = serviceParser.createURIAPIForecast(urlAPI, APIVersion, latitude, longitude, "14");
             final String jsonData = HTTPClient.retrieveDataAsString(new URL(url));