From: gu.martinm@gmail.com Date: Sun, 28 Sep 2014 02:35:30 +0000 (+0200) Subject: WeatherInformation: avoid caches X-Git-Tag: weatherinformation-1.0~113 X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=ad5551e604f7f46863ed2a091999b8657855beca;p=AndroidWeatherInformation WeatherInformation: avoid caches --- diff --git a/src/de/example/exampletdd/NotificationIntentService.java b/src/de/example/exampletdd/NotificationIntentService.java index f953b53..d544cb9 100644 --- a/src/de/example/exampletdd/NotificationIntentService.java +++ b/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/src/de/example/exampletdd/fragment/current/CurrentFragment.java b/src/de/example/exampletdd/fragment/current/CurrentFragment.java index 64d83a2..0c2a263 100644 --- a/src/de/example/exampletdd/fragment/current/CurrentFragment.java +++ b/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/src/de/example/exampletdd/fragment/overview/OverviewFragment.java b/src/de/example/exampletdd/fragment/overview/OverviewFragment.java index c24bfdd..465279b 100644 --- a/src/de/example/exampletdd/fragment/overview/OverviewFragment.java +++ b/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); }