- LedgerTransaction tr = TransactionListViewModel.getTransaction(position);
- // in a race when transaction value is reduced, but the model hasn't been notified yet
- // the view will disappear when the notifications reaches the model, so by simply omitting
- // the out-of-range get() call nothing bad happens - just a to-be-deleted view remains
- // a bit longer
- if (tr == null) return;
-
- Log.d("transactions", String.format("Filling position %d", position));
-
- TransactionLoader loader = new TransactionLoader();
- loader.execute(new TransactionLoaderParams(tr, holder, position, boldAccountName));
+ TransactionListItem item = TransactionListViewModel.getTransactionListItem(position);
+
+ if (item.getType() == TransactionListItem.Type.TRANSACTION) {
+ holder.vTransaction.setVisibility(View.VISIBLE);
+ holder.vDelimiter.setVisibility(View.GONE);
+ LedgerTransaction tr = item.getTransaction();
+ // in a race when transaction value is reduced, but the model hasn't been notified yet
+ // the view will disappear when the notifications reaches the model, so by simply omitting
+ // the out-of-range get() call nothing bad happens - just a to-be-deleted view remains
+ // a bit longer
+ if (tr == null) return;
+
+ LedgerTransaction previous = null;
+ TransactionListItem previousItem = null;
+ if (position > 0)
+ previousItem = TransactionListViewModel.getTransactionListItem(position - 1);
+
+// Log.d("transactions", String.format("Filling position %d with %d accounts", position,
+// tr.getAccounts().size()));
+
+ TransactionLoader loader = new TransactionLoader();
+ loader.execute(
+ new TransactionLoaderParams(tr, previous, holder, position, boldAccountName));
+
+ // WORKAROUND what seems to be a bug in CardHolder somewhere
+ // when a view that was previously holding a delimiter is re-purposed
+ // occasionally it stays too short (not high enough)
+ holder.vTransaction.measure(View.MeasureSpec
+ .makeMeasureSpec(holder.itemView.getWidth(), View.MeasureSpec.EXACTLY),
+ View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
+ }
+ else {
+ Date date = item.getDate();
+ holder.vTransaction.setVisibility(View.GONE);
+ holder.vDelimiter.setVisibility(View.VISIBLE);
+ holder.tvDelimiterDate.setText(DateFormat.getDateInstance().format(date));
+ if (item.isMonthShown()) {
+ holder.tvDelimiterMonth.setText(Globals.monthNames[date.getMonth()]);
+ holder.tvDelimiterMonth.setVisibility(View.VISIBLE);
+ holder.vDelimiterLine.setBackgroundResource(R.drawable.dashed_border_8dp);
+ }
+ else {
+ holder.tvDelimiterMonth.setVisibility(View.GONE);
+ holder.vDelimiterLine.setBackgroundResource(R.drawable.dashed_border_1dp);
+ }
+ }