From 1fc531b92fade23e3f07469cf29ada1b9fc73a9a Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Mon, 15 Sep 2014 20:06:24 +0200 Subject: [PATCH] WeatherInformation: getApplicationContext() works even with screen rotations --- src/de/example/exampletdd/fragment/current/CurrentFragment.java | 4 ++-- src/de/example/exampletdd/fragment/overview/OverviewFragment.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/de/example/exampletdd/fragment/current/CurrentFragment.java b/src/de/example/exampletdd/fragment/current/CurrentFragment.java index ca61875..2292985 100644 --- a/src/de/example/exampletdd/fragment/current/CurrentFragment.java +++ b/src/de/example/exampletdd/fragment/current/CurrentFragment.java @@ -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 diff --git a/src/de/example/exampletdd/fragment/overview/OverviewFragment.java b/src/de/example/exampletdd/fragment/overview/OverviewFragment.java index bb9b881..2759120 100644 --- a/src/de/example/exampletdd/fragment/overview/OverviewFragment.java +++ b/src/de/example/exampletdd/fragment/overview/OverviewFragment.java @@ -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)); -- 2.1.4