- LedgerAccount acc = Data.accounts.get().get(position);
- Context ctx = holder.row.getContext();
- Resources rm = ctx.getResources();
-
- 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);
- }
+ List<LedgerAccount> 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);
+ }