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 1837cba..98ed755 100644 --- a/app/src/main/java/de/apps4ics/mountainnavigation/handlers/WeatherHandler.java +++ b/app/src/main/java/de/apps4ics/mountainnavigation/handlers/WeatherHandler.java @@ -12,6 +12,7 @@ import com.survivingwithandroid.weather.lib.exception.WeatherLibException; import com.survivingwithandroid.weather.lib.exception.WeatherProviderInstantiationException; import com.survivingwithandroid.weather.lib.model.DayForecast; +import com.survivingwithandroid.weather.lib.model.HistoricalHourWeather; import com.survivingwithandroid.weather.lib.model.HistoricalWeather; import com.survivingwithandroid.weather.lib.model.Weather; import com.survivingwithandroid.weather.lib.model.WeatherForecast; @@ -191,19 +192,20 @@ }); } - public MyWeather getForecastOnline(double lat, double lon, int days, int step) { - return new MyWeather(new WeatherForecast()); + public List getForecastOnline(double lat, double lon, int days, int step) { + return null; } - public MyWeather getForecastCached(double lat, double lon, int days, int step, int offset) { - return new MyWeather(new WeatherForecast()); + public List getForecastCached(double lat, double lon, int days, int step, int offset) { + return null; } - public MyWeather getHistoricalWeather(float lat, float lon, long start, long end){ + public List getHistoricalWeather(float lat, float lon, long start, long end){ return getHistoricalWeather(lat, lon, start, end, 3); } - public MyWeather getHistoricalWeather(float lat, float lon, long start, long end, int step){ + public List getHistoricalWeather(float lat, float lon, long start, long end, int step){ + ArrayList weathers = new ArrayList<>(); Date startDate = new Date(start / 1000); //OWM uses seconds instead of milliseconds Date endDate = new Date(end / 1000); histWeather = null; @@ -226,11 +228,18 @@ t.printStackTrace(); } }); - return new MyWeather(histWeather); + for(HistoricalHourWeather hhw : histWeather.getHoistoricalData()) { + weathers.add(new MyWeather(hhw.weather, hhw.timestamp)); + } + return weathers; } private void insertIntoDatabase(Weather weather) { - insertIntoDatabase(new MyWeather(weather)); + insertIntoDatabase(weather, 0); + } + + private void insertIntoDatabase(Weather weather, long timestamp) { + insertIntoDatabase(new MyWeather(weather, timestamp)); } private void insertIntoDatabase(MyWeather weather) {