From: gu.martinm@gmail.com Date: Mon, 15 Sep 2014 18:06:24 +0000 (+0200) Subject: WeatherInformation: getApplicationContext() works even with screen rotations X-Git-Tag: weatherinformation-1.0~136 X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=1fc531b92fade23e3f07469cf29ada1b9fc73a9a;p=AndroidWeatherInformation WeatherInformation: getApplicationContext() works even with screen rotations --- 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));