From b5ce02c84db901506139f9e0aaab3c56e394a6e3 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 19 Jan 2019 15:34:02 +0000 Subject: [PATCH 1/1] account list: add hollow trailing item so that the FAB can be in a position not to cover a useful item --- .../AccountSummaryAdapter.java | 77 +++++++++++-------- .../TransactionListFragment.java | 15 ++++ .../main/res/layout/account_summary_row.xml | 69 +++++++++++------ 3 files changed, 105 insertions(+), 56 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryAdapter.java b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryAdapter.java index 6c6f4a76..6f3e4f2b 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryAdapter.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryAdapter.java @@ -34,6 +34,8 @@ import net.ktnx.mobileledger.R; import net.ktnx.mobileledger.model.Data; import net.ktnx.mobileledger.model.LedgerAccount; +import java.util.List; + class AccountSummaryAdapter extends RecyclerView.Adapter { private boolean selectionActive; @@ -42,40 +44,49 @@ class AccountSummaryAdapter extends RecyclerView.Adapter accounts = Data.accounts.get(); + if (position < accounts.size()) { + LedgerAccount acc = accounts.get(position); + Context ctx = holder.row.getContext(); + Resources rm = ctx.getResources(); + + holder.row.setVisibility(View.VISIBLE); + holder.vTrailer.setVisibility(View.GONE); + holder.tvAccountName.setText(acc.getShortName()); + holder.tvAccountName.setPadding( + acc.getLevel() * rm.getDimensionPixelSize(R.dimen.activity_horizontal_margin) / + 2, 0, 0, 0); + holder.tvAccountAmounts.setText(acc.getAmountsString()); + + if (acc.isHidden()) { + holder.tvAccountName.setTypeface(null, Typeface.ITALIC); + holder.tvAccountAmounts.setTypeface(null, Typeface.ITALIC); + } + else { + holder.tvAccountName.setTypeface(null, Typeface.NORMAL); + holder.tvAccountAmounts.setTypeface(null, Typeface.NORMAL); + } - if (position % 2 == 0) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) holder.row - .setBackgroundColor(rm.getColor(R.color.table_row_dark_bg, ctx.getTheme())); - else holder.row.setBackgroundColor(rm.getColor(R.color.table_row_dark_bg)); + if (position % 2 == 0) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) holder.row + .setBackgroundColor(rm.getColor(R.color.table_row_dark_bg, ctx.getTheme())); + else holder.row.setBackgroundColor(rm.getColor(R.color.table_row_dark_bg)); + } + else { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) holder.row + .setBackgroundColor(rm.getColor(R.color.drawer_background, ctx.getTheme())); + else holder.row.setBackgroundColor(rm.getColor(R.color.drawer_background)); + } + + holder.selectionCb.setVisibility(selectionActive ? View.VISIBLE : View.GONE); + holder.selectionCb.setChecked(!acc.isHiddenToBe()); + + holder.row.setTag(R.id.POS, position); } else { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) holder.row - .setBackgroundColor(rm.getColor(R.color.drawer_background, ctx.getTheme())); - else holder.row.setBackgroundColor(rm.getColor(R.color.drawer_background)); + holder.vTrailer.setVisibility(View.VISIBLE); + holder.row.setVisibility(View.GONE); } - - holder.selectionCb.setVisibility(selectionActive ? View.VISIBLE : View.GONE); - holder.selectionCb.setChecked(!acc.isHiddenToBe()); - - holder.row.setTag(R.id.POS, position); } @NonNull @@ -88,7 +99,7 @@ class AccountSummaryAdapter extends RecyclerView.Adapter. --> - - - - - - - \ No newline at end of file + + + + + + + + + + + \ No newline at end of file -- 2.39.2