mirror of
https://github.com/woheller69/solxpect.git
synced 2025-09-22 00:40:46 +02:00
Add produced / remaining today
Remove dependenciesInfo block
This commit is contained in:
parent
972de5739d
commit
8479bcd741
6 changed files with 126 additions and 39 deletions
|
@ -2,6 +2,17 @@ apply plugin: 'com.android.application'
|
|||
|
||||
android {
|
||||
|
||||
lintOptions {
|
||||
disable 'MissingTranslation'
|
||||
}
|
||||
|
||||
dependenciesInfo {
|
||||
// Disable including dependency metadata when building APKs
|
||||
includeInApk = false
|
||||
// Disable including dependency metadata when building Android App Bundles
|
||||
includeInBundle = false
|
||||
}
|
||||
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
|
|
|
@ -38,6 +38,8 @@ public class CityWeatherAdapter extends RecyclerView.Adapter<CityWeatherAdapter.
|
|||
private int[] dataSetTypes;
|
||||
private List<HourlyForecast> courseDayList;
|
||||
private List<WeekForecast> weekForecastList;
|
||||
private float producedToday;
|
||||
private float remainingToday;
|
||||
|
||||
private Context context;
|
||||
private ViewGroup mParent;
|
||||
|
@ -118,6 +120,13 @@ public class CityWeatherAdapter extends RecyclerView.Adapter<CityWeatherAdapter.
|
|||
courseDayList.add(f);
|
||||
}
|
||||
|
||||
if (f.getForecastTime() < System.currentTimeMillis() && stepCounter <= 24) producedToday = f.getEnergyCum();
|
||||
if (f.getForecastTime() > System.currentTimeMillis() && f.getForecastTime() < System.currentTimeMillis() + 3600000 && stepCounter <= 24) {
|
||||
long millisRemainingThisHour = f.getForecastTime() - System.currentTimeMillis();
|
||||
long millisSoFarThisHour = 3600000 - millisRemainingThisHour;
|
||||
producedToday = producedToday + (f.getEnergyCum()-producedToday) * millisSoFarThisHour/3600000;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -136,7 +145,7 @@ public class CityWeatherAdapter extends RecyclerView.Adapter<CityWeatherAdapter.
|
|||
}
|
||||
weekForecast.setEnergyDay(totalEnergy/1000);
|
||||
}
|
||||
|
||||
remainingToday = weekForecasts.get(0).getEnergyDay()*1000 - producedToday;
|
||||
weekForecastList = weekForecasts;
|
||||
|
||||
notifyDataSetChanged();
|
||||
|
@ -150,15 +159,17 @@ public class CityWeatherAdapter extends RecyclerView.Adapter<CityWeatherAdapter.
|
|||
}
|
||||
|
||||
public class OverViewHolder extends ViewHolder {
|
||||
TextView temperature;
|
||||
TextView produced;
|
||||
TextView remaining;
|
||||
TextView updatetime;
|
||||
TextView sun;
|
||||
|
||||
OverViewHolder(View v) {
|
||||
super(v);
|
||||
this.temperature = v.findViewById(R.id.card_overview_temperature);
|
||||
this.sun=v.findViewById(R.id.card_overview_sunrise_sunset);
|
||||
this.updatetime=v.findViewById(R.id.card_overview_update_time);
|
||||
this.produced=v.findViewById(R.id.card_overview_produced_today);
|
||||
this.remaining=v.findViewById(R.id.card_overview_remaining_today);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,6 +287,8 @@ public class CityWeatherAdapter extends RecyclerView.Adapter<CityWeatherAdapter.
|
|||
|
||||
holder.updatetime.setText("("+StringFormatUtils.formatTimeWithoutZone(context, updateTime)+")");
|
||||
|
||||
holder.produced.setText(StringFormatUtils.formatEnergyCum(context, producedToday));
|
||||
holder.remaining.setText(StringFormatUtils.formatEnergyCum(context, remainingToday));
|
||||
|
||||
} else if (viewHolder.getItemViewType() == WEEK) {
|
||||
|
||||
|
|
|
@ -3,6 +3,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.EMPTY;
|
||||
import static org.woheller69.weather.ui.RecycleList.CityWeatherAdapter.OVERVIEW;
|
||||
import static org.woheller69.weather.ui.RecycleList.CityWeatherAdapter.WEEK;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
@ -38,7 +39,7 @@ public class WeatherCityFragment extends Fragment implements IUpdateableCityUI {
|
|||
|
||||
private int mCityId = -1;
|
||||
private int[] mDataSetTypes = new int[]{};
|
||||
private static int[] mFull = {DAY, WEEK, CHART}; //TODO Make dynamic from Settings
|
||||
private static int[] mFull = {OVERVIEW, DAY, WEEK, CHART}; //TODO Make dynamic from Settings
|
||||
private static int[] mEmpty = {EMPTY};
|
||||
private CityWeatherAdapter mAdapter;
|
||||
|
||||
|
|
|
@ -5,40 +5,38 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/card_margin">
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#fafafa"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginStart="7dp"
|
||||
android:textSize="12dp"
|
||||
android:text="Weather data by Open-Meteo.com" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical">
|
||||
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@color/backgroundBlue">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/card_overview_temperature"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/card_overview_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:background="@drawable/rounded_corner"
|
||||
android:paddingLeft="7dp"
|
||||
android:paddingRight="7dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/card_today_heading"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textSize="45dp" />
|
||||
android:textStyle="bold" />
|
||||
|
||||
<View
|
||||
android:id="@+id/card_overview_header_spacer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_below="@id/card_overview_header"
|
||||
android:background="@color/white" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/card_overview_update_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignBaseline="@id/card_overview_header"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:paddingLeft="7dp"
|
||||
|
@ -46,18 +44,77 @@
|
|||
android:textColor="#fafafa"
|
||||
android:textSize="18dp" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/card_overview_sunrise_sunset"
|
||||
android:layout_alignBaseline="@id/card_overview_remaining_today"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="15dp"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:paddingRight="7dp"
|
||||
android:paddingLeft="7dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/card_overview_credits"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/card_overview_sunrise_sunset"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:textColor="#fafafa"
|
||||
android:layout_marginStart="7dp"
|
||||
android:textSize="12dp"
|
||||
android:text="Weather data by Open-Meteo.com" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/card_overview_produced_today_header"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/card_overview_header_spacer"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginStart="7dp"
|
||||
android:text="@string/card_today_produced" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/card_overview_produced_today"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/card_overview_header_spacer"
|
||||
android:layout_toEndOf="@id/card_overview_produced_today_header"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginStart="7dp"
|
||||
android:text="1500 Wh" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/card_overview_remaining_today_header"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/card_overview_produced_today"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginStart="7dp"
|
||||
android:text="@string/card_today_remaining" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/card_overview_remaining_today"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/card_overview_produced_today"
|
||||
android:layout_toEndOf="@id/card_overview_remaining_today_header"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginStart="7dp"
|
||||
android:text="1500 Wh" />
|
||||
|
||||
</RelativeLayout>
|
||||
<TextView
|
||||
android:id="@+id/card_overview_sunrise_sunset"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:textSize="15dp"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:background="@drawable/rounded_corner"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:paddingRight="7dp"
|
||||
android:paddingLeft="7dp" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
|
@ -111,4 +111,7 @@
|
|||
<string name="settings_server_urls">Server URLs</string>
|
||||
<string name="settings_server_summary">Nur ändern, wenn Sie Ihre eigenen Server betreiben wollen</string>
|
||||
<string name="edit_location_hint_central_inverter">Zentralwechselrichter</string>
|
||||
<string name="card_today_heading">Heute</string>
|
||||
<string name="card_today_produced">Produziert:</string>
|
||||
<string name="card_today_remaining">Verbleibend:</string>
|
||||
</resources>
|
||||
|
|
|
@ -114,5 +114,7 @@
|
|||
<string name="settings_server_urls">Server URLs</string>
|
||||
<string name="settings_server_summary">Only change if you want to host your own servers</string>
|
||||
<string name="edit_location_hint_central_inverter">Central Inverter</string>
|
||||
|
||||
<string name="card_today_heading">Today</string>
|
||||
<string name="card_today_produced">Produced:</string>
|
||||
<string name="card_today_remaining">Remaining:</string>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue