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"
|
||||
minSdkVersion 26
|
||||
targetSdk 34
|
||||
versionCode 23
|
||||
versionName "2.3"
|
||||
versionCode 24
|
||||
versionName "2.4"
|
||||
|
||||
buildConfigField "String", "BASE_URL", "\"https://api.open-meteo.com/v1/\""
|
||||
buildConfigField "String", "TILES_URL","\"https://tile.openstreetmap.org/\""
|
||||
|
|
|
@ -100,15 +100,23 @@ public class CityWeatherAdapter extends RecyclerView.Adapter<CityWeatherAdapter.
|
|||
courseDayList = new ArrayList<>();
|
||||
|
||||
float energyCumulated=0;
|
||||
boolean isDebugMode = sp.getBoolean("pref_debug", false);
|
||||
int stepCounter = 0; // Counter to track the number of steps taken in the loop
|
||||
|
||||
for (HourlyForecast f : hourlyForecasts) {
|
||||
energyCumulated+=f.getPower();
|
||||
float power = f.getPower();
|
||||
if (stepCounter > 0) energyCumulated += power; //Ignore first value because power values are for preceding hour
|
||||
f.setEnergyCum(energyCumulated);
|
||||
if (sp.getBoolean("pref_debug",false)) {
|
||||
courseDayList.add(f);
|
||||
} else {
|
||||
if (f.getForecastTime() >= System.currentTimeMillis()) {
|
||||
|
||||
// In debug mode show all values, otherwise only future values
|
||||
if (isDebugMode || f.getForecastTime() >= System.currentTimeMillis()) {
|
||||
courseDayList.add(f);
|
||||
}
|
||||
|
||||
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();
|
||||
|
|
|
@ -198,7 +198,7 @@ public class ProcessOMweatherAPIRequest implements IProcessHttpRequest {
|
|||
float totalEnergy = 0;
|
||||
Long timeNoon = weekForecast.getForecastTime();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
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