Skip to content

Commit

Permalink
Separated the initialization of expanded items at start up #86: expan…
Browse files Browse the repository at this point in the history
…dItemsAtStartUp() must be explicitly called by the user in Activity creation phase.
  • Loading branch information
davideas committed Jun 5, 2016
1 parent 922eaa4 commit 76b1aa1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
private void initializeRecyclerView(Bundle savedInstanceState) {
mAdapter = new ExampleAdapter(getActivity());
//Experimenting NEW features (v5.0.0)
mAdapter.expandItemsAtStartUp();
mAdapter.setAnimationOnScrolling(true);
mAdapter.setAnimationOnReverseScrolling(true);
mAdapter.setAutoCollapseOnExpand(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
private void initializeRecyclerView(Bundle savedInstanceState) {
mAdapter = new ExampleAdapter(getActivity());
//Experimenting NEW features (v5.0.0)
mAdapter.expandItemsAtStartUp();
mAdapter.setAnimationOnScrolling(true);
mAdapter.setAnimationOnReverseScrolling(true);
mAdapter.setAutoCollapseOnExpand(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@ public FlexibleAdapter(@NonNull List<T> items, @Nullable Object listeners) {
mRestoreList = new ArrayList<RestoreInfo>();
mOrphanHeaders = new ArrayList<IHeader>();

//Expand initial items
//This works also after a screen rotation
initializeItems();

//Create listeners instances
initializeListeners(listeners);

Expand Down Expand Up @@ -264,9 +260,10 @@ public void onDetachedFromRecyclerView(RecyclerView recyclerView) {

/**
* Maps and expands items that are initially configured to be shown as expanded.
* <p>This method is also called after a screen rotation.</p>
* <p>This method has to be called during creation of the Activity, useful also after a
* screen rotation.</p>
*/
protected void initializeItems() {
public void expandItemsAtStartUp() {
int position = 0;
setInitialize(true);
multiRange = true;
Expand Down Expand Up @@ -378,7 +375,7 @@ public boolean isAnyChildSelected() {
*/
public void updateDataSet(List<T> items) {
animateTo(items);
initializeItems();
expandItemsAtStartUp();
showAllHeaders();
}

Expand Down Expand Up @@ -3249,7 +3246,7 @@ private void updateOrClearHeader() {
/* Triggered by notifyDataSetChanged() */
@Override
public void onChanged() {
initializeItems();
expandItemsAtStartUp();
updateOrClearHeader();
}

Expand Down

0 comments on commit 76b1aa1

Please sign in to comment.