File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
java/com/georgemc2610/benzinapp/fragments/history Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -108,15 +108,22 @@ private void createCards()
108
108
List <FuelFillRecord > recordsInMonthYear = groupedRecords .get (key );
109
109
String stringYearMonth = key .format (formatter );
110
110
111
+ TextView totalCostLegend = null ;
112
+ float totalCost = 0f ;
113
+
111
114
for (FuelFillRecord record : recordsInMonthYear )
112
115
{
116
+ // add total cost count
117
+ totalCost += record .getCost_eur ();
118
+
113
119
// inflate the card view for the fuel fill records.
114
120
View v ;
115
121
116
122
if (recordsInMonthYear .indexOf (record ) == 0 )
117
123
{
118
124
v = inflater .inflate (R .layout .cardview_fill_with_legend , null );
119
125
TextView legend = v .findViewById (R .id .card_year_month_legend );
126
+ totalCostLegend = v .findViewById (R .id .card_cost_legend );
120
127
legend .setText (stringYearMonth );
121
128
}
122
129
else
@@ -186,6 +193,13 @@ private void createCards()
186
193
// change the hint text.
187
194
hint .setText (getString (R .string .text_view_click_cards_message ));
188
195
}
196
+
197
+ if (totalCostLegend != null )
198
+ {
199
+ DecimalFormat decimalFormat = new DecimalFormat ("#.##" );
200
+ String totalCostString = "€" + decimalFormat .format (totalCost );
201
+ totalCostLegend .setText (totalCostString );
202
+ }
189
203
}
190
204
}
191
205
Original file line number Diff line number Diff line change 13
13
android : layout_marginStart =" 7dp"
14
14
android : layout_marginTop =" 8dp"
15
15
android : layout_marginEnd =" 7dp"
16
- android : layout_marginBottom =" 8dp "
16
+ android : layout_marginBottom =" 2dp "
17
17
android : text =" mmmm YYYY"
18
18
style =" @style/textColor"
19
19
android : textSize =" 24sp"
20
20
android : textStyle =" bold" />
21
21
22
+ <TextView
23
+ android : id =" @+id/card_cost_legend"
24
+ android : layout_width =" wrap_content"
25
+ android : layout_height =" wrap_content"
26
+ android : layout_marginStart =" 7dp"
27
+ android : layout_marginEnd =" 7dp"
28
+ android : layout_marginBottom =" 8dp"
29
+ android : text =" total cost"
30
+ style =" @style/textColorSpecial"
31
+ android : textSize =" 12sp" />
32
+
22
33
<androidx .cardview.widget.CardView
23
34
android : layout_width =" match_parent"
24
35
android : layout_height =" 105dp"
You can’t perform that action at this time.
0 commit comments