TonicArtos / SuperSLiM

A layout manager for the RecyclerView with interchangeable linear, grid, and staggered displays of views, all with configurable section headers including the sticky variety as specified in the material design docs.
http://tonicartos.nz
2.12k stars 296 forks source link

Scroll position is not persistent during rotation #106

Closed woxblom closed 7 years ago

woxblom commented 9 years ago

If I scroll down to item 15 for example and then rotate the screen the scroll position is reset and back to 0. It works if I use the standard LinearLayoutManager.

I can see that the scrollposition is saved in onSaveInstanceState and restored in onRestoreInstanceState but the mRequestPosition is set to -1 in onItemsChanged before it has been used or any children has been laid out.

TonicArtos commented 9 years ago

So I take it that you have a data change which is clearing the position that is to be restored.

woxblom commented 9 years ago

When I rotate onCreateView will be called again and the onLoadFinished where my loader delivers the result. I need to set the data on the adapter again when rotating, this works fine with the standard LinearLayoutManager and also works fine with a ListView solution. Feels like the superslim layoutmanager does not handle the rotate in a correct way somehow as the standard layout manager handles it.

Does it work for you to keep the scroll position on rotate with superslim? In that case how do you set the data again after rotate?

TonicArtos commented 9 years ago

At the moment, setting a new adapter will cause the layout state in SuperSLiM to be lost.

OFmarting commented 9 years ago

Is it planned to support configuration changes?

TonicArtos commented 9 years ago

The example app doesn't have this problem and persists its position through configuration changes.