String.format(Locale.US, "invoking notifyItemInserted(%d)", newAccountCount));
// the header is at position 0
notifyItemInserted(newAccountCount);
+ model.sendCountNotifications(); // needed after holders' positions have changed
return newAccountCount;
}
@NonNull
@Override
public void onBindViewHolder(@NonNull NewTransactionItemHolder holder, int position) {
Logger.debug("bind", String.format(Locale.US, "Binding item at position %d", position));
- holder.setData(model.getItem(position));
- Logger.debug("bind", String.format(Locale.US, "Bound item at position %d", position));
+ NewTransactionModel.Item item = model.getItem(position);
+ holder.setData(item);
+ Logger.debug("bind", String.format(Locale.US, "Bound %s item at position %d", item.getType()
+ .toString(),
+ position));
}
@Override
public int getItemCount() {
- final int itemCount = model.getAccountCount() + 2;
- Logger.debug("new-transaction",
- String.format(Locale.US, "getItemCount() returning %d", itemCount));
- return itemCount;
+ return model.getAccountCount() + 2;
}
boolean accountListIsEmpty() {
for (int i = 0; i < model.getAccountCount(); i++) {
if (presentItemCount > 2)
notifyItemRangeRemoved(3, presentItemCount - 2); // all the rest are gone
}
- public void removeItem(int pos) {
- model.removeItem(pos - 1, this);
- notifyItemRemoved(pos);
- }
}