2 * Copyright © 2021 Damyan Ivanov.
3 * This file is part of MoLe.
4 * MoLe is free software: you can distribute it and/or modify it
5 * under the term of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your opinion), any later version.
9 * MoLe is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License terms for details.
14 * You should have received a copy of the GNU General Public License
15 * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
18 package net.ktnx.mobileledger.ui.transaction_list;
20 import android.view.View;
22 import net.ktnx.mobileledger.App;
23 import net.ktnx.mobileledger.databinding.TransactionDelimiterBinding;
24 import net.ktnx.mobileledger.model.TransactionListItem;
25 import net.ktnx.mobileledger.utils.Globals;
26 import net.ktnx.mobileledger.utils.SimpleDate;
28 import java.text.DateFormat;
29 import java.util.GregorianCalendar;
30 import java.util.TimeZone;
32 class TransactionListDelimiterRowHolder extends TransactionRowHolderBase {
33 private final TransactionDelimiterBinding b;
34 TransactionListDelimiterRowHolder(TransactionDelimiterBinding binding) {
35 super(binding.getRoot());
38 public void bind(TransactionListItem item) {
39 SimpleDate date = item.getDate();
40 b.transactionDelimiterDate.setText(DateFormat.getDateInstance()
41 .format(date.toDate()));
42 if (item.isMonthShown()) {
43 GregorianCalendar cal = new GregorianCalendar(TimeZone.getDefault());
44 cal.setTime(date.toDate());
45 App.prepareMonthNames();
46 b.transactionDelimiterMonth.setText(
47 Globals.monthNames[cal.get(GregorianCalendar.MONTH)]);
48 b.transactionDelimiterMonth.setVisibility(View.VISIBLE);
49 // holder.vDelimiterLine.setBackgroundResource(R.drawable
50 // .dashed_border_8dp);
51 b.transactionDelimiterThick.setVisibility(View.VISIBLE);
54 b.transactionDelimiterMonth.setVisibility(View.GONE);
55 // holder.vDelimiterLine.setBackgroundResource(R.drawable
56 // .dashed_border_1dp);
57 b.transactionDelimiterThick.setVisibility(View.GONE);