Package com.firebase.ui.firestore.paging
Class FirestorePagingAdapter<T,VH extends androidx.recyclerview.widget.RecyclerView.ViewHolder>
- java.lang.Object
-
- androidx.recyclerview.widget.RecyclerView.Adapter<VH>
-
- androidx.paging.PagedListAdapter<com.google.firebase.firestore.DocumentSnapshot,VH>
-
- com.firebase.ui.firestore.paging.FirestorePagingAdapter<T,VH>
-
- All Implemented Interfaces:
androidx.lifecycle.LifecycleObserver
public abstract class FirestorePagingAdapter<T,VH extends androidx.recyclerview.widget.RecyclerView.ViewHolder> extends androidx.paging.PagedListAdapter<com.google.firebase.firestore.DocumentSnapshot,VH> implements androidx.lifecycle.LifecycleObserverPaginated RecyclerView Adapter for a Cloud Firestore query. Configured withFirestorePagingOptions.
-
-
Constructor Summary
Constructors Constructor Description FirestorePagingAdapter(FirestorePagingOptions<T> options)Construct a new FirestorePagingAdapter from the givenFirestorePagingOptions.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidonBindViewHolder(VH holder, int position)protected abstract voidonBindViewHolder(VH holder, int position, T model)protected voidonError(java.lang.Exception e)Called whenever theExceptionis caught.protected voidonLoadingStateChanged(LoadingState state)Called whenever the loading state of the adapter changes.voidrefresh()To attempt to refresh the list.voidretry()IfonLoadingStateChanged(LoadingState)indicates error state, call this method to attempt to retry the most recent failure.voidstartListening()Start listening to paging / scrolling events and populating adapter data.voidstopListening()Unsubscribe from paging / scrolling events, no more data will be populated, but the existing data will remain.voidupdateOptions(FirestorePagingOptions<T> options)Re-initialize the Adapter with a new set of options.-
Methods inherited from class androidx.paging.PagedListAdapter
getCurrentList, getItem, getItemCount, onCurrentListChanged, onCurrentListChanged, submitList, submitList
-
Methods inherited from class androidx.recyclerview.widget.RecyclerView.Adapter
bindViewHolder, createViewHolder, getItemId, getItemViewType, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onCreateViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserver
-
-
-
-
Constructor Detail
-
FirestorePagingAdapter
public FirestorePagingAdapter(@NonNull FirestorePagingOptions<T> options)Construct a new FirestorePagingAdapter from the givenFirestorePagingOptions.
-
-
Method Detail
-
retry
public void retry()
IfonLoadingStateChanged(LoadingState)indicates error state, call this method to attempt to retry the most recent failure.
-
refresh
public void refresh()
To attempt to refresh the list. It will reload the list from beginning.
-
updateOptions
public void updateOptions(@NonNull FirestorePagingOptions<T> options)Re-initialize the Adapter with a new set of options. Can be used to change the query without re-constructing the entire adapter.
-
startListening
public void startListening()
Start listening to paging / scrolling events and populating adapter data.
-
stopListening
public void stopListening()
Unsubscribe from paging / scrolling events, no more data will be populated, but the existing data will remain.
-
onBindViewHolder
public void onBindViewHolder(@NonNull VH holder, int position)- Specified by:
onBindViewHolderin classandroidx.recyclerview.widget.RecyclerView.Adapter<VH extends androidx.recyclerview.widget.RecyclerView.ViewHolder>
-
onBindViewHolder
protected abstract void onBindViewHolder(@NonNull VH holder, int position, @NonNull T model)- Parameters:
model- the model object containing the data that should be used to populate the view.- See Also:
onBindViewHolder(RecyclerView.ViewHolder, int)
-
onLoadingStateChanged
protected void onLoadingStateChanged(@NonNull LoadingState state)Called whenever the loading state of the adapter changes.When the state is
LoadingState.ERRORthe adapter will stop loading any data unlessretry()is called.
-
onError
protected void onError(@NonNull java.lang.Exception e)Called whenever theExceptionis caught.When
Exceptionis caught the adapter will stop loading any data
-
-