Class FirestoreDataSource


  • public class FirestoreDataSource
    extends androidx.paging.PageKeyedDataSource<PageKey,​com.google.firebase.firestore.DocumentSnapshot>
    Data source to power a FirestorePagingAdapter. Note: although loadInitial, loadBefore, and loadAfter are not called on the main thread by the paging library, we treat them as if they were so that we can facilitate retry without managing our own thread pool or requiring the user to pass us an executor.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  FirestoreDataSource.Factory  
      • Nested classes/interfaces inherited from class androidx.paging.PageKeyedDataSource

        androidx.paging.PageKeyedDataSource.LoadCallback<Key extends java.lang.Object,​Value extends java.lang.Object>, androidx.paging.PageKeyedDataSource.LoadInitialCallback<Key extends java.lang.Object,​Value extends java.lang.Object>, androidx.paging.PageKeyedDataSource.LoadInitialParams<Key extends java.lang.Object>, androidx.paging.PageKeyedDataSource.LoadParams<Key extends java.lang.Object>
      • Nested classes/interfaces inherited from class androidx.paging.DataSource

        androidx.paging.DataSource.InvalidatedCallback
    • Constructor Summary

      Constructors 
      Constructor Description
      FirestoreDataSource​(com.google.firebase.firestore.Query baseQuery, com.google.firebase.firestore.Source source)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      androidx.lifecycle.LiveData<java.lang.Exception> getLastError()  
      androidx.lifecycle.LiveData<LoadingState> getLoadingState()  
      void loadAfter​(androidx.paging.PageKeyedDataSource.LoadParams<PageKey> params, androidx.paging.PageKeyedDataSource.LoadCallback<PageKey,​com.google.firebase.firestore.DocumentSnapshot> callback)  
      void loadBefore​(androidx.paging.PageKeyedDataSource.LoadParams<PageKey> params, androidx.paging.PageKeyedDataSource.LoadCallback<PageKey,​com.google.firebase.firestore.DocumentSnapshot> callback)  
      void loadInitial​(androidx.paging.PageKeyedDataSource.LoadInitialParams<PageKey> params, androidx.paging.PageKeyedDataSource.LoadInitialCallback<PageKey,​com.google.firebase.firestore.DocumentSnapshot> callback)  
      void retry()  
      • Methods inherited from class androidx.paging.PageKeyedDataSource

        map, mapByPage
      • Methods inherited from class androidx.paging.DataSource

        addInvalidatedCallback, invalidate, isInvalid, removeInvalidatedCallback
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FirestoreDataSource

        public FirestoreDataSource​(@NonNull
                                   com.google.firebase.firestore.Query baseQuery,
                                   @NonNull
                                   com.google.firebase.firestore.Source source)
    • Method Detail

      • loadInitial

        public void loadInitial​(@NonNull
                                androidx.paging.PageKeyedDataSource.LoadInitialParams<PageKey> params,
                                @NonNull
                                androidx.paging.PageKeyedDataSource.LoadInitialCallback<PageKey,​com.google.firebase.firestore.DocumentSnapshot> callback)
        Specified by:
        loadInitial in class androidx.paging.PageKeyedDataSource<PageKey,​com.google.firebase.firestore.DocumentSnapshot>
      • loadBefore

        public void loadBefore​(@NonNull
                               androidx.paging.PageKeyedDataSource.LoadParams<PageKey> params,
                               @NonNull
                               androidx.paging.PageKeyedDataSource.LoadCallback<PageKey,​com.google.firebase.firestore.DocumentSnapshot> callback)
        Specified by:
        loadBefore in class androidx.paging.PageKeyedDataSource<PageKey,​com.google.firebase.firestore.DocumentSnapshot>
      • loadAfter

        public void loadAfter​(@NonNull
                              androidx.paging.PageKeyedDataSource.LoadParams<PageKey> params,
                              @NonNull
                              androidx.paging.PageKeyedDataSource.LoadCallback<PageKey,​com.google.firebase.firestore.DocumentSnapshot> callback)
        Specified by:
        loadAfter in class androidx.paging.PageKeyedDataSource<PageKey,​com.google.firebase.firestore.DocumentSnapshot>
      • getLoadingState

        @NonNull
        public androidx.lifecycle.LiveData<LoadingState> getLoadingState()
      • getLastError

        @NonNull
        public androidx.lifecycle.LiveData<java.lang.Exception> getLastError()
      • retry

        public void retry()