package ca.antonious.viewcelladapter.sections;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import ca.antonious.viewcelladapter.utils.CollectionUtils;
import ca.antonious.viewcelladapter.viewcells.AbstractViewCell;

/**
 * Created by George on 2016-11-17.
 */

public class Section extends AbstractSection {
    protected List<AbstractViewCell> viewCells;

    public Section() {
        this.viewCells = new ArrayList<>();
    }

    public List<AbstractViewCell> getAll() {
        return new ArrayList<>(viewCells);
    }

    public List<AbstractViewCell> getAllSelected() {
        List<AbstractViewCell> selectedViewCells = new ArrayList<>();

        for (AbstractViewCell viewCell: viewCellIterator()) {
            if (viewCell.isSelected()) {
                selectedViewCells.add(viewCell);
            }
        }

        return selectedViewCells;
    }

    public void add(AbstractViewCell viewCell) {
        this.viewCells.add(viewCell);
    }

    public void addAll(Collection<? extends AbstractViewCell> viewCells) {
        this.viewCells.addAll(viewCells);
    }

    public void setAll(Collection<? extends AbstractViewCell> viewCells) {
        CollectionUtils.setAll(this.viewCells, viewCells);
    }

    public void prependAll(Collection<? extends AbstractViewCell> viewCells) {
        CollectionUtils.prependAll(this.viewCells, viewCells);
    }

    public void clear() {
        viewCells.clear();
    }

    @Override
    public AbstractViewCell get(int position) {
        return viewCells.get(position);
    }

    @Override
    public void remove(int position) {
        viewCells.remove(position);
    }

    @Override
    public int getItemCount() {
        return viewCells.size();
    }
}
@@ -985,22 +985,48 @@
 wCell);%0A
+        invalidateData();%0A
     %7D%0A
-
 %0A    pub
@@ -1127,32 +1127,58 @@
 All(viewCells);%0A
+        invalidateData();%0A
     %7D%0A%0A    publi
@@ -1294,32 +1294,58 @@
 ls, viewCells);%0A
+        invalidateData();%0A
     %7D%0A%0A    publi
@@ -1469,32 +1469,58 @@
 ls, viewCells);%0A
+        invalidateData();%0A
     %7D%0A%0A    publi
@@ -1559,24 +1559,50 @@
 ls.clear();%0A
+        invalidateData();%0A
     %7D%0A%0A    @
@@ -1786,32 +1786,58 @@
 move(position);%0A
+        invalidateData();%0A
     %7D%0A%0A    @Over
@@ -1869,24 +1869,24 @@
 emCount() %7B%0A
-
         retu
@@ -1911,10 +1911,82 @@
 );%0A    %7D
+%0A%0A    private void invalidateData() %7B%0A        notifyDataChanged();%0A    %7D
 %0A%7D

Update section to handle notifications