X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;ds=inline;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Faccount_summary%2FAccountSummaryAdapter.java;h=da678a6a192d4a628d505b688c10f67474eec884;hb=aef5271787fb3b91b74a93efb48c569df0de6575;hp=6c6f4a7624a5c48e0e05bd4532f6401e94f06610;hpb=a2b00ecbcbe8b13df466c94aa11ba593f69869d8;p=mobile-ledger.git
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..da678a6a 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
@@ -1,18 +1,18 @@
/*
* Copyright © 2019 Damyan Ivanov.
- * This file is part of Mobile-Ledger.
- * Mobile-Ledger is free software: you can distribute it and/or modify it
+ * 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.
*
- * Mobile-Ledger is distributed in the hope that it will be useful,
+ * 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 Mobile-Ledger. If not, see .
+ * along with MoLe. If not, see .
*/
package net.ktnx.mobileledger.ui.account_summary;
@@ -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