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-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=aebf92b73b135f8988b50efd757be17cd0340ae5;p=JavaForFun WeatherInformation: getApplicationContext() works even with screen rotations --- diff --git a/Android/WeatherInformation/src/de/example/exampletdd/fragment/current/CurrentFragment.java b/Android/WeatherInformation/src/de/example/exampletdd/fragment/current/CurrentFragment.java index ca61875..2292985 100644 --- a/Android/WeatherInformation/src/de/example/exampletdd/fragment/current/CurrentFragment.java +++ b/Android/WeatherInformation/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/Android/WeatherInformation/src/de/example/exampletdd/fragment/overview/OverviewFragment.java b/Android/WeatherInformation/src/de/example/exampletdd/fragment/overview/OverviewFragment.java index bb9b881..2759120 100644 --- a/Android/WeatherInformation/src/de/example/exampletdd/fragment/overview/OverviewFragment.java +++ b/Android/WeatherInformation/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));