Faltenreich / SkeletonLayout

Skeleton view pattern for Android
Apache License 2.0
505 stars 65 forks source link

Does not work with DiffUtill #28

Open Stashevskiy opened 3 years ago

Stashevskiy commented 3 years ago

Hello, I found that library does not work with DiffUtill. When a new list is added, it will scroll to the first position. Сould you fix this?

ajans commented 3 years ago

I don't think this has anything to do with DiffUtil. Try this before you set the adapter to the recyclerview:

In Kotlin:

        adapter.stateRestorationPolicy =
            RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY

In java:

        adapter.setStateRestorationPolicy(RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY);

If you get a compilation error, try updating the recyclerview-dependency to current version:

        implementation "androidx.recyclerview:recyclerview:1.2.0-beta01"