Skip to content

Commit

Permalink
- Fix initial expand.
Browse files Browse the repository at this point in the history
  • Loading branch information
iammert committed Aug 22, 2017
1 parent a5b2f05 commit 5a7b1ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public Section<FruitCategory, Fruit> getSection() {
section.children.add(fruit3);
section.children.add(fruit4);
section.children.add(fruit5);
section.expanded = true;
return section;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public <P, C> void addChild(P parent, C child) {
}
if (parentIndex != NO_INDEX) {
notifyItemAdded(parentIndex, child);
if (sections.get(parentIndex).expanded) {
expand(parent);
}
}
}

Expand All @@ -129,6 +132,9 @@ public <P, C> void addChildren(P parent, List<C> children) {
}
if (parentIndex != NO_INDEX) {
notifyItemAdded(parentIndex, children);
if (sections.get(parentIndex).expanded) {
expand(parent);
}
}
}

Expand Down Expand Up @@ -187,7 +193,7 @@ public void onClick(View view) {
addView(sectionLayout);
}

public <P> void expand(@NonNull P parent) {
private <P> void expand(@NonNull P parent) {
for (int i = 0; i < sections.size(); i++) {
if (parent.equals(sections.get(i).parent)) {
ViewGroup sectionView = ((ViewGroup) getChildAt(i));
Expand All @@ -201,7 +207,7 @@ public <P> void expand(@NonNull P parent) {
}
}

public <P> void collapse(@NonNull P parent) {
private <P> void collapse(@NonNull P parent) {
for (int i = 0; i < sections.size(); i++) {
if (parent.equals(sections.get(i).parent)) {
ViewGroup sectionView = ((ViewGroup) getChildAt(i));
Expand Down

0 comments on commit 5a7b1ed

Please sign in to comment.