Package com.firebase.ui.database
Class FirebaseListAdapter<T>
- java.lang.Object
-
- android.widget.BaseAdapter
-
- com.firebase.ui.database.FirebaseListAdapter<T>
-
- Type Parameters:
T- The class type to use as a model for the data contained in the children of the given Firebase location
- All Implemented Interfaces:
Adapter,ListAdapter,SpinnerAdapter,androidx.lifecycle.LifecycleObserver,com.firebase.ui.common.BaseChangeEventListener<com.google.firebase.database.DataSnapshot,com.google.firebase.database.DatabaseError>,ChangeEventListener
public abstract class FirebaseListAdapter<T> extends BaseAdapter
-
-
Field Summary
Fields Modifier and Type Field Description protected intmLayout-
Fields inherited from interface android.widget.Adapter
IGNORE_ITEM_VIEW_TYPE, NO_SELECTION
-
-
Constructor Summary
Constructors Constructor Description FirebaseListAdapter(FirebaseListOptions<T> options)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intgetCount()TgetItem(int position)longgetItemId(int i)com.google.firebase.database.DatabaseReferencegetRef(int position)ObservableSnapshotArray<T>getSnapshots()ViewgetView(int position, View convertView, ViewGroup parent)voidonChildChanged(com.firebase.ui.common.ChangeEventType type, com.google.firebase.database.DataSnapshot snapshot, int newIndex, int oldIndex)voidonDataChanged()voidonError(com.google.firebase.database.DatabaseError error)protected abstract voidpopulateView(View v, T model, int position)Each time the data at the given Firebase location changes, this method will be called for each item that needs to be displayed.voidstartListening()voidstopListening()-
Methods inherited from class android.widget.BaseAdapter
areAllItemsEnabled, getAutofillOptions, getDropDownView, getItemViewType, getViewTypeCount, hasStableIds, isEmpty, isEnabled, notifyDataSetChanged, notifyDataSetInvalidated, registerDataSetObserver, setAutofillOptions, unregisterDataSetObserver
-
-
-
-
Constructor Detail
-
FirebaseListAdapter
public FirebaseListAdapter(@NonNull FirebaseListOptions<T> options)
-
-
Method Detail
-
startListening
public void startListening()
-
stopListening
public void stopListening()
-
onChildChanged
public void onChildChanged(@NonNull com.firebase.ui.common.ChangeEventType type, @NonNull com.google.firebase.database.DataSnapshot snapshot, int newIndex, int oldIndex)- Specified by:
onChildChangedin interfacecom.firebase.ui.common.BaseChangeEventListener<com.google.firebase.database.DataSnapshot,com.google.firebase.database.DatabaseError>
-
onDataChanged
public void onDataChanged()
- Specified by:
onDataChangedin interfacecom.firebase.ui.common.BaseChangeEventListener<com.google.firebase.database.DataSnapshot,com.google.firebase.database.DatabaseError>
-
onError
public void onError(@NonNull com.google.firebase.database.DatabaseError error)- Specified by:
onErrorin interfacecom.firebase.ui.common.BaseChangeEventListener<com.google.firebase.database.DataSnapshot,com.google.firebase.database.DatabaseError>
-
getSnapshots
@NonNull public ObservableSnapshotArray<T> getSnapshots()
-
getRef
@NonNull public com.google.firebase.database.DatabaseReference getRef(int position)
-
getView
@NonNull public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent)
-
populateView
protected abstract void populateView(@NonNull View v, @NonNull T model, int position)Each time the data at the given Firebase location changes, this method will be called for each item that needs to be displayed. The first two arguments correspond to the mLayout and mModelClass given to the constructor of this class. The third argument is the item's position in the list.Your implementation should populate the view using the data contained in the model.
- Parameters:
v- The view to populatemodel- The object containing the data used to populate the viewposition- The position in the list of the view being populated
-
-