From: gu.martinm@gmail.com Date: Sun, 28 Sep 2014 02:35:30 +0000 (+0200) Subject: WeatherInformation: avoid caches X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=7ea21d09cac2759f78145e42b3e2e0efcbe22915;p=JavaForFun WeatherInformation: avoid caches --- diff --git a/Android/WeatherInformation/src/de/example/exampletdd/NotificationIntentService.java b/Android/WeatherInformation/src/de/example/exampletdd/NotificationIntentService.java index f953b53..d544cb9 100644 --- a/Android/WeatherInformation/src/de/example/exampletdd/NotificationIntentService.java +++ b/Android/WeatherInformation/src/de/example/exampletdd/NotificationIntentService.java @@ -89,7 +89,8 @@ public class NotificationIntentService extends IntentService { final String urlAPI = this.getResources().getString(R.string.uri_api_weather_today); final String url = weatherService.createURIAPICurrent(urlAPI, APIVersion, weatherLocation.getLatitude(), weatherLocation.getLongitude()); - final String jsonData = HTTPClient.retrieveDataAsString(new URL(url)); + final String urlWithoutCache = url.concat("&time=" + System.currentTimeMillis()); + final String jsonData = HTTPClient.retrieveDataAsString(new URL(urlWithoutCache)); final Current current = weatherService.retrieveCurrentFromJPOS(jsonData); // TODO: what is this for? I guess I could skip it :/ final Calendar now = Calendar.getInstance(); 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 64d83a2..0c2a263 100644 --- a/Android/WeatherInformation/src/de/example/exampletdd/fragment/current/CurrentFragment.java +++ b/Android/WeatherInformation/src/de/example/exampletdd/fragment/current/CurrentFragment.java @@ -498,7 +498,8 @@ public class CurrentFragment extends Fragment { 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 = HTTPClient.retrieveDataAsString(new URL(url)); + final String urlWithoutCache = url.concat("&time=" + System.currentTimeMillis()); + final String jsonData = HTTPClient.retrieveDataAsString(new URL(urlWithoutCache)); final Current current = weatherService.retrieveCurrentFromJPOS(jsonData); // TODO: what is this for? I guess I could skip it :/ final Calendar now = Calendar.getInstance(); 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 c24bfdd..465279b 100644 --- a/Android/WeatherInformation/src/de/example/exampletdd/fragment/overview/OverviewFragment.java +++ b/Android/WeatherInformation/src/de/example/exampletdd/fragment/overview/OverviewFragment.java @@ -359,7 +359,8 @@ public class OverviewFragment extends ListFragment { final String urlAPI = localContext.getResources().getString(R.string.uri_api_weather_forecast); // TODO: number as resource final String url = weatherService.createURIAPIForecast(urlAPI, APIVersion, latitude, longitude, "14"); - final String jsonData = HTTPClient.retrieveDataAsString(new URL(url)); + final String urlWithoutCache = url.concat("&time=" + System.currentTimeMillis()); + final String jsonData = HTTPClient.retrieveDataAsString(new URL(urlWithoutCache)); return weatherService.retrieveForecastFromJPOS(jsonData); }