From ad5551e604f7f46863ed2a091999b8657855beca Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Sun, 28 Sep 2014 04:35:30 +0200 Subject: [PATCH] WeatherInformation: avoid caches --- src/de/example/exampletdd/NotificationIntentService.java | 3 ++- src/de/example/exampletdd/fragment/current/CurrentFragment.java | 3 ++- src/de/example/exampletdd/fragment/overview/OverviewFragment.java | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) 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); } -- 2.1.4