X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;ds=sidebyside;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Ftransaction_list%2FTransactionListDelimiterRowHolder.java;fp=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Ftransaction_list%2FTransactionListDelimiterRowHolder.java;h=390b4941719c2eca9b5d4c4e992086131ac3525e;hb=0b96f4968cd5c0b36474b94b94ec6dcf6699f60c;hp=0000000000000000000000000000000000000000;hpb=3c459e59ba3ac6082d65984359fcb6276965de4d;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListDelimiterRowHolder.java b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListDelimiterRowHolder.java new file mode 100644 index 00000000..390b4941 --- /dev/null +++ b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListDelimiterRowHolder.java @@ -0,0 +1,61 @@ +/* + * Copyright © 2021 Damyan Ivanov. + * This file is part of MoLe. + * MoLe is free software: you can distribute it and/or modify it + * under the term of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your opinion), any later version. + * + * MoLe is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License terms for details. + * + * You should have received a copy of the GNU General Public License + * along with MoLe. If not, see . + */ + +package net.ktnx.mobileledger.ui.transaction_list; + +import android.view.View; + +import net.ktnx.mobileledger.App; +import net.ktnx.mobileledger.databinding.TransactionDelimiterBinding; +import net.ktnx.mobileledger.model.TransactionListItem; +import net.ktnx.mobileledger.utils.Globals; +import net.ktnx.mobileledger.utils.SimpleDate; + +import java.text.DateFormat; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +class TransactionListDelimiterRowHolder extends TransactionRowHolderBase { + private final TransactionDelimiterBinding b; + TransactionListDelimiterRowHolder(TransactionDelimiterBinding binding) { + super(binding.getRoot()); + b = binding; + } + public void bind(TransactionListItem item) { + SimpleDate date = item.getDate(); + b.transactionDelimiterDate.setText(DateFormat.getDateInstance() + .format(date.toDate())); + if (item.isMonthShown()) { + GregorianCalendar cal = new GregorianCalendar(TimeZone.getDefault()); + cal.setTime(date.toDate()); + App.prepareMonthNames(); + b.transactionDelimiterMonth.setText( + Globals.monthNames[cal.get(GregorianCalendar.MONTH)]); + b.transactionDelimiterMonth.setVisibility(View.VISIBLE); + // holder.vDelimiterLine.setBackgroundResource(R.drawable + // .dashed_border_8dp); + b.transactionDelimiterThick.setVisibility(View.VISIBLE); + } + else { + b.transactionDelimiterMonth.setVisibility(View.GONE); + // holder.vDelimiterLine.setBackgroundResource(R.drawable + // .dashed_border_1dp); + b.transactionDelimiterThick.setVisibility(View.GONE); + } + + } +}