Skip to content

Commit

Permalink
fix bug: show sum also in chart
Browse files Browse the repository at this point in the history
  • Loading branch information
woheller69 committed Apr 19, 2023
1 parent 2ae9a05 commit 7880b66
Showing 1 changed file with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ public void updateWeekForecastData(List<WeekForecast> forecasts) {
SQLiteHelper dbHelper = SQLiteHelper.getInstance(context.getApplicationContext());
int zonemilliseconds = dbHelper.getGeneralDataByCityId(cityId).getTimeZoneSeconds() * 1000;

//temp max 0, temp min 1, humidity 2, pressure 3, precipitation 4, wind 5, wind direction 6, uv_index 7, forecast time 8, weather ID 9, number of FCs for day 10

forecastData = new float[forecasts.size()][11];

for (int i=0;i<forecasts.size();i++){
Expand Down Expand Up @@ -386,28 +384,22 @@ public void onLongItemClick(View view, int position) {
} else if (viewHolder.getItemViewType() == CHART) {
ChartViewHolder holder = (ChartViewHolder) viewHolder;

SQLiteHelper database = SQLiteHelper.getInstance(context.getApplicationContext());
List<WeekForecast> weekforecasts = database.getWeekForecastsByCityId(generalDataList.getCity_id());

if (weekforecasts.isEmpty()) {
return;
}
if(forecastData==null || forecastData.length==0 || forecastData[0]==null) return;

float energyMax=0;

BarSet energyDataset = new BarSet();

Calendar c = Calendar.getInstance();
c.setTimeZone(TimeZone.getTimeZone("GMT"));
int zonemilliseconds = generalDataList.getTimeZoneSeconds()*1000;

for (int i=0 ; i< weekforecasts.size();i++) {
c.setTimeInMillis(weekforecasts.get(i).getForecastTime()+zonemilliseconds);
for (int i=0 ; i< forecastData.length;i++) {
c.setTimeInMillis((long) forecastData[i][8]);
int day = c.get(Calendar.DAY_OF_WEEK);
float energyDay=weekforecasts.get(i).getEnergyDay();
float energyDay=forecastData[i][4];

String dayString = context.getResources().getString(StringFormatUtils.getDayShort(day));
if (weekforecasts.size()>8) dayString=dayString.substring(0,1); //use first character only if more than 8 days to avoid overlapping text
if (forecastData.length>8) dayString=dayString.substring(0,1); //use first character only if more than 8 days to avoid overlapping text

energyDataset.addBar(dayString, energyDay);
if (energyDay>energyMax) energyMax=energyDay;
Expand Down

0 comments on commit 7880b66

Please sign in to comment.