Package 

Class FirebaseRecyclerAdapter

  • All Implemented Interfaces:
    androidx.lifecycle.LifecycleObserver , com.firebase.ui.common.BaseChangeEventListener , com.firebase.ui.database.ChangeEventListener , com.firebase.ui.database.FirebaseAdapter

    
    public abstract class FirebaseRecyclerAdapter<T, VH extends RecyclerView.ViewHolder>
    extends RecyclerView.Adapter<VH> implements FirebaseAdapter<T>
                        

    This class is a generic way of backing a RecyclerView with a Firebase location. It handles all of the child events at the given Firebase location and marshals received data into the given class type.

    See the READMEfor an in-depth tutorial on how to set up the FirebaseRecyclerAdapter.

    • Method Summary

      Modifier and Type Method Description
      void startListening() Start listening for database changes and populate the adapter.
      void stopListening() Stop listening for database changes and clear all items in the adapter.
      void onChildChanged(@NonNull() ChangeEventType type, @NonNull() DataSnapshot snapshot, int newIndex, int oldIndex)
      void onDataChanged()
      void onError(@NonNull() DatabaseError error)
      ObservableSnapshotArray<T> getSnapshots() Returns the backing ObservableSnapshotArray used to populate this adapter.
      T getItem(int position) Gets the item at the specified position from the backing snapshot array.
      DatabaseReference getRef(int position) Returns the reference at the specified position in this list.
      int getItemCount()
      void updateOptions(@NonNull() FirebaseRecyclerOptions<T> options) Re-initialize the Adapter with a new set of options.
      void onBindViewHolder(@NonNull() VH holder, int position)
      • Methods inherited from class androidx.recyclerview.widget.RecyclerView.Adapter

        bindViewHolder, createViewHolder, findRelativeAdapterPositionIn, getItemCount, getItemId, getItemViewType, getStateRestorationPolicy, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onCreateViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, setStateRestorationPolicy, unregisterAdapterDataObserver
      • Methods inherited from class com.firebase.ui.common.BaseChangeEventListener

        onChildChanged, onDataChanged, onError
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait