Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListTransformation fires multiple add events on the target list when multiple elements are added to the source list #281

Closed
mthiele opened this issue Jul 3, 2015 · 1 comment

Comments

@mthiele
Copy link

mthiele commented Jul 3, 2015

The ListTransformation implementation fires multiple ListChangeEvents on the target list when adding multiple elements to the source list (which is done in one event). This is a rather unexpected behaviour since the original add event is also one event and leads to problems with FilteredLists in conjunction with ListTransformation when the predicate of the FilteredList is reset.

My proposed change would be:

  private void processAddEvent(
      final Change<? extends SourceType> listEvent) {
    final List<TargetType> toAdd = new ArrayList<>();
    for (int index = listEvent.getFrom(); index < listEvent.getTo(); index++) {
      final SourceType item = listEvent.getList().get(index);
      toAdd.add(function.apply(item));
    }
    viewModelList.addAll(listEvent.getFrom(), toAdd);
  }
@manuel-mauky manuel-mauky added this to the 1.4.0 milestone Jul 3, 2015
manuel-mauky added a commit that referenced this issue Jul 6, 2015
manuel-mauky added a commit that referenced this issue Jul 6, 2015
@manuel-mauky
Copy link
Collaborator

thanks for your suggestion. It's now fixed with #283

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants