setStateRestorationPolicy
Sets the state restoration strategy for the Adapter. By default, it is set to ALLOW which means RecyclerView expects any set Adapter to be immediately capable of restoring the RecyclerView's saved scroll position.
This behaviour might be undesired if the Adapter's data is loaded asynchronously, and thus unavailable during initial layout (e.g. after Activity rotation). To avoid losing scroll position, you can change this to be either PREVENT_WHEN_EMPTY or PREVENT. Note that the former means your RecyclerView will restore state as soon as Adapter has 1 or more items while the latter requires you to call setStateRestorationPolicy with either ALLOW or PREVENT_WHEN_EMPTY again when the Adapter is ready to restore its state.
RecyclerView will still layout even when State restoration is disabled. The behavior of how State is restored is up to the LayoutManager. All default LayoutManagers will override current state with restored state when state restoration happens (unless an explicit call to scrollToPosition is made).
Calling this method after state is restored will not have any effect other than changing the return value of getStateRestorationPolicy.
Parameters
The saved state restoration strategy for this Adapter.