Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalidate() and refresh #4

Open
mbfakourii opened this issue Feb 18, 2020 · 8 comments
Open

invalidate() and refresh #4

mbfakourii opened this issue Feb 18, 2020 · 8 comments

Comments

@mbfakourii
Copy link

Hello when i use the invalidate() and RecyclerView is on the page for example 7 then the invalidate() is scrolled to page 2

 sourceFactory.usersDataSourceLiveData.value!!.invalidate()
@eternalBlast
Copy link

i got this issue too. Have you fixed this issue?

@mbfakourii
Copy link
Author

No, I haven't got anything yet but I realized this is a problem on the part of Google

@eternalBlast
Copy link

I think so. I tried to get the key from adapter.currentList.lastKey but always return null. I am trying another ways.

@eternalBlast
Copy link

Are you using PagedKeyedDataSource or ItemKeyedDataSource?

@mbfakourii
Copy link
Author

No, I didn't use it!
Did you solve the problem?

@eternalBlast
Copy link

I solved use some hacky solution :)
So, whenever I observed the network state, I scroll the recyclerview to top if the swipe refresh is in refreshing state. Here is the snippet:

yourViewModel.getNetworkState().observe(
            viewLifecycleOwner,
            androidx.lifecycle.Observer<NetworkState> {
                    if (bd.swipeRefreshLayout.isRefreshing)
                        bd.historyRV.smoothScrollToPosition(0)
                    bd.swipeRefreshLayout.isRefreshing = false
})

Please share if you have better solution.

@mbfakourii
Copy link
Author

I solved use some hacky solution :)
So, whenever I observed the network state, I scroll the recyclerview to top if the swipe refresh is in refreshing state. Here is the snippet:

yourViewModel.getNetworkState().observe(
            viewLifecycleOwner,
            androidx.lifecycle.Observer<NetworkState> {
                    if (bd.swipeRefreshLayout.isRefreshing)
                        bd.historyRV.smoothScrollToPosition(0)
                    bd.swipeRefreshLayout.isRefreshing = false
})

Please share if you have better solution.

I don't think it's a good way

@eternalBlast
Copy link

This solution is for temporary. Can you provide cleaner solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants