ExpansionPanel icon indicating copy to clipboard operation
ExpansionPanel copied to clipboard

ExpansionLayout do not save expanded state

Open JRoot3D opened this issue 7 years ago • 22 comments

Any android component with ID can save own state.

JRoot3D avatar Feb 16 '18 10:02 JRoot3D

so, add id on it ?

florent37 avatar Feb 23 '18 20:02 florent37

and this doesn't work.

JRoot3D avatar Feb 23 '18 20:02 JRoot3D

check in you example app. Headers and layouts with id but when screen rotate layout is back to initial state...

JRoot3D avatar Feb 23 '18 21:02 JRoot3D

Oh ok, i juste have tout handle onSaveInstanceState

Le 23 févr. 2018 22:26, "Alex" [email protected] a écrit :

check in you example app. Headers and layouts with id but when screen rotate layout is back to initial state...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/florent37/ExpansionPanel/issues/14#issuecomment-368143011, or mute the thread https://github.com/notifications/unsubscribe-auth/AFfQXAwLt6oOQn4KNJm_hLPDEBkzLpnZks5tXyztgaJpZM4SIIQZ .

florent37 avatar Feb 24 '18 06:02 florent37

I added this into 1.0.9 can you try ?

florent37 avatar Feb 24 '18 18:02 florent37

its partially work, after rotating expanded state is saved but then can't collapse view

JRoot3D avatar Feb 24 '18 18:02 JRoot3D

expansionLayout is null after call setup() from onRestoreInstanceState(...)

JRoot3D avatar Feb 24 '18 19:02 JRoot3D

Ok, will fix it

Le 24 févr. 2018 20:16, "Alex" [email protected] a écrit :

expansionLayout is null after call setup() from onRestoreInstanceState(...)

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/florent37/ExpansionPanel/issues/14#issuecomment-368252229, or mute the thread https://github.com/notifications/unsubscribe-auth/AFfQXG5DGP3jGeNUqOBYo2yjCMO_P1Ehks5tYF_xgaJpZM4SIIQZ .

florent37 avatar Feb 25 '18 07:02 florent37

Problem with the call to restore super state. I fix this with extends View.BaseSavedState. But found another bug, when header use identical id's in View or RecuclerView, in this case, state is single for all headers.

JRoot3D avatar Feb 25 '18 09:02 JRoot3D

I'm on this now

2018-02-25 10:21 GMT+01:00 Alex [email protected]:

Problem with the call to restore super state. I fix this with extends View.BaseSavedState. But found another bug, when header use identical id's in View or RecuclerView, in this case, state is single for all headers.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/florent37/ExpansionPanel/issues/14#issuecomment-368295004, or mute the thread https://github.com/notifications/unsubscribe-auth/AFfQXFiAM24PZgtDc9hJIrOm4OK79liXks5tYSY1gaJpZM4SIIQZ .

florent37 avatar Feb 25 '18 09:02 florent37

I fixed the saved/restore instance, but yes I have the same bug as you : if all the views have the same Identfier... I've got the same restored instance

2018-02-25 10:24 GMT+01:00 Florent Champigny [email protected]:

I'm on this now

2018-02-25 10:21 GMT+01:00 Alex [email protected]:

Problem with the call to restore super state. I fix this with extends View.BaseSavedState. But found another bug, when header use identical id's in View or RecuclerView, in this case, state is single for all headers.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/florent37/ExpansionPanel/issues/14#issuecomment-368295004, or mute the thread https://github.com/notifications/unsubscribe-auth/AFfQXFiAM24PZgtDc9hJIrOm4OK79liXks5tYSY1gaJpZM4SIIQZ .

florent37 avatar Feb 25 '18 09:02 florent37

but with differents id, it will work

2018-02-25 10:32 GMT+01:00 Florent Champigny [email protected]:

I fixed the saved/restore instance, but yes I have the same bug as you : if all the views have the same Identfier... I've got the same restored instance

2018-02-25 10:24 GMT+01:00 Florent Champigny [email protected] :

I'm on this now

2018-02-25 10:21 GMT+01:00 Alex [email protected]:

Problem with the call to restore super state. I fix this with extends View.BaseSavedState. But found another bug, when header use identical id's in View or RecuclerView, in this case, state is single for all headers.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/florent37/ExpansionPanel/issues/14#issuecomment-368295004, or mute the thread https://github.com/notifications/unsubscribe-auth/AFfQXFiAM24PZgtDc9hJIrOm4OK79liXks5tYSY1gaJpZM4SIIQZ .

florent37 avatar Feb 25 '18 09:02 florent37

for RecyclerView this is important

JRoot3D avatar Feb 25 '18 09:02 JRoot3D

you've got an idea how to fix it ?

florent37 avatar Feb 25 '18 12:02 florent37

because on RecyclerView, each view can have same ids

florent37 avatar Feb 25 '18 12:02 florent37

currently, no...

JRoot3D avatar Feb 25 '18 12:02 JRoot3D

Can you release latest fixes?

JRoot3D avatar Feb 26 '18 14:02 JRoot3D

I already pushed it un 1.0.2, Can you clean the gradle cache for this lib ?

Le 26 févr. 2018 15:48, "Alex" [email protected] a écrit :

Can you release latest fixes?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/florent37/ExpansionPanel/issues/14#issuecomment-368526607, or mute the thread https://github.com/notifications/unsubscribe-auth/AFfQXNbIHS0AcybcSoHsQaaFxm3p3Jhkks5tYsQogaJpZM4SIIQZ .

florent37 avatar Feb 26 '18 15:02 florent37

If you can't i will publish a 1.0.3

Le 26 févr. 2018 16:34, "Florent Champigny" [email protected] a écrit :

I already pushed it un 1.0.2, Can you clean the gradle cache for this lib ?

Le 26 févr. 2018 15:48, "Alex" [email protected] a écrit :

Can you release latest fixes?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/florent37/ExpansionPanel/issues/14#issuecomment-368526607, or mute the thread https://github.com/notifications/unsubscribe-auth/AFfQXNbIHS0AcybcSoHsQaaFxm3p3Jhkks5tYsQogaJpZM4SIIQZ .

florent37 avatar Feb 26 '18 15:02 florent37

How can we fix this in recyclerview? If i expand several panels, press the home button and come back, everything is reset

broakenmedia avatar Apr 26 '18 14:04 broakenmedia

I think that for the recyclerview it is best to implement something like this:

In Recyclerview the following article can be adapted Android: Handling Checkbox state in Recycler Views.

Use SparseBooleanArray for save state each expandable state

private SparseBooleanArray itemStateArray= new SparseBooleanArray();

Detect expandable state in Viewholder

expansionLayout.addListener(new ExpansionLayout.Listener() {
    @Override
    public void onExpansionChanged(ExpansionLayout expansionLayout, boolean expanded) {
            itemStateArray.put(adapterPosition, true);
    }
});

webserveis avatar Mar 07 '19 14:03 webserveis

https://stackoverflow.com/questions/35424232/issue-refreshing-a-view-of-a-row-in-recyclerview?rq=1 This may help to avoid recreating all views and your state will not be changed. You can update only specific view that you need.

M0N3 avatar May 31 '19 11:05 M0N3