mirror of
https://github.com/woheller69/solxpect.git
synced 2025-09-22 00:40:46 +02:00
-reset cumulated values at midnight, unless in debug mode
-bugfix for weekforcast because values are for preceding hour fixes #23
This commit is contained in:
parent
71e9cbe08d
commit
2974b4b156
4 changed files with 24 additions and 14 deletions
|
@ -8,8 +8,8 @@ android {
|
||||||
applicationId "org.woheller69.solxpect"
|
applicationId "org.woheller69.solxpect"
|
||||||
minSdkVersion 26
|
minSdkVersion 26
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 23
|
versionCode 24
|
||||||
versionName "2.3"
|
versionName "2.4"
|
||||||
|
|
||||||
buildConfigField "String", "BASE_URL", "\"https://api.open-meteo.com/v1/\""
|
buildConfigField "String", "BASE_URL", "\"https://api.open-meteo.com/v1/\""
|
||||||
buildConfigField "String", "TILES_URL","\"https://tile.openstreetmap.org/\""
|
buildConfigField "String", "TILES_URL","\"https://tile.openstreetmap.org/\""
|
||||||
|
|
|
@ -100,18 +100,26 @@ public class CityWeatherAdapter extends RecyclerView.Adapter<CityWeatherAdapter.
|
||||||
courseDayList = new ArrayList<>();
|
courseDayList = new ArrayList<>();
|
||||||
|
|
||||||
float energyCumulated=0;
|
float energyCumulated=0;
|
||||||
for (HourlyForecast f : hourlyForecasts) {
|
boolean isDebugMode = sp.getBoolean("pref_debug", false);
|
||||||
energyCumulated+=f.getPower();
|
int stepCounter = 0; // Counter to track the number of steps taken in the loop
|
||||||
f.setEnergyCum(energyCumulated);
|
|
||||||
if (sp.getBoolean("pref_debug",false)) {
|
for (HourlyForecast f : hourlyForecasts) {
|
||||||
courseDayList.add(f);
|
float power = f.getPower();
|
||||||
} else {
|
if (stepCounter > 0) energyCumulated += power; //Ignore first value because power values are for preceding hour
|
||||||
if (f.getForecastTime() >= System.currentTimeMillis()) {
|
f.setEnergyCum(energyCumulated);
|
||||||
courseDayList.add(f);
|
|
||||||
}
|
// In debug mode show all values, otherwise only future values
|
||||||
}
|
if (isDebugMode || f.getForecastTime() >= System.currentTimeMillis()) {
|
||||||
|
courseDayList.add(f);
|
||||||
}
|
}
|
||||||
notifyDataSetChanged();
|
|
||||||
|
stepCounter++;
|
||||||
|
// if not in debug mode: Reset energyCumulated after every 24 hours if next step is 01:00 am because values are for previous hour
|
||||||
|
if (!isDebugMode && stepCounter % 24 == 1) {
|
||||||
|
energyCumulated = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
// function for week forecast list
|
// function for week forecast list
|
||||||
|
|
|
@ -198,7 +198,7 @@ public class ProcessOMweatherAPIRequest implements IProcessHttpRequest {
|
||||||
float totalEnergy = 0;
|
float totalEnergy = 0;
|
||||||
Long timeNoon = weekForecast.getForecastTime();
|
Long timeNoon = weekForecast.getForecastTime();
|
||||||
for (HourlyForecast hourlyForecast: hourlyforecasts){
|
for (HourlyForecast hourlyForecast: hourlyforecasts){
|
||||||
if ((hourlyForecast.getForecastTime()>=timeNoon-12*3600*1000L) && (hourlyForecast.getForecastTime()< timeNoon + 12*3600*1000L)){
|
if ((hourlyForecast.getForecastTime()>=timeNoon-11*3600*1000L) && (hourlyForecast.getForecastTime()< timeNoon + 13*3600*1000L)){ //values are for preceding hour!
|
||||||
totalEnergy+=hourlyForecast.getPower();
|
totalEnergy+=hourlyForecast.getPower();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
fastlane/metadata/android/en-US/changelogs/24.txt
Normal file
2
fastlane/metadata/android/en-US/changelogs/24.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Reset cumulated values every 24h
|
||||||
|
Bugfix
|
Loading…
Add table
Add a link
Reference in a new issue