diff --git a/README.md b/README.md index 124d841..60024b7 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,10 @@ solarCast forecasts the output of your solar power plant +This app takes direct and diffuse radiation data from Open-Meteo.com, calculates the position +of the sun and projects the radiation on your solar panel. +It shows the estimated energy production for the next hours and up to 16 days. + diff --git a/app/src/main/java/org/woheller69/weather/activities/ForecastCityActivity.java b/app/src/main/java/org/woheller69/weather/activities/ForecastCityActivity.java index a590745..10082f4 100644 --- a/app/src/main/java/org/woheller69/weather/activities/ForecastCityActivity.java +++ b/app/src/main/java/org/woheller69/weather/activities/ForecastCityActivity.java @@ -1,17 +1,10 @@ package org.woheller69.weather.activities; -import static java.lang.Boolean.TRUE; - -import android.Manifest; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.location.LocationListener; -import android.location.LocationManager; import android.os.Bundle; -import androidx.core.app.ActivityCompat; import androidx.preference.PreferenceManager; import com.google.android.material.tabs.TabLayout; import com.google.android.material.tabs.TabLayoutMediator; @@ -19,31 +12,25 @@ import com.google.android.material.tabs.TabLayoutMediator; import androidx.recyclerview.widget.RecyclerView; import androidx.viewpager2.widget.ViewPager2; -import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.LinearInterpolator; import android.view.animation.RotateAnimation; import android.widget.TextView; -import android.widget.Toast; import org.woheller69.weather.R; -import org.woheller69.weather.database.CityToWatch; -import org.woheller69.weather.database.CurrentWeatherData; +import org.woheller69.weather.database.GeneralData; import org.woheller69.weather.database.HourlyForecast; import org.woheller69.weather.database.SQLiteHelper; import org.woheller69.weather.database.WeekForecast; import org.woheller69.weather.ui.updater.IUpdateableCityUI; import org.woheller69.weather.ui.updater.ViewUpdater; import org.woheller69.weather.ui.viewPager.WeatherPagerAdapter; -import static org.woheller69.weather.database.SQLiteHelper.getWidgetCityID; import java.lang.reflect.Field; import java.util.List; -import java.util.Locale; public class ForecastCityActivity extends NavigationActivity implements IUpdateableCityUI { private WeatherPagerAdapter pagerAdapter; @@ -88,9 +75,9 @@ public class ForecastCityActivity extends NavigationActivity implements IUpdatea if (pagerAdapter.getItemCount()>0) { //only if at least one city is watched //if pagerAdapter has item with current cityId go there, otherwise use cityId from current item if (pagerAdapter.getPosForCityID(cityId)==-1) cityId=pagerAdapter.getCityIDForPos(viewPager2.getCurrentItem()); - CurrentWeatherData currentWeather = db.getCurrentWeatherByCityId(cityId); + GeneralData generalData = db.getGeneralDataByCityId(cityId); - long timestamp = currentWeather.getTimestamp(); + long timestamp = generalData.getTimestamp(); long systemTime = System.currentTimeMillis() / 1000; SharedPreferences prefManager = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); long updateInterval = (long) (Float.parseFloat(prefManager.getString("pref_updateInterval", "2")) * 60 * 60); @@ -120,9 +107,9 @@ public class ForecastCityActivity extends NavigationActivity implements IUpdatea //Update current tab if outside update interval, show animation SharedPreferences prefManager = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SQLiteHelper database = SQLiteHelper.getInstance(getApplicationContext().getApplicationContext()); - CurrentWeatherData currentWeather = database.getCurrentWeatherByCityId(pagerAdapter.getCityIDForPos(position)); + GeneralData generalData = database.getGeneralDataByCityId(pagerAdapter.getCityIDForPos(position)); - long timestamp = currentWeather.getTimestamp(); + long timestamp = generalData.getTimestamp(); long systemTime = System.currentTimeMillis() / 1000; long updateInterval = (long) (Float.parseFloat(prefManager.getString("pref_updateInterval", "2")) * 60 * 60); @@ -204,7 +191,7 @@ public class ForecastCityActivity extends NavigationActivity implements IUpdatea } @Override - public void processNewCurrentWeatherData(CurrentWeatherData data) { + public void processNewGeneralData(GeneralData data) { if (refreshActionButton != null && refreshActionButton.getActionView() != null) { refreshActionButton.getActionView().clearAnimation(); } diff --git a/app/src/main/java/org/woheller69/weather/activities/ManageLocationsActivity.java b/app/src/main/java/org/woheller69/weather/activities/ManageLocationsActivity.java index dc6235f..42adf6b 100644 --- a/app/src/main/java/org/woheller69/weather/activities/ManageLocationsActivity.java +++ b/app/src/main/java/org/woheller69/weather/activities/ManageLocationsActivity.java @@ -150,7 +150,8 @@ public class ManageLocationsActivity extends NavigationActivity { @Override public void afterTextChanged(Editable editable) { float elevation = Float.parseFloat("0"+editElevation.getText().toString()); - editDiffuseEfficiency.setText(Float.toString(100-50 * elevation/90)); + int diffuseEfficiency = (int) (100-50 * elevation/90); + editDiffuseEfficiency.setText(Float.toString((float) diffuseEfficiency)); } }); diff --git a/app/src/main/java/org/woheller69/weather/database/CurrentWeatherData.java b/app/src/main/java/org/woheller69/weather/database/GeneralData.java similarity index 50% rename from app/src/main/java/org/woheller69/weather/database/CurrentWeatherData.java rename to app/src/main/java/org/woheller69/weather/database/GeneralData.java index 8c8aa5c..e9e29e2 100644 --- a/app/src/main/java/org/woheller69/weather/database/CurrentWeatherData.java +++ b/app/src/main/java/org/woheller69/weather/database/GeneralData.java @@ -9,40 +9,23 @@ import java.util.TimeZone; * This class represents the database model for current weather data of cities. */ -public class CurrentWeatherData { +public class GeneralData { private int id; private int city_id; private long timestamp; - private int weatherID; - private float temperatureCurrent; - private float humidity; - private float pressure; - private float windSpeed; - private float windDirection; - private float cloudiness; private long timeSunrise; private long timeSunset; private int timeZoneSeconds; - private String Rain60min; - private String city_name; - - public CurrentWeatherData() { + public GeneralData() { this.city_id = Integer.MIN_VALUE; } - public CurrentWeatherData(int id, int city_id, long timestamp, int weatherID, float temperatureCurrent, float temperatureMin, float temperatureMax, float humidity, float pressure, float windSpeed, float windDirection, float cloudiness, long timeSunrise, long timeSunset, int timeZoneSeconds) { + public GeneralData(int id, int city_id, long timestamp, int weatherID, float temperatureCurrent, float temperatureMin, float temperatureMax, float humidity, float pressure, float windSpeed, float windDirection, float cloudiness, long timeSunrise, long timeSunset, int timeZoneSeconds) { this.id = id; this.city_id = city_id; this.timestamp = timestamp; - this.weatherID = weatherID; - this.temperatureCurrent = temperatureCurrent; - this.humidity = humidity; - this.pressure = pressure; - this.windSpeed = windSpeed; - this.windDirection = windDirection; - this.cloudiness = cloudiness; this.timeSunrise = timeSunrise; this.timeSunset = timeSunset; this.timeZoneSeconds = timeZoneSeconds; @@ -72,61 +55,6 @@ public class CurrentWeatherData { this.timestamp = timestamp; } - public int getWeatherID() { - return weatherID; - } - - public void setWeatherID(int weatherID) { - this.weatherID = weatherID; - } - - public float getTemperatureCurrent() { - return temperatureCurrent; - } - - public void setTemperatureCurrent(float temperatureCurrent) { - this.temperatureCurrent = temperatureCurrent; - } - - public float getHumidity() { - return humidity; - } - - public void setHumidity(float humidity) { - this.humidity = humidity; - } - - public float getPressure() { - return pressure; - } - - public void setPressure(float pressure) { - this.pressure = pressure; - } - - public float getWindSpeed() { - return windSpeed; - } - - public void setWindSpeed(float windSpeed) { - this.windSpeed = windSpeed; - } - - public float getWindDirection() { - return windDirection; - } - - public void setWindDirection(float windDirection) { - this.windDirection = windDirection; - } - - public float getCloudiness() { - return cloudiness; - } - - public void setCloudiness(float cloudiness) { - this.cloudiness = cloudiness; - } public boolean isDay(Context context){ Calendar timeStamp = Calendar.getInstance(); @@ -158,14 +86,6 @@ public class CurrentWeatherData { this.timeSunset = timeSunset; } - public String getCity_name() { - return city_name; - } - - public void setCity_name(String city_name) { - this.city_name = city_name; - } - public int getTimeZoneSeconds() { return timeZoneSeconds; } @@ -174,11 +94,4 @@ public class CurrentWeatherData { this.timeZoneSeconds = timeZoneSeconds; } - public String getRain60min() { - return Rain60min; - } - - public void setRain60min(String Rain60min) { - this.Rain60min = Rain60min; - } } diff --git a/app/src/main/java/org/woheller69/weather/database/HourlyForecast.java b/app/src/main/java/org/woheller69/weather/database/HourlyForecast.java index 73a6727..2a6cdfe 100644 --- a/app/src/main/java/org/woheller69/weather/database/HourlyForecast.java +++ b/app/src/main/java/org/woheller69/weather/database/HourlyForecast.java @@ -45,7 +45,7 @@ public class HourlyForecast { */ public long getLocalForecastTime(Context context) { SQLiteHelper dbhelper = SQLiteHelper.getInstance(context); - int timezoneseconds = dbhelper.getCurrentWeatherByCityId(city_id).getTimeZoneSeconds(); + int timezoneseconds = dbhelper.getGeneralDataByCityId(city_id).getTimeZoneSeconds(); return forecastFor + timezoneseconds * 1000L; } diff --git a/app/src/main/java/org/woheller69/weather/database/SQLiteHelper.java b/app/src/main/java/org/woheller69/weather/database/SQLiteHelper.java index a9b8e2f..840612d 100644 --- a/app/src/main/java/org/woheller69/weather/database/SQLiteHelper.java +++ b/app/src/main/java/org/woheller69/weather/database/SQLiteHelper.java @@ -33,7 +33,7 @@ public class SQLiteHelper extends SQLiteOpenHelper { private static final String TABLE_CITIES_TO_WATCH = "CITIES_TO_WATCH"; private static final String TABLE_HOURLY_FORECAST = "FORECASTS"; private static final String TABLE_WEEKFORECAST = "WEEKFORECASTS"; - private static final String TABLE_CURRENT_WEATHER = "CURRENT_WEATHER"; + private static final String TABLE_GENERAL_DATA = "GENERAL_DATA"; //Names of columns in TABLE_CITIES_TO_WATCH @@ -69,55 +69,30 @@ public class SQLiteHelper extends SQLiteOpenHelper { private static final String WEEKFORECAST_COLUMN_TIME_MEASUREMENT = "time_of_measurement"; private static final String WEEKFORECAST_COLUMN_FORECAST_FOR = "forecast_for"; private static final String WEEKFORECAST_COLUMN_WEATHER_ID = "weather_id"; - private static final String WEEKFORECAST_COLUMN_TEMPERATURE_CURRENT = "temperature_current"; - private static final String WEEKFORECAST_COLUMN_TEMPERATURE_MIN = "temperature_min"; - private static final String WEEKFORECAST_COLUMN_TEMPERATURE_MAX = "temperature_max"; - private static final String WEEKFORECAST_COLUMN_HUMIDITY = "humidity"; - private static final String WEEKFORECAST_COLUMN_PRESSURE = "pressure"; - private static final String WEEKFORECAST_COLUMN_PRECIPITATION = "precipitation"; - private static final String WEEKFORECAST_COLUMN_WIND_SPEED = "wind_speed"; - private static final String WEEKFORECAST_COLUMN_WIND_DIRECTION = "wind_direction"; - private static final String WEEKFORECAST_COLUMN_UV_INDEX = "uv_index"; + private static final String WEEKFORECAST_COLUMN_ENERGY_DAY = "energy_day"; private static final String WEEKFORECAST_COLUMN_TIME_SUNRISE = "time_sunrise"; private static final String WEEKFORECAST_COLUMN_TIME_SUNSET = "time_sunset"; - //Names of columns in TABLE_CURRENT_WEATHER - private static final String CURRENT_WEATHER_ID = "current_weather_id"; - private static final String CURRENT_WEATHER_CITY_ID = "city_id"; + //Names of columns in TABLE_GENERAL_DATA + private static final String COLUMN_ID = "current_id"; + private static final String COLUMN_CITY_ID = "city_id"; private static final String COLUMN_TIME_MEASUREMENT = "time_of_measurement"; - private static final String COLUMN_WEATHER_ID = "weather_id"; - private static final String COLUMN_TEMPERATURE_CURRENT = "temperature_current"; - private static final String COLUMN_HUMIDITY = "humidity"; - private static final String COLUMN_PRESSURE = "pressure"; - private static final String COLUMN_WIND_SPEED = "wind_speed"; - private static final String COLUMN_WIND_DIRECTION = "wind_direction"; - private static final String COLUMN_CLOUDINESS = "cloudiness"; private static final String COLUMN_TIME_SUNRISE = "time_sunrise"; private static final String COLUMN_TIME_SUNSET = "time_sunset"; private static final String COLUMN_TIMEZONE_SECONDS = "timezone_seconds"; - private static final String COLUMN_RAIN60MIN = "Rain60min"; /** * Create Table statements for all tables */ - private static final String CREATE_CURRENT_WEATHER = "CREATE TABLE " + TABLE_CURRENT_WEATHER + + private static final String CREATE_GENERAL_DATA = "CREATE TABLE " + TABLE_GENERAL_DATA + "(" + - CURRENT_WEATHER_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + - CURRENT_WEATHER_CITY_ID + " INTEGER," + + COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + + COLUMN_CITY_ID + " INTEGER," + COLUMN_TIME_MEASUREMENT + " LONG NOT NULL," + - COLUMN_WEATHER_ID + " INTEGER," + - COLUMN_TEMPERATURE_CURRENT + " REAL," + - COLUMN_HUMIDITY + " REAL," + - COLUMN_PRESSURE + " REAL," + - COLUMN_WIND_SPEED + " REAL," + - COLUMN_WIND_DIRECTION + " REAL," + - COLUMN_CLOUDINESS + " REAL," + COLUMN_TIME_SUNRISE + " LONG NOT NULL," + COLUMN_TIME_SUNSET + " LONG NOT NULL," + - COLUMN_TIMEZONE_SECONDS + " INTEGER," + - COLUMN_RAIN60MIN + " VARCHAR(25) NOT NULL) ;"; - + COLUMN_TIMEZONE_SECONDS + " INTEGER)"; private static final String CREATE_TABLE_FORECASTS = "CREATE TABLE " + TABLE_HOURLY_FORECAST + "(" + @@ -137,15 +112,7 @@ public class SQLiteHelper extends SQLiteOpenHelper { WEEKFORECAST_COLUMN_TIME_MEASUREMENT + " LONG NOT NULL," + WEEKFORECAST_COLUMN_FORECAST_FOR + " VARCHAR(200) NOT NULL," + WEEKFORECAST_COLUMN_WEATHER_ID + " INTEGER," + - WEEKFORECAST_COLUMN_TEMPERATURE_CURRENT + " REAL," + - WEEKFORECAST_COLUMN_TEMPERATURE_MIN + " REAL," + - WEEKFORECAST_COLUMN_TEMPERATURE_MAX + " REAL," + - WEEKFORECAST_COLUMN_HUMIDITY + " REAL," + - WEEKFORECAST_COLUMN_PRESSURE + " REAL," + - WEEKFORECAST_COLUMN_PRECIPITATION + " REAL," + - WEEKFORECAST_COLUMN_WIND_SPEED + " REAL," + - WEEKFORECAST_COLUMN_WIND_DIRECTION + " REAL," + - WEEKFORECAST_COLUMN_UV_INDEX + " REAL," + + WEEKFORECAST_COLUMN_ENERGY_DAY + " REAL," + WEEKFORECAST_COLUMN_TIME_SUNRISE + " LONG NOT NULL," + WEEKFORECAST_COLUMN_TIME_SUNSET + " LONG NOT NULL)"; @@ -182,7 +149,7 @@ public class SQLiteHelper extends SQLiteOpenHelper { @Override public void onCreate(SQLiteDatabase db) { db.execSQL(CREATE_TABLE_CITIES_TO_WATCH); - db.execSQL(CREATE_CURRENT_WEATHER); + db.execSQL(CREATE_GENERAL_DATA); db.execSQL(CREATE_TABLE_FORECASTS); db.execSQL(CREATE_TABLE_WEEKFORECASTS); } @@ -192,7 +159,6 @@ public class SQLiteHelper extends SQLiteOpenHelper { } - /** * Methods for TABLE_CITIES_TO_WATCH */ @@ -352,7 +318,7 @@ public class SQLiteHelper extends SQLiteOpenHelper { public synchronized void deleteCityToWatch(CityToWatch cityToWatch) { //First delete all weather data for city which is deleted - deleteCurrentWeatherByCityId(cityToWatch.getCityId()); + deleteGeneralDataByCityId(cityToWatch.getCityId()); deleteForecastsByCityId(cityToWatch.getCityId()); deleteWeekForecastsByCityId(cityToWatch.getCityId()); @@ -457,15 +423,7 @@ public class SQLiteHelper extends SQLiteOpenHelper { values.put(WEEKFORECAST_COLUMN_TIME_MEASUREMENT, weekForecast.getTimestamp()); values.put(WEEKFORECAST_COLUMN_FORECAST_FOR, weekForecast.getForecastTime()); values.put(WEEKFORECAST_COLUMN_WEATHER_ID, weekForecast.getWeatherID()); - values.put(WEEKFORECAST_COLUMN_TEMPERATURE_CURRENT, weekForecast.getTemperature()); - values.put(WEEKFORECAST_COLUMN_TEMPERATURE_MIN, weekForecast.getMinTemperature()); - values.put(WEEKFORECAST_COLUMN_TEMPERATURE_MAX, weekForecast.getMaxTemperature()); - values.put(WEEKFORECAST_COLUMN_HUMIDITY, weekForecast.getHumidity()); - values.put(WEEKFORECAST_COLUMN_PRESSURE, weekForecast.getPressure()); - values.put(WEEKFORECAST_COLUMN_PRECIPITATION, weekForecast.getPrecipitation()); - values.put(WEEKFORECAST_COLUMN_WIND_SPEED, weekForecast.getWind_speed()); - values.put(WEEKFORECAST_COLUMN_WIND_DIRECTION, weekForecast.getWind_direction()); - values.put(WEEKFORECAST_COLUMN_UV_INDEX, weekForecast.getUv_index()); + values.put(WEEKFORECAST_COLUMN_ENERGY_DAY, weekForecast.getEnergyDay()); values.put(WEEKFORECAST_COLUMN_TIME_SUNRISE, weekForecast.getTimeSunrise()); values.put(WEEKFORECAST_COLUMN_TIME_SUNSET, weekForecast.getTimeSunset()); database.insert(TABLE_WEEKFORECAST, null, values); @@ -492,15 +450,7 @@ public class SQLiteHelper extends SQLiteOpenHelper { WEEKFORECAST_COLUMN_TIME_MEASUREMENT, WEEKFORECAST_COLUMN_FORECAST_FOR, WEEKFORECAST_COLUMN_WEATHER_ID, - WEEKFORECAST_COLUMN_TEMPERATURE_CURRENT, - WEEKFORECAST_COLUMN_TEMPERATURE_MIN, - WEEKFORECAST_COLUMN_TEMPERATURE_MAX, - WEEKFORECAST_COLUMN_HUMIDITY, - WEEKFORECAST_COLUMN_PRESSURE, - WEEKFORECAST_COLUMN_PRECIPITATION, - WEEKFORECAST_COLUMN_WIND_SPEED, - WEEKFORECAST_COLUMN_WIND_DIRECTION, - WEEKFORECAST_COLUMN_UV_INDEX, + WEEKFORECAST_COLUMN_ENERGY_DAY, WEEKFORECAST_COLUMN_TIME_SUNRISE, WEEKFORECAST_COLUMN_TIME_SUNSET} , WEEKFORECAST_CITY_ID + "=?", @@ -517,17 +467,9 @@ public class SQLiteHelper extends SQLiteOpenHelper { weekForecast.setTimestamp(Long.parseLong(cursor.getString(2))); weekForecast.setForecastTime(Long.parseLong(cursor.getString(3))); weekForecast.setWeatherID(Integer.parseInt(cursor.getString(4))); - weekForecast.setTemperature(Float.parseFloat(cursor.getString(5))); - weekForecast.setMinTemperature(Float.parseFloat(cursor.getString(6))); - weekForecast.setMaxTemperature(Float.parseFloat(cursor.getString(7))); - weekForecast.setHumidity(Float.parseFloat(cursor.getString(8))); - weekForecast.setPressure(Float.parseFloat(cursor.getString(9))); - weekForecast.setPrecipitation(Float.parseFloat(cursor.getString(10))); - weekForecast.setWind_speed(Float.parseFloat(cursor.getString(11))); - weekForecast.setWind_direction(Float.parseFloat(cursor.getString(12))); - weekForecast.setUv_index(Float.parseFloat(cursor.getString(13))); - weekForecast.setTimeSunrise(Long.parseLong(cursor.getString(14))); - weekForecast.setTimeSunset(Long.parseLong(cursor.getString(15))); + weekForecast.setEnergyDay(Float.parseFloat(cursor.getString(5))); + weekForecast.setTimeSunrise(Long.parseLong(cursor.getString(6))); + weekForecast.setTimeSunset(Long.parseLong(cursor.getString(7))); list.add(weekForecast); } while (cursor.moveToNext()); @@ -538,128 +480,71 @@ public class SQLiteHelper extends SQLiteOpenHelper { } /** - * Methods for TABLE_CURRENT_WEATHER + * Methods for TABLE_GENERAL_DATA */ - public synchronized void addCurrentWeather(CurrentWeatherData currentWeather) { + public synchronized void addGeneralData(GeneralData generalData) { SQLiteDatabase database = this.getWritableDatabase(); ContentValues values = new ContentValues(); - values.put(CURRENT_WEATHER_CITY_ID, currentWeather.getCity_id()); - values.put(COLUMN_TIME_MEASUREMENT, currentWeather.getTimestamp()); - values.put(COLUMN_WEATHER_ID, currentWeather.getWeatherID()); - values.put(COLUMN_TEMPERATURE_CURRENT, currentWeather.getTemperatureCurrent()); - values.put(COLUMN_HUMIDITY, currentWeather.getHumidity()); - values.put(COLUMN_PRESSURE, currentWeather.getPressure()); - values.put(COLUMN_WIND_SPEED, currentWeather.getWindSpeed()); - values.put(COLUMN_WIND_DIRECTION, currentWeather.getWindDirection()); - values.put(COLUMN_CLOUDINESS, currentWeather.getCloudiness()); - values.put(COLUMN_TIME_SUNRISE, currentWeather.getTimeSunrise()); - values.put(COLUMN_TIME_SUNSET, currentWeather.getTimeSunset()); - values.put(COLUMN_TIMEZONE_SECONDS, currentWeather.getTimeZoneSeconds()); - values.put(COLUMN_RAIN60MIN, currentWeather.getRain60min()); + values.put(COLUMN_CITY_ID, generalData.getCity_id()); + values.put(COLUMN_TIME_MEASUREMENT, generalData.getTimestamp()); + values.put(COLUMN_TIME_SUNRISE, generalData.getTimeSunrise()); + values.put(COLUMN_TIME_SUNSET, generalData.getTimeSunset()); + values.put(COLUMN_TIMEZONE_SECONDS, generalData.getTimeZoneSeconds()); - - database.insert(TABLE_CURRENT_WEATHER, null, values); + database.insert(TABLE_GENERAL_DATA, null, values); database.close(); } - public synchronized CurrentWeatherData getCurrentWeatherByCityId(int cityId) { + public synchronized GeneralData getGeneralDataByCityId(int cityId) { SQLiteDatabase database = this.getReadableDatabase(); - Cursor cursor = database.query(TABLE_CURRENT_WEATHER, - new String[]{CURRENT_WEATHER_ID, - CURRENT_WEATHER_CITY_ID, + Cursor cursor = database.query(TABLE_GENERAL_DATA, + new String[]{COLUMN_ID, + COLUMN_CITY_ID, COLUMN_TIME_MEASUREMENT, - COLUMN_WEATHER_ID, - COLUMN_TEMPERATURE_CURRENT, - COLUMN_HUMIDITY, - COLUMN_PRESSURE, - COLUMN_WIND_SPEED, - COLUMN_WIND_DIRECTION, - COLUMN_CLOUDINESS, COLUMN_TIME_SUNRISE, COLUMN_TIME_SUNSET, - COLUMN_TIMEZONE_SECONDS, - COLUMN_RAIN60MIN}, - CURRENT_WEATHER_CITY_ID + " = ?", + COLUMN_TIMEZONE_SECONDS}, + COLUMN_CITY_ID + " = ?", new String[]{String.valueOf(cityId)}, null, null, null, null); - CurrentWeatherData currentWeather = new CurrentWeatherData(); + GeneralData generalData = new GeneralData(); if (cursor != null && cursor.moveToFirst()) { - currentWeather.setId(Integer.parseInt(cursor.getString(0))); - currentWeather.setCity_id(Integer.parseInt(cursor.getString(1))); - currentWeather.setTimestamp(Long.parseLong(cursor.getString(2))); - currentWeather.setWeatherID(Integer.parseInt(cursor.getString(3))); - currentWeather.setTemperatureCurrent(Float.parseFloat(cursor.getString(4))); - currentWeather.setHumidity(Float.parseFloat(cursor.getString(5))); - currentWeather.setPressure(Float.parseFloat(cursor.getString(6))); - currentWeather.setWindSpeed(Float.parseFloat(cursor.getString(7))); - currentWeather.setWindDirection(Float.parseFloat(cursor.getString(8))); - currentWeather.setCloudiness(Float.parseFloat(cursor.getString(9))); - currentWeather.setTimeSunrise(Long.parseLong(cursor.getString(10))); - currentWeather.setTimeSunset(Long.parseLong(cursor.getString(11))); - currentWeather.setTimeZoneSeconds(Integer.parseInt(cursor.getString(12))); - currentWeather.setRain60min(cursor.getString(13)); - + generalData.setId(Integer.parseInt(cursor.getString(0))); + generalData.setCity_id(Integer.parseInt(cursor.getString(1))); + generalData.setTimestamp(Long.parseLong(cursor.getString(2))); + generalData.setTimeSunrise(Long.parseLong(cursor.getString(3))); + generalData.setTimeSunset(Long.parseLong(cursor.getString(4))); + generalData.setTimeZoneSeconds(Integer.parseInt(cursor.getString(5))); cursor.close(); } - return currentWeather; + return generalData; } - public synchronized void updateCurrentWeather(CurrentWeatherData currentWeather) { + public synchronized void updateGeneralData(GeneralData generalData) { SQLiteDatabase database = this.getWritableDatabase(); ContentValues values = new ContentValues(); - values.put(CURRENT_WEATHER_CITY_ID, currentWeather.getCity_id()); - values.put(COLUMN_TIME_MEASUREMENT, currentWeather.getTimestamp()); - values.put(COLUMN_WEATHER_ID, currentWeather.getWeatherID()); - values.put(COLUMN_TEMPERATURE_CURRENT, currentWeather.getTemperatureCurrent()); - values.put(COLUMN_HUMIDITY, currentWeather.getHumidity()); - values.put(COLUMN_PRESSURE, currentWeather.getPressure()); - values.put(COLUMN_WIND_SPEED, currentWeather.getWindSpeed()); - values.put(COLUMN_WIND_DIRECTION, currentWeather.getWindDirection()); - values.put(COLUMN_CLOUDINESS, currentWeather.getCloudiness()); - values.put(COLUMN_TIME_SUNRISE, currentWeather.getTimeSunrise()); - values.put(COLUMN_TIME_SUNSET, currentWeather.getTimeSunset()); - values.put(COLUMN_TIMEZONE_SECONDS, currentWeather.getTimeZoneSeconds()); - values.put(COLUMN_RAIN60MIN, currentWeather.getRain60min()); + values.put(COLUMN_CITY_ID, generalData.getCity_id()); + values.put(COLUMN_TIME_MEASUREMENT, generalData.getTimestamp()); + values.put(COLUMN_TIME_SUNRISE, generalData.getTimeSunrise()); + values.put(COLUMN_TIME_SUNSET, generalData.getTimeSunset()); + values.put(COLUMN_TIMEZONE_SECONDS, generalData.getTimeZoneSeconds()); - database.update(TABLE_CURRENT_WEATHER, values, CURRENT_WEATHER_CITY_ID + " = ?", - new String[]{String.valueOf(currentWeather.getCity_id())}); + database.update(TABLE_GENERAL_DATA, values, COLUMN_CITY_ID + " = ?", + new String[]{String.valueOf(generalData.getCity_id())}); } - public synchronized void deleteCurrentWeather(CurrentWeatherData currentWeather) { + public synchronized void deleteGeneralDataByCityId(int cityId) { SQLiteDatabase database = this.getWritableDatabase(); - database.delete(TABLE_CURRENT_WEATHER, CURRENT_WEATHER_ID + " = ?", - new String[]{Integer.toString(currentWeather.getId())}); - database.close(); - } - - public synchronized void deleteCurrentWeatherByCityId(int cityId) { - SQLiteDatabase database = this.getWritableDatabase(); - database.delete(TABLE_CURRENT_WEATHER, CURRENT_WEATHER_CITY_ID + " = ?", + database.delete(TABLE_GENERAL_DATA, COLUMN_CITY_ID + " = ?", new String[]{Integer.toString(cityId)}); database.close(); } - public static int getWidgetCityID(Context context) { - SQLiteHelper db = SQLiteHelper.getInstance(context); - int cityID=0; - List cities = db.getAllCitiesToWatch(); - int rank=cities.get(0).getRank(); - for (int i = 0; i < cities.size(); i++) { //find cityID for first city to watch = lowest Rank - CityToWatch city = cities.get(i); - //Log.d("debugtag",Integer.toString(city.getRank())); - if (city.getRank() <= rank ){ - rank=city.getRank(); - cityID = city.getCityId(); - } - } - return cityID; - } - } diff --git a/app/src/main/java/org/woheller69/weather/database/WeekForecast.java b/app/src/main/java/org/woheller69/weather/database/WeekForecast.java index a6af8cc..45583c3 100644 --- a/app/src/main/java/org/woheller69/weather/database/WeekForecast.java +++ b/app/src/main/java/org/woheller69/weather/database/WeekForecast.java @@ -13,36 +13,20 @@ public class WeekForecast { private long timestamp; private long forecastFor; private int weatherID; - private float temperature; - private float temperature_min; - private float temperature_max; - private float humidity; - private float pressure; - private float precipitation; - private float wind_speed; - private float wind_direction; - private float uv_index; + private float energyDay; private long timeSunrise; private long timeSunset; public WeekForecast() { } - public WeekForecast(int id, int city_id, long timestamp, long forecastFor, int weatherID, float temperature, float temperature_min, float temperature_max, float humidity, float pressure, float precipitation, float wind_speed, float wind_direction, float uv_index) { + public WeekForecast(int id, int city_id, long timestamp, long forecastFor, int weatherID, float temperature, float temperature_min, float temperature_max, float humidity, float pressure, float energyDay, float wind_speed, float wind_direction, float uv_index) { this.id = id; this.city_id = city_id; this.timestamp = timestamp; this.forecastFor = forecastFor; this.weatherID = weatherID; - this.temperature = temperature; - this.temperature_min = temperature_min; - this.temperature_max = temperature_max; - this.humidity = humidity; - this.pressure = pressure; - this.precipitation=precipitation; - this.wind_speed=wind_speed; - this.wind_direction=wind_direction; - this.uv_index=uv_index; + this.energyDay = energyDay; } @@ -69,7 +53,7 @@ public class WeekForecast { */ public long getLocalForecastTime(Context context) { SQLiteHelper dbhelper = SQLiteHelper.getInstance(context); - int timezoneseconds = dbhelper.getCurrentWeatherByCityId(city_id).getTimeZoneSeconds(); + int timezoneseconds = dbhelper.getGeneralDataByCityId(city_id).getTimeZoneSeconds(); return forecastFor + timezoneseconds * 1000L; } @@ -117,77 +101,9 @@ public class WeekForecast { this.weatherID = weatherID; } - /** - * @return Returns the current temperature in Celsius. - */ - public float getTemperature() { - return temperature; - } + public float getEnergyDay() {return energyDay;} - /** - * @param temperature The current temperature to set in Celsius. - */ - public void setTemperature(float temperature) { - this.temperature = temperature; - } - - /** - * @return Returns the min temperature in Celsius. - */ - public float getMinTemperature() { - return temperature_min; - } - - /** - * @param temperature_min The min temperature to set in Celsius. - */ - public void setMinTemperature(float temperature_min) { - this.temperature_min = temperature_min; - } - - /** - * @return Returns the max temperature in Celsius. - */ - public float getMaxTemperature() { - return temperature_max; - } - - /** - * @param temperature_max The max temperature to set in Celsius. - */ - public void setMaxTemperature(float temperature_max) { - this.temperature_max = temperature_max; - } - - - /** - * @return Returns the humidity value in percent. - */ - public float getHumidity() { - return humidity; - } - - /** - * @param humidity The humidity value in percent to set. - */ - public void setHumidity(float humidity) { - this.humidity = humidity; - } - - public float getPressure() { return pressure;} - public void setPressure(float pressure) {this.pressure=pressure;} - - public float getPrecipitation() {return precipitation; } - public void setPrecipitation(float precipitation) {this.precipitation=precipitation;} - - public float getWind_speed() { return wind_speed;} - public void setWind_speed(float wind_speed) {this.wind_speed=wind_speed;} - - public float getWind_direction() { return wind_direction;} - public void setWind_direction(float wind_direction) {this.wind_direction=wind_direction;} - - public float getUv_index() { return uv_index; } - public void setUv_index(float uv_index) {this.uv_index=uv_index;} + public void setEnergyDay(float energyDay) {this.energyDay =energyDay;} public long getTimeSunrise() { return timeSunrise; } diff --git a/app/src/main/java/org/woheller69/weather/ui/Help/StringFormatUtils.java b/app/src/main/java/org/woheller69/weather/ui/Help/StringFormatUtils.java index 58701f0..802b534 100644 --- a/app/src/main/java/org/woheller69/weather/ui/Help/StringFormatUtils.java +++ b/app/src/main/java/org/woheller69/weather/ui/Help/StringFormatUtils.java @@ -54,161 +54,6 @@ public final class StringFormatUtils { return df.format(time); } - public static String formatWindSpeed(Context context, float wind_speed) { - SharedPreferences sharedPreferences= PreferenceManager.getDefaultSharedPreferences(context); - if (sharedPreferences.getBoolean("pref_WindFormat",true)==TRUE) { - if (wind_speed < 0.3) { - return formatInt(0, context.getString(R.string.units_Bft)); // Calm - } else if (wind_speed < 1.5) { - return formatInt(1, context.getString(R.string.units_Bft)); // Light air - } else if (wind_speed < 3.3) { - return formatInt(2, context.getString(R.string.units_Bft)); // Light breeze - } else if (wind_speed < 5.5) { - return formatInt(3, context.getString(R.string.units_Bft)); // Gentle breeze - } else if (wind_speed < 7.9) { - return formatInt(4, context.getString(R.string.units_Bft)); // Moderate breeze - } else if (wind_speed < 10.7) { - return formatInt(5, context.getString(R.string.units_Bft)); // Fresh breeze - } else if (wind_speed < 13.8) { - return formatInt(6, context.getString(R.string.units_Bft)); // Strong breeze - } else if (wind_speed < 17.1) { - return formatInt(7, context.getString(R.string.units_Bft)); // High wind - } else if (wind_speed < 20.7) { - return formatInt(8, context.getString(R.string.units_Bft)); // Gale - } else if (wind_speed < 24.4) { - return formatInt(9, context.getString(R.string.units_Bft)); // Strong gale - } else if (wind_speed < 28.4) { - return formatInt(10, context.getString(R.string.units_Bft)); // Storm - } else if (wind_speed < 32.6) { - return formatInt(11, context.getString(R.string.units_Bft)); // Violent storm - } else { - return formatInt(12, context.getString(R.string.units_Bft)); // Hurricane - } - }else{ - if (sharedPreferences.getString("distanceUnit", "0").equals("1")) { //distanceUnit km - return formatInt((float) (wind_speed*3.6),context.getString(R.string.units_km_h)); - }else return formatInt((float) (wind_speed*2.236),context.getString(R.string.units_mph)); - } - } - - public static Drawable colorWindSpeed(Context context, float wind_speed) { - if (wind_speed < 0.3) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_transparent,null); - } else if (wind_speed < 1.5) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_transparent,null); - } else if (wind_speed < 3.3) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_transparent,null); - } else if (wind_speed < 5.5) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_transparent,null); - } else if (wind_speed < 7.9) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_transparent,null); - } else if (wind_speed < 10.7) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_yellow,null); - } else if (wind_speed < 13.8) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_yellow,null); - } else if (wind_speed < 17.1) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_yellow,null); - } else if (wind_speed < 20.7) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_orange,null); - } else if (wind_speed < 24.4) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_orange,null); - } else if (wind_speed < 28.4) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_lightred,null); - } else if (wind_speed < 32.6) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_lightred,null); - } else { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_red,null); - } - } - - public static int colorWindSpeedWidget(float wind_speed) { - if (wind_speed < 0.3) { - return R.drawable.ic_wind_empty; - } else if (wind_speed < 1.5) { - return R.drawable.ic_wind_empty; - } else if (wind_speed < 3.3) { - return R.drawable.ic_wind_empty; - } else if (wind_speed < 5.5) { - return R.drawable.ic_wind_empty; - } else if (wind_speed < 7.9) { - return R.drawable.ic_wind_empty; - } else if (wind_speed < 10.7) { - return R.drawable.ic_wind_yellow; - } else if (wind_speed < 13.8) { - return R.drawable.ic_wind_yellow; - } else if (wind_speed < 17.1) { - return R.drawable.ic_wind_yellow; - } else if (wind_speed < 20.7) { - return R.drawable.ic_wind_orange; - } else if (wind_speed < 24.4) { - return R.drawable.ic_wind_orange; - } else if (wind_speed < 28.4) { - return R.drawable.ic_wind_lightred; - } else if (wind_speed < 32.6) { - return R.drawable.ic_wind_lightred; - } else { - return R.drawable.ic_wind_lightred; - } - } - - public static Drawable colorUVindex(Context context, int uvindex) { - if (uvindex <=2) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_transparent,null); - } else if (uvindex <= 5) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_yellow,null); - } else if (uvindex <= 7) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_orange,null); - } else if (uvindex <= 10) { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_lightred,null); - } else { - return ResourcesCompat.getDrawable(context.getResources(),R.drawable.rounded_violet,null); - } - } - - public static Integer widgetColorWindSpeed(Context context, float wind_speed) { - if (wind_speed < 0.3) { - return R.drawable.rounded_grey; - } else if (wind_speed < 1.5) { - return R.drawable.rounded_grey; - } else if (wind_speed < 3.3) { - return R.drawable.rounded_grey; - } else if (wind_speed < 5.5) { - return R.drawable.rounded_grey; - } else if (wind_speed < 7.9) { - return R.drawable.rounded_grey; - } else if (wind_speed < 10.7) { - return R.drawable.rounded_yellow; - } else if (wind_speed < 13.8) { - return R.drawable.rounded_yellow; - } else if (wind_speed < 17.1) { - return R.drawable.rounded_yellow; - } else if (wind_speed < 20.7) { - return R.drawable.rounded_orange; - } else if (wind_speed < 24.4) { - return R.drawable.rounded_orange; - } else if (wind_speed < 28.4) { - return R.drawable.rounded_lightred; - } else if (wind_speed < 32.6) { - return R.drawable.rounded_lightred; - } else { - return R.drawable.rounded_red; - } - } - - public static Integer widgetColorUVindex(Context context, int uvindex) { - if (uvindex <=2) { - return R.drawable.rounded_green; - } else if (uvindex <= 5) { - return R.drawable.rounded_yellow; - } else if (uvindex <= 7) { - return R.drawable.rounded_orange; - } else if (uvindex <= 10) { - return R.drawable.rounded_lightred; - } else { - return R.drawable.rounded_violet; - } - } - public static Integer getDayShort(int day){ switch(day) { diff --git a/app/src/main/java/org/woheller69/weather/ui/RecycleList/CityWeatherAdapter.java b/app/src/main/java/org/woheller69/weather/ui/RecycleList/CityWeatherAdapter.java index f00f0d6..91c42b4 100644 --- a/app/src/main/java/org/woheller69/weather/ui/RecycleList/CityWeatherAdapter.java +++ b/app/src/main/java/org/woheller69/weather/ui/RecycleList/CityWeatherAdapter.java @@ -3,7 +3,6 @@ package org.woheller69.weather.ui.RecycleList; import android.content.Context; import androidx.core.content.ContextCompat; import androidx.core.content.res.ResourcesCompat; -import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; @@ -15,27 +14,23 @@ import android.widget.TextView; import com.db.chart.Tools; import com.db.chart.model.BarSet; import com.db.chart.model.ChartSet; -import com.db.chart.model.LineSet; import com.db.chart.view.AxisController; import com.db.chart.view.BarChartView; import org.woheller69.weather.R; -import org.woheller69.weather.database.CurrentWeatherData; +import org.woheller69.weather.database.GeneralData; import org.woheller69.weather.database.HourlyForecast; import org.woheller69.weather.database.SQLiteHelper; import org.woheller69.weather.database.WeekForecast; -import org.woheller69.weather.preferences.AppPreferencesManager; import org.woheller69.weather.ui.Help.StringFormatUtils; import org.woheller69.weather.ui.UiResourceProvider; import java.util.ArrayList; import java.util.Calendar; import java.util.List; -import java.util.Locale; import java.util.TimeZone; public class CityWeatherAdapter extends RecyclerView.Adapter { - private static final String TAG = "Forecast_Adapter"; private int[] dataSetTypes; private List courseDayList; @@ -46,7 +41,7 @@ public class CityWeatherAdapter extends RecyclerView.Adapter hourlyForecasts = database.getForecastsByCityId(currentWeatherDataList.getCity_id()); - List weekforecasts = database.getWeekForecastsByCityId(currentWeatherDataList.getCity_id()); + List hourlyForecasts = database.getForecastsByCityId(generalDataList.getCity_id()); + List weekforecasts = database.getWeekForecastsByCityId(generalDataList.getCity_id()); updateForecastData(hourlyForecasts); updateWeekForecastData(weekforecasts); @@ -90,21 +85,21 @@ public class CityWeatherAdapter extends RecyclerView.Adapter weekforecasts = database.getWeekForecastsByCityId(currentWeatherDataList.getCity_id()); + List weekforecasts = database.getWeekForecastsByCityId(generalDataList.getCity_id()); long time = weekforecasts.get(position).getForecastTime(); //time of clicked week item time=time-6*3600000; //week item normally midday -> subtract 6h to get morning time @@ -343,7 +329,7 @@ public class CityWeatherAdapter extends RecyclerView.Adapter weekforecasts = database.getWeekForecastsByCityId(currentWeatherDataList.getCity_id()); + List weekforecasts = database.getWeekForecastsByCityId(generalDataList.getCity_id()); if (weekforecasts.isEmpty()) { return; @@ -355,12 +341,12 @@ public class CityWeatherAdapter extends RecyclerView.Adapter8) dayString=dayString.substring(0,1); //use first character only if more than 8 days to avoid overlapping text @@ -369,18 +355,12 @@ public class CityWeatherAdapter extends RecyclerView.Adapterpmax) pmax=precip; } - int step; - - ArrayList temperature = new ArrayList<>(); - ArrayList precipitation = new ArrayList<>(); precipitation.add(precipitationDataset); precipitationDataset.setColor(ContextCompat.getColor(context,R.color.yellow)); precipitationDataset.setAlpha(0.8f); // make precipitation bars transparent - - step = (int) Math.ceil((Math.max(1,pmax))/4); holder.barChartView.addData(precipitation); holder.barChartView.setBarSpacing(10); holder.barChartView.setXAxis(false); @@ -398,10 +378,6 @@ public class CityWeatherAdapter extends RecyclerView.Adapter0){ //northern hemisphere isDay= forecastTime.get(Calendar.DAY_OF_YEAR) >= 80 && forecastTime.get(Calendar.DAY_OF_YEAR) <= 265; //from March 21 to September 22 (incl) }else{ //southern hemisphere @@ -79,14 +79,14 @@ public class CourseOfDayAdapter extends RecyclerView.Adapter 0) { //northern hemisphere isDay = forecastTime.get(Calendar.DAY_OF_YEAR) >= 80 && forecastTime.get(Calendar.DAY_OF_YEAR) <= 265; //from March 21 to September 22 (incl) } else { //southern hemisphere diff --git a/app/src/main/java/org/woheller69/weather/ui/UiResourceProvider.java b/app/src/main/java/org/woheller69/weather/ui/UiResourceProvider.java index 5c2e1b0..f5e8ae7 100644 --- a/app/src/main/java/org/woheller69/weather/ui/UiResourceProvider.java +++ b/app/src/main/java/org/woheller69/weather/ui/UiResourceProvider.java @@ -158,147 +158,4 @@ public class UiResourceProvider { } } - /** - * @param categoryNumber The category number. See IApiToDatabaseConversion#WeatherCategories - * for details. - * @param isDay True if TimeStamp between sunrise and sunset - * @return Returns the image resource that belongs to the given category number. - */ - public static int getImageResourceForWeatherCategory(int categoryNumber, boolean isDay) { - if (categoryNumber == WeatherCategories.CLEAR_SKY.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_00d; - } else { - return R.drawable.wmo_image_00n; - } - } else if (categoryNumber == WeatherCategories.FEW_CLOUDS.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_01d; - } else { - return R.drawable.wmo_image_01n; - } - } else if (categoryNumber == WeatherCategories.SCATTERED_CLOUDS.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_02d; - } else { - return R.drawable.wmo_image_02n; - } - } else if (categoryNumber == WeatherCategories.OVERCAST_CLOUDS.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_03d; - } else { - return R.drawable.wmo_image_03n; - } - } else if (categoryNumber == WeatherCategories.MIST.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_45d; - } else { - return R.drawable.wmo_image_45n; - } - } else if (categoryNumber == WeatherCategories.DRIZZLE_RAIN.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_53d; - } else { - return R.drawable.wmo_image_53n; - } - } else if (categoryNumber == WeatherCategories.FREEZING_DRIZZLE_RAIN.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_57d; - } else { - return R.drawable.wmo_image_57n; - } - } else if (categoryNumber == WeatherCategories.LIGHT_RAIN.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_61d; - } else { - return R.drawable.wmo_image_61n; - } - } else if (categoryNumber == WeatherCategories.MODERATE_RAIN.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_63d; - } else { - return R.drawable.wmo_image_63n; - } - } else if (categoryNumber == WeatherCategories.HEAVY_RAIN.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_65d; - } else { - return R.drawable.wmo_image_65n; - } - } else if (categoryNumber == WeatherCategories.LIGHT_SHOWER_RAIN.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_80d; - } else { - return R.drawable.wmo_image_80n; - } - } else if (categoryNumber == WeatherCategories.SHOWER_RAIN.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_81d; - } else { - return R.drawable.wmo_image_81n; - } - } else if (categoryNumber == WeatherCategories.LIGHT_SNOW.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_71d; - } else { - return R.drawable.wmo_image_71n; - } - } else if (categoryNumber == WeatherCategories.MODERATE_SNOW.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_73d; - } else { - return R.drawable.wmo_image_73n; - } - } else if (categoryNumber == WeatherCategories.HEAVY_SNOW.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_75d; - } else { - return R.drawable.wmo_image_75n; - } - } else if (categoryNumber == WeatherCategories.LIGHT_FREEZING_RAIN.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_66d; - } else { - return R.drawable.wmo_image_66n; - } - } else if (categoryNumber == WeatherCategories.FREEZING_RAIN.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_67d; - } else { - return R.drawable.wmo_image_67n; - } - } else if (categoryNumber == WeatherCategories.LIGHT_SHOWER_SNOW.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_85d; - } else { - return R.drawable.wmo_image_85n; - } - } else if (categoryNumber == WeatherCategories.SHOWER_SNOW.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_86d; - } else { - return R.drawable.wmo_image_86n; - } - } else if (categoryNumber == WeatherCategories.SHOWER_RAIN_SNOW.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_84d; - } else { - return R.drawable.wmo_image_84n; - } - } else if (categoryNumber == WeatherCategories.THUNDERSTORM.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_95d; - } else { - return R.drawable.wmo_image_95n; - } - } else if (categoryNumber == WeatherCategories.THUNDERSTORM_HAIL.getNumVal()) { - if (isDay) { - return R.drawable.wmo_image_96d; - } else { - return R.drawable.wmo_image_96n; - } - } else { //this should not occur - return R.drawable.wmo_image_error; - } - } } diff --git a/app/src/main/java/org/woheller69/weather/ui/WeatherCityFragment.java b/app/src/main/java/org/woheller69/weather/ui/WeatherCityFragment.java index 2253ec3..ce21919 100644 --- a/app/src/main/java/org/woheller69/weather/ui/WeatherCityFragment.java +++ b/app/src/main/java/org/woheller69/weather/ui/WeatherCityFragment.java @@ -2,9 +2,7 @@ package org.woheller69.weather.ui; import static org.woheller69.weather.ui.RecycleList.CityWeatherAdapter.CHART; import static org.woheller69.weather.ui.RecycleList.CityWeatherAdapter.DAY; -import static org.woheller69.weather.ui.RecycleList.CityWeatherAdapter.DETAILS; import static org.woheller69.weather.ui.RecycleList.CityWeatherAdapter.EMPTY; -import static org.woheller69.weather.ui.RecycleList.CityWeatherAdapter.OVERVIEW; import static org.woheller69.weather.ui.RecycleList.CityWeatherAdapter.WEEK; import android.annotation.SuppressLint; @@ -16,7 +14,6 @@ import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import androidx.recyclerview.widget.StaggeredGridLayoutManager; import android.view.LayoutInflater; @@ -25,7 +22,7 @@ import android.view.ViewGroup; import org.woheller69.weather.R; import org.woheller69.weather.activities.ForecastCityActivity; -import org.woheller69.weather.database.CurrentWeatherData; +import org.woheller69.weather.database.GeneralData; import org.woheller69.weather.database.HourlyForecast; import org.woheller69.weather.database.SQLiteHelper; import org.woheller69.weather.database.WeekForecast; @@ -38,7 +35,7 @@ import org.woheller69.weather.ui.viewPager.WeatherPagerAdapter; import java.util.List; public class WeatherCityFragment extends Fragment implements IUpdateableCityUI { - private static final int MINGRIDWIDTH = 500; + private int mCityId = -1; private int[] mDataSetTypes = new int[]{}; private static int[] mFull = {DAY, WEEK, CHART}; //TODO Make dynamic from Settings @@ -65,10 +62,10 @@ public class WeatherCityFragment extends Fragment implements IUpdateableCityUI { } public void loadData() { - CurrentWeatherData currentWeatherData = SQLiteHelper.getInstance(getContext()).getCurrentWeatherByCityId(mCityId); - if (currentWeatherData.getTimestamp()==0) mDataSetTypes=mEmpty; //show empty view if no data available yet + GeneralData generalData = SQLiteHelper.getInstance(getContext()).getGeneralDataByCityId(mCityId); + if (generalData.getTimestamp()==0) mDataSetTypes=mEmpty; //show empty view if no data available yet else mDataSetTypes=mFull; - mAdapter = new CityWeatherAdapter(currentWeatherData, mDataSetTypes, getContext()); + mAdapter = new CityWeatherAdapter(generalData, mDataSetTypes, getContext()); setAdapter(mAdapter); } @@ -123,7 +120,7 @@ public class WeatherCityFragment extends Fragment implements IUpdateableCityUI { } @Override - public void processNewCurrentWeatherData(CurrentWeatherData data) { + public void processNewGeneralData(GeneralData data) { if (data != null && data.getCity_id() == mCityId) { mDataSetTypes= mFull; setAdapter(new CityWeatherAdapter(data, mDataSetTypes, getContext())); diff --git a/app/src/main/java/org/woheller69/weather/ui/updater/IUpdateableCityUI.java b/app/src/main/java/org/woheller69/weather/ui/updater/IUpdateableCityUI.java index 6e81d59..305f095 100644 --- a/app/src/main/java/org/woheller69/weather/ui/updater/IUpdateableCityUI.java +++ b/app/src/main/java/org/woheller69/weather/ui/updater/IUpdateableCityUI.java @@ -1,6 +1,6 @@ package org.woheller69.weather.ui.updater; -import org.woheller69.weather.database.CurrentWeatherData; +import org.woheller69.weather.database.GeneralData; import org.woheller69.weather.database.HourlyForecast; import org.woheller69.weather.database.WeekForecast; @@ -10,7 +10,7 @@ import java.util.List; * Created by chris on 24.01.2017. */ public interface IUpdateableCityUI { - void processNewCurrentWeatherData(CurrentWeatherData data); + void processNewGeneralData(GeneralData data); void processNewForecasts(List hourlyForecasts); diff --git a/app/src/main/java/org/woheller69/weather/ui/updater/ViewUpdater.java b/app/src/main/java/org/woheller69/weather/ui/updater/ViewUpdater.java index 0c37109..8db5c96 100644 --- a/app/src/main/java/org/woheller69/weather/ui/updater/ViewUpdater.java +++ b/app/src/main/java/org/woheller69/weather/ui/updater/ViewUpdater.java @@ -1,6 +1,6 @@ package org.woheller69.weather.ui.updater; -import org.woheller69.weather.database.CurrentWeatherData; +import org.woheller69.weather.database.GeneralData; import org.woheller69.weather.database.HourlyForecast; import org.woheller69.weather.database.WeekForecast; @@ -24,10 +24,10 @@ public class ViewUpdater { subscribers.remove(sub); } - public static void updateCurrentWeatherData(CurrentWeatherData data) { + public static void updateGeneralDataData(GeneralData data) { ArrayList subcopy = new ArrayList<>(subscribers); //copy list needed as bugfix for concurrent modification exception for (IUpdateableCityUI sub : subcopy) { - sub.processNewCurrentWeatherData(data); + sub.processNewGeneralData(data); } } diff --git a/app/src/main/java/org/woheller69/weather/ui/viewPager/WeatherPagerAdapter.java b/app/src/main/java/org/woheller69/weather/ui/viewPager/WeatherPagerAdapter.java index 25d1a55..1d31b2a 100644 --- a/app/src/main/java/org/woheller69/weather/ui/viewPager/WeatherPagerAdapter.java +++ b/app/src/main/java/org/woheller69/weather/ui/viewPager/WeatherPagerAdapter.java @@ -9,7 +9,7 @@ import androidx.lifecycle.Lifecycle; import androidx.viewpager2.adapter.FragmentStateAdapter; import org.woheller69.weather.database.CityToWatch; -import org.woheller69.weather.database.CurrentWeatherData; +import org.woheller69.weather.database.GeneralData; import org.woheller69.weather.database.HourlyForecast; import org.woheller69.weather.database.SQLiteHelper; import org.woheller69.weather.database.WeekForecast; @@ -77,7 +77,7 @@ public class WeatherPagerAdapter extends FragmentStateAdapter implements IUpdate @Override - public void processNewCurrentWeatherData(CurrentWeatherData data) { + public void processNewGeneralData(GeneralData data) { } diff --git a/app/src/main/java/org/woheller69/weather/weather_api/IDataExtractor.java b/app/src/main/java/org/woheller69/weather/weather_api/IDataExtractor.java index 12b2688..a85f9d8 100644 --- a/app/src/main/java/org/woheller69/weather/weather_api/IDataExtractor.java +++ b/app/src/main/java/org/woheller69/weather/weather_api/IDataExtractor.java @@ -1,23 +1,16 @@ package org.woheller69.weather.weather_api; -import org.woheller69.weather.database.CurrentWeatherData; +import org.woheller69.weather.database.GeneralData; import org.woheller69.weather.database.HourlyForecast; import org.woheller69.weather.database.WeekForecast; import java.util.List; /** - * This interface defines the frame of the functionality to extractCurrentWeatherData weather information from which + * This interface defines the frame of the functionality to extractGeneralData weather information from which * is returned by some API. */ public interface IDataExtractor { - /** - * @param data The data that contains the information to instantiate a CurrentWeatherData - * object. In the easiest case this is the (HTTP) response of the One Call API. - * @return Returns the extracted information as a CurrentWeatherData instance. - */ - CurrentWeatherData extractCurrentWeather(String data); - /** * @param data The data that contains the information to instantiate a Forecast object. * @return Returns the extracted weather forecast information. In case some error occurs, null @@ -33,10 +26,4 @@ public interface IDataExtractor { List extractHourlyForecast(String data, int cityID); - /** - * @param data0, data1, data2, data3, data4 contain the information to retrieve the rain for a minute within the next 60min. - * @return Returns a string with a rain drop in case of rain or a - in case of no rain - */ - String extractRain60min(String data0,String data1, String data2, String data3, String data4); - } diff --git a/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/OMDataExtractor.java b/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/OMDataExtractor.java index f62d61b..f5d4dc6 100644 --- a/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/OMDataExtractor.java +++ b/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/OMDataExtractor.java @@ -10,7 +10,7 @@ import org.json.JSONException; import org.json.JSONObject; import org.woheller69.weather.SolarPowerPlant; import org.woheller69.weather.database.CityToWatch; -import org.woheller69.weather.database.CurrentWeatherData; +import org.woheller69.weather.database.GeneralData; import org.woheller69.weather.database.HourlyForecast; import org.woheller69.weather.database.SQLiteHelper; import org.woheller69.weather.database.WeekForecast; @@ -30,50 +30,17 @@ public class OMDataExtractor implements IDataExtractor { this.context = context; } - @Override - public CurrentWeatherData extractCurrentWeather(String data) { - try { - JSONObject jsonData = new JSONObject(data); - CurrentWeatherData weatherData = new CurrentWeatherData(); - weatherData.setTimestamp(System.currentTimeMillis() / 1000); - IApiToDatabaseConversion conversion = new OMToDatabaseConversion(); - if (jsonData.has("weathercode")) weatherData.setWeatherID(conversion.convertWeatherCategory(jsonData.getString("weathercode"))); - if (jsonData.has("temperature")) weatherData.setTemperatureCurrent((float) jsonData.getDouble("temperature")); - if (jsonData.has("windspeed")) weatherData.setWindSpeed((float) jsonData.getDouble("windspeed")); - if (jsonData.has("winddirection")) weatherData.setWindDirection((float) jsonData.getDouble("winddirection")); - weatherData.setTimeSunrise(0L); - weatherData.setTimeSunset(0L); - weatherData.setHumidity(0); - weatherData.setPressure(0); - weatherData.setCloudiness(0); - - return weatherData; - } catch (JSONException e) { - e.printStackTrace(); - } - return null; - } - @Override public List extractWeekForecast(String data) { try { - SharedPreferences prefManager = PreferenceManager.getDefaultSharedPreferences(context); List weekforecasts = new ArrayList<>(); JSONObject jsonData = new JSONObject(data); JSONArray timeArray = jsonData.getJSONArray("time"); JSONArray weathercodeArray = jsonData.has("weathercode") ? jsonData.getJSONArray("weathercode") : null; - JSONArray tempMaxArray = jsonData.has("temperature_2m_max") ? jsonData.getJSONArray("temperature_2m_max") : null; - JSONArray tempMinArray = jsonData.has("temperature_2m_min") ? jsonData.getJSONArray("temperature_2m_min") : null; JSONArray sunriseArray = jsonData.has("sunrise") ? jsonData.getJSONArray("sunrise") : null; JSONArray sunsetArray = jsonData.has("sunset") ? jsonData.getJSONArray("sunset") : null; - JSONArray uvIndexArray = jsonData.has("uv_index_max") ? jsonData.getJSONArray("uv_index_max") : null; - JSONArray precipitationArray = jsonData.has("precipitation_sum") ? jsonData.getJSONArray("precipitation_sum") : null; - JSONArray windSpeedArray = jsonData.has("windspeed_10m_max") ? jsonData.getJSONArray("windspeed_10m_max") : null; - JSONArray snowfallArray = jsonData.has("snowfall_sum") ? jsonData.getJSONArray("snowfall_sum") : null; - JSONArray showersArray = jsonData.has("showers_sum") ? jsonData.getJSONArray("showers_sum") : null; - JSONArray rainArray = jsonData.has("rain_sum") ? jsonData.getJSONArray("rain_sum") : null; IApiToDatabaseConversion conversion = new OMToDatabaseConversion(); for (int i = 0; i < timeArray.length(); i++) { @@ -81,14 +48,8 @@ public class OMDataExtractor implements IDataExtractor { weekForecast.setTimestamp(System.currentTimeMillis() / 1000); if (!timeArray.isNull(i)) weekForecast.setForecastTime((timeArray.getLong(i)+12*3600)*1000L); //shift to midday if (!weathercodeArray.isNull(i)) weekForecast.setWeatherID(conversion.convertWeatherCategory(weathercodeArray.getString(i))); - if (!tempMaxArray.isNull(i)) weekForecast.setMaxTemperature((float) tempMaxArray.getDouble(i)); - if (!tempMinArray.isNull(i)) weekForecast.setMinTemperature((float) tempMinArray.getDouble(i)); if (!sunriseArray.isNull(i)) weekForecast.setTimeSunrise(sunriseArray.getLong(i)); if (!sunsetArray.isNull(i)) weekForecast.setTimeSunset(sunsetArray.getLong(i)); - if (!uvIndexArray.isNull(i)) { - weekForecast.setUv_index((float) uvIndexArray.getDouble(i)); - } else weekForecast.setUv_index(-1); - if (!windSpeedArray.isNull(i)) weekForecast.setWind_speed((float) windSpeedArray.getDouble(i)); weekforecasts.add(weekForecast); } return weekforecasts; @@ -139,47 +100,4 @@ public class OMDataExtractor implements IDataExtractor { } - /** - * @see IDataExtractor#extractRain60min(String, String, String, String, String) - */ - @Override - public String extractRain60min(String data0,String data1, String data2, String data3, String data4) { - try { - - String rain = ""; - JSONObject jsonData0 = new JSONObject(data0); - JSONObject jsonData1 = new JSONObject(data1); - JSONObject jsonData2 = new JSONObject(data2); - JSONObject jsonData3 = new JSONObject(data3); - JSONObject jsonData4 = new JSONObject(data4); - double rain5min=jsonData0.getDouble("precipitation")+jsonData1.getDouble("precipitation")+jsonData2.getDouble("precipitation")+jsonData3.getDouble("precipitation")+jsonData4.getDouble("precipitation"); - if (rain5min==0){ - rain ="\u25a1"; - } else if (rain5min<2.5){ // very light rain equals <0.5mm/h (2.5 = 5 x 0.5) - rain ="\u25a4"; - }else if (rain5min<12.5){ //light rain equals <2.5mm/h (12.5 = 5 x 2.5) - rain ="\u25a6"; - } else{ - rain ="\u25a0"; - } - - return rain; - } catch (JSONException e) { - e.printStackTrace(); - } - return null; - } - - - /** - * @param data The data that contains the information to retrieve the ID of the city. - * If data for a single city were requested, the response string can be - * passed as an argument. - * If data for multiple cities were requested, make sure to pass only one item - * of the response list at a time! - * @return Returns the ID of the city or Integer#MIN_VALUE in case the data is not well-formed - * and the information could not be extracted. - */ - - } diff --git a/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/OMHttpRequest.java b/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/OMHttpRequest.java index 27d4f53..64db92e 100644 --- a/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/OMHttpRequest.java +++ b/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/OMHttpRequest.java @@ -24,7 +24,7 @@ public class OMHttpRequest { SharedPreferences sharedPreferences=PreferenceManager.getDefaultSharedPreferences(context); return String.format( - "%sforecast?latitude=%s&longitude=%s&forecast_days=%s&hourly=diffuse_radiation,direct_normal_irradiance,weathercode&daily=weathercode,temperature_2m_max,temperature_2m_min,sunrise,sunset,uv_index_max,precipitation_sum,windspeed_10m_max¤t_weather=true&windspeed_unit=ms&timeformat=unixtime&timezone=auto", + "%sforecast?latitude=%s&longitude=%s&forecast_days=%s&hourly=diffuse_radiation,direct_normal_irradiance,weathercode&daily=weathercode,sunrise,sunset,&timeformat=unixtime&timezone=auto", BuildConfig.BASE_URL, lat, lon, diff --git a/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/ProcessOMweatherAPIRequest.java b/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/ProcessOMweatherAPIRequest.java index c76fac8..1c8f93e 100644 --- a/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/ProcessOMweatherAPIRequest.java +++ b/app/src/main/java/org/woheller69/weather/weather_api/open_meteo/ProcessOMweatherAPIRequest.java @@ -1,11 +1,7 @@ package org.woheller69.weather.weather_api.open_meteo; -import android.appwidget.AppWidgetManager; -import android.content.ComponentName; import android.content.Context; -import android.content.SharedPreferences; import android.os.Handler; -import android.widget.RemoteViews; import android.widget.Toast; import com.android.volley.VolleyError; @@ -14,8 +10,7 @@ import org.json.JSONException; import org.json.JSONObject; import org.woheller69.weather.R; import org.woheller69.weather.activities.NavigationActivity; -import org.woheller69.weather.database.CityToWatch; -import org.woheller69.weather.database.CurrentWeatherData; +import org.woheller69.weather.database.GeneralData; import org.woheller69.weather.database.HourlyForecast; import org.woheller69.weather.database.WeekForecast; import org.woheller69.weather.database.SQLiteHelper; @@ -23,7 +18,6 @@ import org.woheller69.weather.ui.updater.ViewUpdater; import org.woheller69.weather.weather_api.IDataExtractor; import org.woheller69.weather.weather_api.IProcessHttpRequest; -import androidx.preference.PreferenceManager; import org.woheller69.weather.weather_api.IApiToDatabaseConversion.WeatherCategories; import java.util.ArrayList; @@ -88,50 +82,41 @@ public class ProcessOMweatherAPIRequest implements IProcessHttpRequest { } //Extract current weather - String rain60min=context.getResources().getString(R.string.error_no_rain60min_data); - CurrentWeatherData weatherData = extractor.extractCurrentWeather(json.getString("current_weather")); + GeneralData generalData = new GeneralData(); + generalData.setTimestamp(System.currentTimeMillis() / 1000); + generalData.setCity_id(cityId); + generalData.setTimeSunrise(weekforecasts.get(0).getTimeSunrise()); + generalData.setTimeSunset(weekforecasts.get(0).getTimeSunset()); + generalData.setTimeZoneSeconds(json.getInt("utc_offset_seconds")); + GeneralData current = dbHelper.getGeneralDataByCityId(cityId); + if (current != null && current.getCity_id() == cityId) { + dbHelper.updateGeneralData(generalData); + } else { + dbHelper.addGeneralData(generalData); + } - if (weatherData == null) { - final String ERROR_MSG = context.getResources().getString(R.string.error_convert_to_json); - if (NavigationActivity.isVisible) - Toast.makeText(context, ERROR_MSG, Toast.LENGTH_LONG).show(); - } else { - weatherData.setCity_id(cityId); - weatherData.setRain60min(rain60min); - weatherData.setTimeSunrise(weekforecasts.get(0).getTimeSunrise()); - weatherData.setTimeSunset(weekforecasts.get(0).getTimeSunset()); - weatherData.setTimeZoneSeconds(json.getInt("utc_offset_seconds")); - CurrentWeatherData current = dbHelper.getCurrentWeatherByCityId(cityId); - if (current != null && current.getCity_id() == cityId) { - dbHelper.updateCurrentWeather(weatherData); - } else { - dbHelper.addCurrentWeather(weatherData); - } - } - - - //Extract hourly weather - dbHelper.deleteForecastsByCityId(cityId); - List hourlyforecasts = new ArrayList<>(); - hourlyforecasts = extractor.extractHourlyForecast(json.getString("hourly"), cityId); - - if (hourlyforecasts!=null && !hourlyforecasts.isEmpty()){ - for (HourlyForecast hourlyForecast: hourlyforecasts){ - hourlyForecast.setCity_id(cityId); - } - } else { - final String ERROR_MSG = context.getResources().getString(R.string.error_convert_to_json); - if (NavigationActivity.isVisible) - Toast.makeText(context, ERROR_MSG, Toast.LENGTH_LONG).show(); - return; + //Extract hourly weather + dbHelper.deleteForecastsByCityId(cityId); + List hourlyforecasts = new ArrayList<>(); + hourlyforecasts = extractor.extractHourlyForecast(json.getString("hourly"), cityId); + + if (hourlyforecasts!=null && !hourlyforecasts.isEmpty()){ + for (HourlyForecast hourlyForecast: hourlyforecasts){ + hourlyForecast.setCity_id(cityId); } + } else { + final String ERROR_MSG = context.getResources().getString(R.string.error_convert_to_json); + if (NavigationActivity.isVisible) + Toast.makeText(context, ERROR_MSG, Toast.LENGTH_LONG).show(); + return; + } dbHelper.addForecasts(hourlyforecasts); weekforecasts = reanalyzeWeekIDs(weekforecasts, hourlyforecasts); dbHelper.addWeekForecasts(weekforecasts); - ViewUpdater.updateCurrentWeatherData(weatherData); + ViewUpdater.updateGeneralDataData(generalData); ViewUpdater.updateWeekForecasts(weekforecasts); ViewUpdater.updateForecasts(hourlyforecasts); @@ -192,7 +177,7 @@ public class ProcessOMweatherAPIRequest implements IProcessHttpRequest { totalEnergy+=hourlyForecast.getPower(); } } - weekForecast.setPrecipitation(totalEnergy/1000); + weekForecast.setEnergyDay(totalEnergy/1000); } return weekforecasts; diff --git a/app/src/main/res/drawable/ic_wind_empty.xml b/app/src/main/res/drawable/ic_wind_empty.xml deleted file mode 100644 index 6c23f97..0000000 --- a/app/src/main/res/drawable/ic_wind_empty.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable/ic_wind_lightred.xml b/app/src/main/res/drawable/ic_wind_lightred.xml deleted file mode 100644 index 019bff7..0000000 --- a/app/src/main/res/drawable/ic_wind_lightred.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable/ic_wind_orange.xml b/app/src/main/res/drawable/ic_wind_orange.xml deleted file mode 100644 index 0bcbdf7..0000000 --- a/app/src/main/res/drawable/ic_wind_orange.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable/ic_wind_red.xml b/app/src/main/res/drawable/ic_wind_red.xml deleted file mode 100644 index ee9b5a9..0000000 --- a/app/src/main/res/drawable/ic_wind_red.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable/ic_wind_yellow.xml b/app/src/main/res/drawable/ic_wind_yellow.xml deleted file mode 100644 index f0a91d8..0000000 --- a/app/src/main/res/drawable/ic_wind_yellow.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable/wmo_image_00d.png b/app/src/main/res/drawable/wmo_image_00d.png deleted file mode 100644 index a2bfaa1..0000000 Binary files a/app/src/main/res/drawable/wmo_image_00d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_00n.png b/app/src/main/res/drawable/wmo_image_00n.png deleted file mode 100644 index b9567a0..0000000 Binary files a/app/src/main/res/drawable/wmo_image_00n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_01d.png b/app/src/main/res/drawable/wmo_image_01d.png deleted file mode 100644 index 7d2c09d..0000000 Binary files a/app/src/main/res/drawable/wmo_image_01d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_01n.png b/app/src/main/res/drawable/wmo_image_01n.png deleted file mode 100644 index 352e122..0000000 Binary files a/app/src/main/res/drawable/wmo_image_01n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_02d.png b/app/src/main/res/drawable/wmo_image_02d.png deleted file mode 100644 index 0833a33..0000000 Binary files a/app/src/main/res/drawable/wmo_image_02d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_02n.png b/app/src/main/res/drawable/wmo_image_02n.png deleted file mode 100644 index 9f659a6..0000000 Binary files a/app/src/main/res/drawable/wmo_image_02n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_03d.png b/app/src/main/res/drawable/wmo_image_03d.png deleted file mode 100644 index 34b6c3a..0000000 Binary files a/app/src/main/res/drawable/wmo_image_03d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_03n.png b/app/src/main/res/drawable/wmo_image_03n.png deleted file mode 100644 index 8647233..0000000 Binary files a/app/src/main/res/drawable/wmo_image_03n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_45d.png b/app/src/main/res/drawable/wmo_image_45d.png deleted file mode 100644 index 34f3f5c..0000000 Binary files a/app/src/main/res/drawable/wmo_image_45d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_45n.png b/app/src/main/res/drawable/wmo_image_45n.png deleted file mode 100644 index bb20c76..0000000 Binary files a/app/src/main/res/drawable/wmo_image_45n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_53d.png b/app/src/main/res/drawable/wmo_image_53d.png deleted file mode 100644 index 4886e02..0000000 Binary files a/app/src/main/res/drawable/wmo_image_53d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_53n.png b/app/src/main/res/drawable/wmo_image_53n.png deleted file mode 100644 index 01810c2..0000000 Binary files a/app/src/main/res/drawable/wmo_image_53n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_57d.png b/app/src/main/res/drawable/wmo_image_57d.png deleted file mode 100644 index b92a5b6..0000000 Binary files a/app/src/main/res/drawable/wmo_image_57d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_57n.png b/app/src/main/res/drawable/wmo_image_57n.png deleted file mode 100644 index d25367f..0000000 Binary files a/app/src/main/res/drawable/wmo_image_57n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_61d.png b/app/src/main/res/drawable/wmo_image_61d.png deleted file mode 100644 index 7e2dbe8..0000000 Binary files a/app/src/main/res/drawable/wmo_image_61d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_61n.png b/app/src/main/res/drawable/wmo_image_61n.png deleted file mode 100644 index 16c1aee..0000000 Binary files a/app/src/main/res/drawable/wmo_image_61n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_63d.png b/app/src/main/res/drawable/wmo_image_63d.png deleted file mode 100644 index d6b0352..0000000 Binary files a/app/src/main/res/drawable/wmo_image_63d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_63n.png b/app/src/main/res/drawable/wmo_image_63n.png deleted file mode 100644 index f5f8916..0000000 Binary files a/app/src/main/res/drawable/wmo_image_63n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_65d.png b/app/src/main/res/drawable/wmo_image_65d.png deleted file mode 100644 index bcab368..0000000 Binary files a/app/src/main/res/drawable/wmo_image_65d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_65n.png b/app/src/main/res/drawable/wmo_image_65n.png deleted file mode 100644 index e3ccdf6..0000000 Binary files a/app/src/main/res/drawable/wmo_image_65n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_66d.png b/app/src/main/res/drawable/wmo_image_66d.png deleted file mode 100644 index 33a9f24..0000000 Binary files a/app/src/main/res/drawable/wmo_image_66d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_66n.png b/app/src/main/res/drawable/wmo_image_66n.png deleted file mode 100644 index 91ff639..0000000 Binary files a/app/src/main/res/drawable/wmo_image_66n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_67d.png b/app/src/main/res/drawable/wmo_image_67d.png deleted file mode 100644 index e6be170..0000000 Binary files a/app/src/main/res/drawable/wmo_image_67d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_67n.png b/app/src/main/res/drawable/wmo_image_67n.png deleted file mode 100644 index 7e5513c..0000000 Binary files a/app/src/main/res/drawable/wmo_image_67n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_71d.png b/app/src/main/res/drawable/wmo_image_71d.png deleted file mode 100644 index 133077c..0000000 Binary files a/app/src/main/res/drawable/wmo_image_71d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_71n.png b/app/src/main/res/drawable/wmo_image_71n.png deleted file mode 100644 index 17be7c9..0000000 Binary files a/app/src/main/res/drawable/wmo_image_71n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_73d.png b/app/src/main/res/drawable/wmo_image_73d.png deleted file mode 100644 index 8fbae62..0000000 Binary files a/app/src/main/res/drawable/wmo_image_73d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_73n.png b/app/src/main/res/drawable/wmo_image_73n.png deleted file mode 100644 index 1a0e387..0000000 Binary files a/app/src/main/res/drawable/wmo_image_73n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_75d.png b/app/src/main/res/drawable/wmo_image_75d.png deleted file mode 100644 index 378f1b8..0000000 Binary files a/app/src/main/res/drawable/wmo_image_75d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_75n.png b/app/src/main/res/drawable/wmo_image_75n.png deleted file mode 100644 index 15f12da..0000000 Binary files a/app/src/main/res/drawable/wmo_image_75n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_80d.png b/app/src/main/res/drawable/wmo_image_80d.png deleted file mode 100644 index 456fe65..0000000 Binary files a/app/src/main/res/drawable/wmo_image_80d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_80n.png b/app/src/main/res/drawable/wmo_image_80n.png deleted file mode 100644 index dacf444..0000000 Binary files a/app/src/main/res/drawable/wmo_image_80n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_81d.png b/app/src/main/res/drawable/wmo_image_81d.png deleted file mode 100644 index 9f46a40..0000000 Binary files a/app/src/main/res/drawable/wmo_image_81d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_81n.png b/app/src/main/res/drawable/wmo_image_81n.png deleted file mode 100644 index df0de9f..0000000 Binary files a/app/src/main/res/drawable/wmo_image_81n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_84d.png b/app/src/main/res/drawable/wmo_image_84d.png deleted file mode 100644 index bb2fa17..0000000 Binary files a/app/src/main/res/drawable/wmo_image_84d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_84n.png b/app/src/main/res/drawable/wmo_image_84n.png deleted file mode 100644 index 770c5f5..0000000 Binary files a/app/src/main/res/drawable/wmo_image_84n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_85d.png b/app/src/main/res/drawable/wmo_image_85d.png deleted file mode 100644 index bf09537..0000000 Binary files a/app/src/main/res/drawable/wmo_image_85d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_85n.png b/app/src/main/res/drawable/wmo_image_85n.png deleted file mode 100644 index a465151..0000000 Binary files a/app/src/main/res/drawable/wmo_image_85n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_86d.png b/app/src/main/res/drawable/wmo_image_86d.png deleted file mode 100644 index fbd1cc1..0000000 Binary files a/app/src/main/res/drawable/wmo_image_86d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_86n.png b/app/src/main/res/drawable/wmo_image_86n.png deleted file mode 100644 index d260e12..0000000 Binary files a/app/src/main/res/drawable/wmo_image_86n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_95d.png b/app/src/main/res/drawable/wmo_image_95d.png deleted file mode 100644 index a508b75..0000000 Binary files a/app/src/main/res/drawable/wmo_image_95d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_95n.png b/app/src/main/res/drawable/wmo_image_95n.png deleted file mode 100644 index 31f2067..0000000 Binary files a/app/src/main/res/drawable/wmo_image_95n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_96d.png b/app/src/main/res/drawable/wmo_image_96d.png deleted file mode 100644 index 5f420eb..0000000 Binary files a/app/src/main/res/drawable/wmo_image_96d.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_96n.png b/app/src/main/res/drawable/wmo_image_96n.png deleted file mode 100644 index d3478e9..0000000 Binary files a/app/src/main/res/drawable/wmo_image_96n.png and /dev/null differ diff --git a/app/src/main/res/drawable/wmo_image_error.png b/app/src/main/res/drawable/wmo_image_error.png deleted file mode 100644 index 15f2acb..0000000 Binary files a/app/src/main/res/drawable/wmo_image_error.png and /dev/null differ diff --git a/app/src/main/res/layout/card_overview.xml b/app/src/main/res/layout/card_overview.xml index f0a44c9..677be24 100644 --- a/app/src/main/res/layout/card_overview.xml +++ b/app/src/main/res/layout/card_overview.xml @@ -5,13 +5,6 @@ android:layout_height="wrap_content" android:layout_margin="@dimen/card_margin"> - -