/*
- * Copyright © 2020 Damyan Ivanov.
+ * 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
import net.ktnx.mobileledger.App;
import net.ktnx.mobileledger.R;
+import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.model.LedgerTransaction;
import net.ktnx.mobileledger.model.LedgerTransactionAccount;
import net.ktnx.mobileledger.model.TransactionListItem;
.equals(newItem.getDate()));
case TRANSACTION:
return oldItem.getTransaction()
- .getId() == newItem.getTransaction()
- .getId();
+ .getLedgerId() == newItem.getTransaction()
+ .getLedgerId();
+ case HEADER:
+ return true; // there can be only one header
default:
throw new IllegalStateException(
String.format(Locale.US, "Unexpected transaction item type %s",
case TRANSACTION:
return oldItem.getTransaction()
.equals(newItem.getTransaction());
+ case HEADER:
+ // headers don't differ in their contents. they observe the last update
+ // date and react to its changes
+ return true;
default:
throw new IllegalStateException(
String.format(Locale.US, "Unexpected transaction item type %s",
if (item == null)
return;
- switch (item.getType()) {
+ final TransactionListItem.Type newType = item.getType();
+ holder.setType(newType);
+
+ switch (newType) {
case TRANSACTION:
- holder.vTransaction.setVisibility(View.VISIBLE);
- holder.vDelimiter.setVisibility(View.GONE);
LedgerTransaction tr = item.getTransaction();
// debug("transactions", String.format("Filling position %d with %d
break;
case DELIMITER:
SimpleDate date = item.getDate();
- holder.vTransaction.setVisibility(View.GONE);
- holder.vDelimiter.setVisibility(View.VISIBLE);
holder.tvDelimiterDate.setText(DateFormat.getDateInstance()
.format(date.toDate()));
if (item.isMonthShown()) {
holder.vDelimiterThick.setVisibility(View.GONE);
}
break;
+ case HEADER:
+ holder.setLastUpdateText(Data.lastTransactionsUpdateText.getValue());
+
+ break;
+ default:
+ throw new IllegalStateException("Unexpected value: " + newType);
}
}
-
@NonNull
@Override
public TransactionRowHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {