list = copyList(list);
liveListCopied = true;
}
- Item item = emptyItems.remove(1);
- list.remove(item);
+ // the list is a copy, so the empty item is no longer present
+ Item itemToRemove = emptyItems.remove(1);
+ removeItemById(list, itemToRemove.id);
listChanged = true;
}
list = copyList(list);
liveListCopied = true;
}
- Item item = emptyItems.get(0);
- list.remove(item);
+ // the list is a copy, so the empty item is no longer present
+ removeItemById(list, emptyItems.get(0).id);
listChanged = true;
}
}
setItemsWithoutSubmittableChecks(list);
}
}
+ private void removeItemById(@NotNull List<Item> list, int id) {
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
+ list.removeIf(item -> item.id == id);
+ }
+ else {
+ for (Item item : list) {
+ if (item.id == id) {
+ list.remove(item);
+ break;
+ }
+ }
+ }
+ }
@SuppressLint("DefaultLocale")
private void dumpItemList(@NotNull String msg, @NotNull List<Item> list) {
Logger.debug("submittable", "== Dump of all items " + msg);