diff --git a/app/src/main/java/de/apps4ics/mountainnavigation/handlers/WeatherHandler.java b/app/src/main/java/de/apps4ics/mountainnavigation/handlers/WeatherHandler.java index 547e458..0e5aaa9 100644 --- a/app/src/main/java/de/apps4ics/mountainnavigation/handlers/WeatherHandler.java +++ b/app/src/main/java/de/apps4ics/mountainnavigation/handlers/WeatherHandler.java @@ -78,7 +78,8 @@ private static int MAX_DAYS_FORECAST; private static float MIN_WINDY_SPEED; - private final static long DAY_IN_MS = 5184000000l; //1000*60*60*24 + private final static long THREE_HOURS_IN_MS = 10800000L; //1000*60*60*3 + private final static long DAY_IN_MS = 5184000000L; //1000*60*60*24 private final static int FORECASTS_PER_DAY = 6; //every 3 hours private static Activity activity; @@ -183,15 +184,15 @@ else getForecastCachedHour(lat, lon, days, 0, callback); } - private void getForecastOnlineHour(double lat, double lon, final int days, final OnWeatherRetrieved callback) { - weatherConfig.numDays = days; + private void getForecastOnlineHour(double lat, double lon, final int forecasts, final OnWeatherRetrieved callback) { + weatherConfig.numDays = forecasts; weatherClient.updateWeatherConfig(weatherConfig); weatherClient.getHourForecastWeather(new WeatherRequest(lon, lat), new WeatherClient.HourForecastWeatherEventListener() { @Override public void onWeatherRetrieved(WeatherHourForecast forecast) { List weatherList = new ArrayList<>(); List foundForecasts = forecast.getHourForecast(); - int dayCount = Math.min(foundForecasts.size(), days); + int dayCount = Math.min(foundForecasts.size(), forecasts); if(dayCount == 0) return; hourForecasts = new HourForecast[dayCount]; weathers = new Weather[dayCount]; @@ -235,13 +236,12 @@ }); } - //TODO CORE get hour forecast from cache - private void getForecastCachedHour(double lat, double lon, int days, int offset, OnWeatherRetrieved callback) { + private void getForecastCachedHour(double lat, double lon, int forecasts, int offset, OnWeatherRetrieved callback) { long timestamp = System.currentTimeMillis(); List weathers = new ArrayList<>(); - for(int i=0; i