+ newList.add(header);
+ changes = true;
+ }
+ else {
+ newList.add(srcList.get(0));
+ }
+
+ for (int i = 1; i < srcList.size(); i++) {
+ final TemplateDetailsItem.AccountRow accRow = srcList.get(i)
+ .asAccountRowItem();
+ if (accRow.isEmpty()) {
+ // it is normal to have two empty rows if they are at the
+ // top (position 1 and 2)
+ if (!hasEmptyItem || i < 3) {
+ accRow.setPosition(newList.size());
+ newList.add(accRow);
+ }
+ else
+ changes = true; // row skipped
+
+ hasEmptyItem = true;
+ }
+ else {
+ accRow.setPosition(newList.size());
+ newList.add(accRow);
+ }
+ }
+
+ while (newList.size() < 3) {
+ final TemplateDetailsItem.AccountRow accountRow =
+ TemplateDetailsItem.createAccountRow();
+ accountRow.setId(genItemId());
+ accountRow.setPosition(newList.size());
+ newList.add(accountRow);