From 6f8d7eb0ab9e5754047ac5bda47868860b5f71e2 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 19 Jan 2019 13:45:38 +0000 Subject: [PATCH] transaction list: add a hollow placeholder at the bottom of the list to ensure the FAB is not always over something --- .../model/TransactionListItem.java | 5 +- .../TransactionListAdapter.java | 86 +++++++++++-------- .../TransactionListViewModel.java | 3 +- .../TransactionRowHolder.java | 2 + .../main/res/layout/transaction_list_row.xml | 7 ++ 5 files changed, 63 insertions(+), 40 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/model/TransactionListItem.java b/app/src/main/java/net/ktnx/mobileledger/model/TransactionListItem.java index 55fe04ac..9243721a 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/TransactionListItem.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/TransactionListItem.java @@ -27,6 +27,9 @@ public class TransactionListItem { private boolean monthShown; private LedgerTransaction transaction; private boolean odd; + public TransactionListItem() { + this.type = Type.TRAILER; + } public TransactionListItem(Date date, boolean monthShown) { this.type = Type.DELIMITER; this.date = date; @@ -53,5 +56,5 @@ public class TransactionListItem { public boolean isOdd() { return odd; } - public enum Type {TRANSACTION, DELIMITER} + public enum Type {TRANSACTION, DELIMITER, TRAILER} } diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListAdapter.java b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListAdapter.java index b6e7057d..f4a0bcbb 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListAdapter.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListAdapter.java @@ -57,43 +57,53 @@ public class TransactionListAdapter extends RecyclerView.Adapter transactions = Data.transactions.get(); - if (position >= transactions.size()) return null; + if (position >= transactions.size() + 1) return null; + if (position == transactions.size()) return new TransactionListItem(); return transactions.get(position); } public static int getTransactionCount() { diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionRowHolder.java b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionRowHolder.java index 7baba8fa..73dd3168 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionRowHolder.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionRowHolder.java @@ -35,6 +35,7 @@ class TransactionRowHolder extends RecyclerView.ViewHolder { CardView vTransaction; TextView tvDelimiterMonth, tvDelimiterDate; View vDelimiterLine, vDelimiterThick; + View vTrailer; public TransactionRowHolder(@NonNull View itemView) { super(itemView); this.row = itemView.findViewById(R.id.transaction_row); @@ -46,5 +47,6 @@ class TransactionRowHolder extends RecyclerView.ViewHolder { this.tvDelimiterMonth = itemView.findViewById(R.id.transaction_delimiter_month); this.vDelimiterLine = itemView.findViewById(R.id.transaction_delimiter_line); this.vDelimiterThick = itemView.findViewById(R.id.transaction_delimiter_thick); + this.vTrailer = itemView.findViewById(R.id.transaction_list_trailer); } } diff --git a/app/src/main/res/layout/transaction_list_row.xml b/app/src/main/res/layout/transaction_list_row.xml index dea0bfd2..28864be9 100644 --- a/app/src/main/res/layout/transaction_list_row.xml +++ b/app/src/main/res/layout/transaction_list_row.xml @@ -202,4 +202,11 @@ app:layout_constraintTop_toTopOf="parent" /> + + \ No newline at end of file -- 2.39.5