-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
FirestorePagingAdapter setSnapshotArray #1750
Comments
Update: I did manage to use modify FirestorePagingAdapter and FirestorePagingOptions to use the existing LiveData from my ViewModel: ViewModel: private val config =
PagedList.Config.Builder()
.setEnablePlaceholders(false)
.setPrefetchDistance(2)
.setPageSize(2)
.build()
private val factoryPetShop = FirestoreDataSource.Factory(firestoreRepo.getPets(), Source.DEFAULT)
val liveDataPetShop = LivePagedListBuilder(factoryPetShop, config).build() FirestorePagingOptions: fun build(data : LiveData<PagedList<DocumentSnapshot>>, modelClass: Class<T>): FirestorePagingOptions<T> {
val parser = ClassSnapshotParser(modelClass)
return FirestorePagingOptions(data, ClassSnapshotParser(modelClass), DefaultSnapshotDiffCallback(parser), mOwner)
} I know this can be better, but this is just what I need for my app. But still, hoping this feature can be added. |
How did you extend FirestorePagingOptions if it is final? did you fetch and modified it? If yes how do you rebuild it to be a library into a project? |
Yep. Just copied the whole files into my project. I didn't rebuilt the libraries. |
Does this also solve the fact that the adapter re-fetches the data every time you leave and come back? I'm having tremendous trouble fixing this. Whenever I click an item and come back to the list, the query is re-run, same with orientation changes. |
It does it for me. The data set is saved and scroll position is restored. |
I see you use a FirestoreDataSource and pagedlist, can you share how you query to make the datasource work? Thanks! |
This has been released in |
Currently, I am using FirestoreRecyclerAdapter on my RecyclerViews to save their scroll positions upon fragment destroy (I use Android Jetpack Navigation Components).
This is how I do it: https://proandroiddev.com/fui-rv-state-a66833c3bb88
I want to switch to FirestorePagingAdapter to improve the performance of my app, but it seems that I cannot save my recyclerview's scroll positions because FirestorePagingAdapter always queries for the data upon start.
The text was updated successfully, but these errors were encountered: