Skip to content

Commit

Permalink
expose collapsed headers
Browse files Browse the repository at this point in the history
  • Loading branch information
mtotschnig committed May 17, 2020
1 parent b2789b4 commit 2d5c904
Showing 1 changed file with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public interface IAnimationExecutor{

ExpandableStickyListHeadersAdapter mExpandableStickyListHeadersAdapter;

List<Long> mCollapseHeaderIds;

IAnimationExecutor mDefaultAnimExecutor = new IAnimationExecutor() {
@Override
public void executeAnim(View target, int animType) {
Expand Down Expand Up @@ -58,10 +56,6 @@ public void setAdapter(StickyListHeadersAdapter adapter) {
mExpandableStickyListHeadersAdapter = (adapter instanceof SectionIndexingStickyListHeadersAdapter) ?
new SectionIndexingExpandableStickyListHeadersAdapter(((SectionIndexingStickyListHeadersAdapter) adapter)) :
new ExpandableStickyListHeadersAdapter(adapter);
if (mCollapseHeaderIds != null) {
mExpandableStickyListHeadersAdapter.mCollapseHeaderIds = mCollapseHeaderIds;
mCollapseHeaderIds = null;
}
super.setAdapter(mExpandableStickyListHeadersAdapter);
}

Expand Down Expand Up @@ -107,6 +101,10 @@ public boolean isHeaderCollapsed(long headerId){
return mExpandableStickyListHeadersAdapter.isHeaderCollapsed(headerId);
}

public List<Long> getCollapsedHeaderIds() {
return mExpandableStickyListHeadersAdapter.mCollapseHeaderIds;
}

public void setAnimExecutor(IAnimationExecutor animExecutor) {
this.mDefaultAnimExecutor = animExecutor;
}
Expand Down Expand Up @@ -140,36 +138,35 @@ public Parcelable onSaveInstanceState() {
public void onRestoreInstanceState(Parcelable state) {
SavedState ss = (SavedState) state;
super.onRestoreInstanceState(ss.getSuperState());
mCollapseHeaderIds = ss.collapsedIds;
if (mExpandableStickyListHeadersAdapter != null) {
mExpandableStickyListHeadersAdapter.mCollapseHeaderIds = mCollapseHeaderIds;
mExpandableStickyListHeadersAdapter.mCollapseHeaderIds = ss.collapsedHeaderIds;
}
}

static class SavedState extends BaseSavedState {
private List<Long> collapsedIds;
private List<Long> collapsedHeaderIds;

/**
* Constructor called from {@link StickyListHeadersListView#onSaveInstanceState()}
*/
SavedState(Parcelable superState, List<Long> collapsedIds) {
SavedState(Parcelable superState, List<Long> collapsedHeaderIds) {
super(superState);
this.collapsedIds = collapsedIds;
this.collapsedHeaderIds = collapsedHeaderIds;
}

/**
* Constructor called from {@link #CREATOR}
*/
private SavedState(Parcel in) {
super(in);
collapsedIds = new ArrayList<>();
in.readList(collapsedIds, null);
collapsedHeaderIds = new ArrayList<>();
in.readList(collapsedHeaderIds, null);
}

@Override
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeList(collapsedIds);
out.writeList(collapsedHeaderIds);
}

public static final Parcelable.Creator<SavedState> CREATOR
Expand Down

0 comments on commit 2d5c904

Please sign in to comment.