package ca.antonious.viewcelladapter.sections;

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

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

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

public class CompositeSection extends AbstractSection {
    private List<AbstractSection> sections;

    public CompositeSection() {
        this.sections = new ArrayList<>();
    }

    @Override
    public AbstractViewCell get(int position) {
        return ViewCellUtils.getViewCell(sections, position);
    }

    @Override
    public void remove(int position) {
        int sectionIndex = ViewCellUtils.getSectionIndex(sections, position);
        int viewCellIndex = ViewCellUtils.getViewCellIndex(sections, position);

        sections.get(sectionIndex).remove(viewCellIndex);
    }

    @Override
    public int getItemCount() {
        return ViewCellUtils.getTotalCount(sections);
    }

    public CompositeSection addSection(AbstractSection section) {
        sections.add(section);
        return this;
    }

    public CompositeSection removeSection(AbstractSection section) {
        sections.remove(section);
        return this;
    }
}

@@ -93,16 +93,78 @@
 .List;%0A%0A
+import ca.antonious.viewcelladapter.internal.SectionObserver;%0A
 import c
@@ -376,16 +376,43 @@
 Section 
+implements SectionObserver 
 %7B%0A    pr
@@ -1105,32 +1105,67 @@
 tion section) %7B%0A
+        section.addObserver(this);%0A
         sections
@@ -1295,46 +1295,168 @@
 tion
-s.remove(section);%0A        return this
+.removeObserver(this);%0A        sections.remove(section);%0A        return this;%0A    %7D%0A%0A    @Override%0A    public void onDataChanged() %7B%0A        notifyDataChanged()
 ;%0A  

Update composite section to handle notifications