code
stringlengths
23
201k
docstring
stringlengths
17
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
72
path
stringlengths
11
317
url
stringlengths
57
377
license
stringclasses
7 values
@CallSuper protected void onDestroy() { mHasDataChanged = false; getSnapshots().clear(); mCachingParser.clear(); }
Called when the {@link BaseObservableSnapshotArray} is inactive and should stop listening to the Firebase database. <p> All data and saved state should also be cleared here.
onDestroy
java
firebase/FirebaseUI-Android
common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java
Apache-2.0
public boolean isListening() { return !mListeners.isEmpty(); }
@return true if the array is listening for change events from the Firebase database, false otherwise
isListening
java
firebase/FirebaseUI-Android
common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java
Apache-2.0
public boolean isListening(@NonNull L listener) { return mListeners.contains(listener); }
@return true if the provided listener is listening for changes
isListening
java
firebase/FirebaseUI-Android
common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java
Apache-2.0
public void clear() { getSnapshots().clear(); notifyOnDataChanged(); }
Clear data and notify all listeners.
clear
java
firebase/FirebaseUI-Android
common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java
Apache-2.0
protected final void notifyOnChildChanged(@NonNull ChangeEventType type, @NonNull S snapshot, int newIndex, int oldIndex) { if (type == ChangeEventType.CHANGED || type == Cha...
Clear data and notify all listeners.
notifyOnChildChanged
java
firebase/FirebaseUI-Android
common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java
Apache-2.0
protected final void notifyOnDataChanged() { mHasDataChanged = true; for (L listener : mListeners) { listener.onDataChanged(); } }
Clear data and notify all listeners.
notifyOnDataChanged
java
firebase/FirebaseUI-Android
common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java
Apache-2.0
protected final void notifyOnError(@NonNull E e) { for (L listener : mListeners) { listener.onError(e); } }
Clear data and notify all listeners.
notifyOnError
java
firebase/FirebaseUI-Android
common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/BaseObservableSnapshotArray.java
Apache-2.0
@NonNull public static <T> T checkNotNull(@Nullable T o) { if (o == null) throw new IllegalArgumentException("Argument cannot be null."); return o; }
Convenience class for checking argument conditions.
checkNotNull
java
firebase/FirebaseUI-Android
common/src/main/java/com/firebase/ui/common/Preconditions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/Preconditions.java
Apache-2.0
public static void assertNull(@Nullable Object object, @NonNull String message) { if (object != null) { throw new RuntimeException(message); } }
Convenience class for checking argument conditions.
assertNull
java
firebase/FirebaseUI-Android
common/src/main/java/com/firebase/ui/common/Preconditions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/Preconditions.java
Apache-2.0
public static void assertNonNull(@Nullable Object object, @NonNull String message) { if (object == null) { throw new RuntimeException(message); } }
Convenience class for checking argument conditions.
assertNonNull
java
firebase/FirebaseUI-Android
common/src/main/java/com/firebase/ui/common/Preconditions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/common/src/main/java/com/firebase/ui/common/Preconditions.java
Apache-2.0
@NonNull @Override public String getId(@NonNull DataSnapshot snapshot) { return snapshot.getKey(); }
Implementation of {@link BaseCachingSnapshotParser} for {@link DataSnapshot}.
getId
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/CachingSnapshotParser.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/CachingSnapshotParser.java
Apache-2.0
@Nullable @Override public T parseSnapshot(@NonNull DataSnapshot snapshot) { // In FirebaseUI controlled usages, we can guarantee that our getValue calls will be nonnull // because we check for nullity with ValueEventListeners and use ChildEventListeners. // However, since this API is pu...
A convenience implementation of {@link SnapshotParser} that converts a {@link DataSnapshot} to the parametrized class via {@link DataSnapshot#getValue(Class)}. @param <T> the POJO class to create from snapshots.
parseSnapshot
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/ClassSnapshotParser.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/ClassSnapshotParser.java
Apache-2.0
private boolean isKeyAtIndex(String key, int index) { return index >= 0 && index < size() && mDataSnapshots.get(index).getKey().equals(key); }
Determines if a DataSnapshot with the given key is present at the given index.
isKeyAtIndex
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseIndexArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseIndexArray.java
Apache-2.0
private void onKeyAdded(DataSnapshot data, int newIndex) { String key = data.getKey(); DatabaseReference ref = mDataRef.child(key); mKeysWithPendingUpdate.add(key); // Start listening mRefs.put(ref, ref.addValueEventListener(new DataRefListener(newIndex))); }
Determines if a DataSnapshot with the given key is present at the given index.
onKeyAdded
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseIndexArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseIndexArray.java
Apache-2.0
private void onKeyMoved(DataSnapshot data, int index, int oldIndex) { String key = data.getKey(); // We can't use `returnOrFindIndexForKey(...)` for `oldIndex` or it might find the updated // index instead of the old one. Unfortunately, this does mean move events will be // incorrectly ...
Determines if a DataSnapshot with the given key is present at the given index.
onKeyMoved
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseIndexArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseIndexArray.java
Apache-2.0
private void onKeyRemoved(DataSnapshot data, int index) { String key = data.getKey(); ValueEventListener listener = mRefs.remove(mDataRef.getRef().child(key)); if (listener != null) mDataRef.child(key).removeEventListener(listener); int realIndex = returnOrFindIndexForKey(index, key); ...
Determines if a DataSnapshot with the given key is present at the given index.
onKeyRemoved
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseIndexArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseIndexArray.java
Apache-2.0
@Override public void onDataChange(DataSnapshot snapshot) { String key = snapshot.getKey(); int index = currentIndex = returnOrFindIndexForKey(currentIndex, key); if (snapshot.getValue() != null) { if (isKeyAtIndex(key, index)) { // We alr...
Cached index to skip searching for the current index on each update
onDataChange
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseIndexArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseIndexArray.java
Apache-2.0
@Override public void onCancelled(DatabaseError error) { notifyOnError(error); }
Cached index to skip searching for the current index on each update
onCancelled
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseIndexArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseIndexArray.java
Apache-2.0
@Override @OnLifecycleEvent(Lifecycle.Event.ON_START) public void startListening() { if (!mSnapshots.isListening(this)) { mSnapshots.addChangeEventListener(this); } }
This class is a generic way of backing an Android {@link android.widget.ListView} with a Firebase location. It handles all of the child events at the given Firebase location. It marshals received data into the given class type. <p> See the <a href="https://github.com/firebase/FirebaseUI-Android/blob/master/database/REA...
startListening
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
Apache-2.0
@Override @OnLifecycleEvent(Lifecycle.Event.ON_STOP) public void stopListening() { mSnapshots.removeChangeEventListener(this); notifyDataSetChanged(); }
This class is a generic way of backing an Android {@link android.widget.ListView} with a Firebase location. It handles all of the child events at the given Firebase location. It marshals received data into the given class type. <p> See the <a href="https://github.com/firebase/FirebaseUI-Android/blob/master/database/REA...
stopListening
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
Apache-2.0
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) void cleanup(LifecycleOwner source) { source.getLifecycle().removeObserver(this); }
This class is a generic way of backing an Android {@link android.widget.ListView} with a Firebase location. It handles all of the child events at the given Firebase location. It marshals received data into the given class type. <p> See the <a href="https://github.com/firebase/FirebaseUI-Android/blob/master/database/REA...
cleanup
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
Apache-2.0
@Override public void onChildChanged(@NonNull ChangeEventType type, @NonNull DataSnapshot snapshot, int newIndex, int oldIndex) { notifyDataSetChanged(); }
This class is a generic way of backing an Android {@link android.widget.ListView} with a Firebase location. It handles all of the child events at the given Firebase location. It marshals received data into the given class type. <p> See the <a href="https://github.com/firebase/FirebaseUI-Android/blob/master/database/REA...
onChildChanged
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
Apache-2.0
@Override public void onDataChanged() { }
This class is a generic way of backing an Android {@link android.widget.ListView} with a Firebase location. It handles all of the child events at the given Firebase location. It marshals received data into the given class type. <p> See the <a href="https://github.com/firebase/FirebaseUI-Android/blob/master/database/REA...
onDataChanged
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
Apache-2.0
@Override public void onError(@NonNull DatabaseError error) { Log.w(TAG, error.toException()); }
This class is a generic way of backing an Android {@link android.widget.ListView} with a Firebase location. It handles all of the child events at the given Firebase location. It marshals received data into the given class type. <p> See the <a href="https://github.com/firebase/FirebaseUI-Android/blob/master/database/REA...
onError
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
Apache-2.0
@NonNull @Override public ObservableSnapshotArray<T> getSnapshots() { return mSnapshots; }
This class is a generic way of backing an Android {@link android.widget.ListView} with a Firebase location. It handles all of the child events at the given Firebase location. It marshals received data into the given class type. <p> See the <a href="https://github.com/firebase/FirebaseUI-Android/blob/master/database/REA...
getSnapshots
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
Apache-2.0
@NonNull @Override public T getItem(int position) { return mSnapshots.get(position); }
This class is a generic way of backing an Android {@link android.widget.ListView} with a Firebase location. It handles all of the child events at the given Firebase location. It marshals received data into the given class type. <p> See the <a href="https://github.com/firebase/FirebaseUI-Android/blob/master/database/REA...
getItem
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
Apache-2.0
@NonNull @Override public DatabaseReference getRef(int position) { return mSnapshots.getSnapshot(position).getRef(); }
This class is a generic way of backing an Android {@link android.widget.ListView} with a Firebase location. It handles all of the child events at the given Firebase location. It marshals received data into the given class type. <p> See the <a href="https://github.com/firebase/FirebaseUI-Android/blob/master/database/REA...
getRef
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
Apache-2.0
@Override public int getCount() { return mSnapshots.size(); }
This class is a generic way of backing an Android {@link android.widget.ListView} with a Firebase location. It handles all of the child events at the given Firebase location. It marshals received data into the given class type. <p> See the <a href="https://github.com/firebase/FirebaseUI-Android/blob/master/database/REA...
getCount
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
Apache-2.0
@Override public long getItemId(int i) { // http://stackoverflow.com/questions/5100071/whats-the-purpose-of-item-ids-in-android-listview-adapter return mSnapshots.getSnapshot(i).getKey().hashCode(); }
This class is a generic way of backing an Android {@link android.widget.ListView} with a Firebase location. It handles all of the child events at the given Firebase location. It marshals received data into the given class type. <p> See the <a href="https://github.com/firebase/FirebaseUI-Android/blob/master/database/REA...
getItemId
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
Apache-2.0
@Override @NonNull public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(parent.getContext()).inflate(mLayout, parent, false); } T model = getItem(position); // Call ou...
This class is a generic way of backing an Android {@link android.widget.ListView} with a Firebase location. It handles all of the child events at the given Firebase location. It marshals received data into the given class type. <p> See the <a href="https://github.com/firebase/FirebaseUI-Android/blob/master/database/REA...
getView
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java
Apache-2.0
@NonNull public ObservableSnapshotArray<T> getSnapshots() { return mSnapshots; }
Get the {@link ObservableSnapshotArray} to observe.
getSnapshots
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
Apache-2.0
@LayoutRes public int getLayout() { return mLayout; }
Get the resource ID of the layout file for a list item.
getLayout
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
Apache-2.0
@NonNull public Builder<T> setSnapshotArray(@NonNull ObservableSnapshotArray<T> snapshots) { assertNull(mSnapshots, ERR_SNAPSHOTS_SET); mSnapshots = snapshots; return this; }
Directly set the {@link ObservableSnapshotArray} to observe. <p> Do not call this method after calling {@code setQuery}.
setSnapshotArray
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
Apache-2.0
@NonNull public Builder<T> setQuery(@NonNull Query query, @NonNull SnapshotParser<T> parser) { assertNull(mSnapshots, ERR_SNAPSHOTS_SET); mSnapshots = new FirebaseArray<>(query, parser); return this; }
Set the query to listen on and a {@link SnapshotParser} to parse data snapshots. <p> Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArray)}.
setQuery
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
Apache-2.0
@NonNull public Builder<T> setQuery(@NonNull Query query, @NonNull Class<T> modelClass) { return setQuery(query, new ClassSnapshotParser<>(modelClass)); }
Set the query to listen on and a {@link Class} to which data snapshots should be converted. Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArray)}.
setQuery
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
Apache-2.0
@NonNull public Builder<T> setIndexedQuery(@NonNull Query keyQuery, @NonNull DatabaseReference dataRef, @NonNull SnapshotParser<T> parser) { assertNull(mSnapshots, ERR_SNAPSHOTS_SET); mSnapshots = new Fi...
Set an indexed query to listen on and a {@link SnapshotParser} to parse data snapshots. The keyQuery is used to find a list of IDs, which are then queried at the dataRef. <p> Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArray)}.
setIndexedQuery
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
Apache-2.0
@NonNull public Builder<T> setIndexedQuery(@NonNull Query keyQuery, @NonNull DatabaseReference dataRef, @NonNull Class<T> modelClass) { return setIndexedQuery(keyQuery, dataRef, new ClassSnapshotParser<>(modelClass))...
Set an indexed query to listen on and a {@link Class} to which data snapshots should be converted. The keyQuery is used to find a list of keys, which are then queried at the dataRef. <p> Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArray)}.
setIndexedQuery
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
Apache-2.0
@NonNull public Builder<T> setLayout(@LayoutRes int layout) { mLayout = layout; return this; }
Set the resource ID for the item layout.
setLayout
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
Apache-2.0
@NonNull public Builder<T> setLifecycleOwner(@Nullable LifecycleOwner owner) { mOwner = owner; return this; }
Set the optional {@link LifecycleOwner}. Listening will stop/start after the appropriate lifecycle events.
setLifecycleOwner
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
Apache-2.0
@NonNull public FirebaseListOptions<T> build() { assertNonNull(mSnapshots, "Snapshot array cannot be null. " + "Call setQuery or setSnapshotArray."); assertNonNull(mLayout, "Layout cannot be null. " + "Call setLayout."); return new Fir...
Build a {@link FirebaseListOptions} from the provided arguments.
build
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseListOptions.java
Apache-2.0
@Override @OnLifecycleEvent(Lifecycle.Event.ON_START) public void startListening() { if (!mSnapshots.isListening(this)) { mSnapshots.addChangeEventListener(this); } }
Initialize a {@link RecyclerView.Adapter} that listens to a Firebase query. See {@link FirebaseRecyclerOptions} for configuration options.
startListening
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
Apache-2.0
@Override @OnLifecycleEvent(Lifecycle.Event.ON_STOP) public void stopListening() { mSnapshots.removeChangeEventListener(this); }
Initialize a {@link RecyclerView.Adapter} that listens to a Firebase query. See {@link FirebaseRecyclerOptions} for configuration options.
stopListening
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
Apache-2.0
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) void cleanup(LifecycleOwner source) { source.getLifecycle().removeObserver(this); }
Initialize a {@link RecyclerView.Adapter} that listens to a Firebase query. See {@link FirebaseRecyclerOptions} for configuration options.
cleanup
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
Apache-2.0
@Override public void onChildChanged(@NonNull ChangeEventType type, @NonNull DataSnapshot snapshot, int newIndex, int oldIndex) { switch (type) { case ADDED: notifyItemInserted(newIndex);...
Initialize a {@link RecyclerView.Adapter} that listens to a Firebase query. See {@link FirebaseRecyclerOptions} for configuration options.
onChildChanged
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
Apache-2.0
@Override public void onDataChanged() { }
Initialize a {@link RecyclerView.Adapter} that listens to a Firebase query. See {@link FirebaseRecyclerOptions} for configuration options.
onDataChanged
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
Apache-2.0
@Override public void onError(@NonNull DatabaseError error) { Log.w(TAG, error.toException()); }
Initialize a {@link RecyclerView.Adapter} that listens to a Firebase query. See {@link FirebaseRecyclerOptions} for configuration options.
onError
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
Apache-2.0
@NonNull @Override public ObservableSnapshotArray<T> getSnapshots() { return mSnapshots; }
Initialize a {@link RecyclerView.Adapter} that listens to a Firebase query. See {@link FirebaseRecyclerOptions} for configuration options.
getSnapshots
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
Apache-2.0
@NonNull @Override public T getItem(int position) { return mSnapshots.get(position); }
Initialize a {@link RecyclerView.Adapter} that listens to a Firebase query. See {@link FirebaseRecyclerOptions} for configuration options.
getItem
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
Apache-2.0
@NonNull @Override public DatabaseReference getRef(int position) { return mSnapshots.getSnapshot(position).getRef(); }
Initialize a {@link RecyclerView.Adapter} that listens to a Firebase query. See {@link FirebaseRecyclerOptions} for configuration options.
getRef
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
Apache-2.0
@Override public int getItemCount() { return mSnapshots.isListening(this) ? mSnapshots.size() : 0; }
Initialize a {@link RecyclerView.Adapter} that listens to a Firebase query. See {@link FirebaseRecyclerOptions} for configuration options.
getItemCount
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
Apache-2.0
public void updateOptions(@NonNull FirebaseRecyclerOptions<T> options) { // Tear down old options boolean wasListening = mSnapshots.isListening(this); if (mOptions.getOwner() != null) { mOptions.getOwner().getLifecycle().removeObserver(this); } mSnapshots.clear(); ...
Re-initialize the Adapter with a new set of options. Can be used to change the query without re-constructing the entire adapter.
updateOptions
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
Apache-2.0
@Override public void onBindViewHolder(@NonNull VH holder, int position) { onBindViewHolder(holder, position, getItem(position)); }
Re-initialize the Adapter with a new set of options. Can be used to change the query without re-constructing the entire adapter.
onBindViewHolder
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java
Apache-2.0
@NonNull public ObservableSnapshotArray<T> getSnapshots() { return mSnapshots; }
Get the {@link ObservableSnapshotArray} to listen to.
getSnapshots
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
Apache-2.0
@Nullable public LifecycleOwner getOwner() { return mOwner; }
Get the (optional) LifecycleOwner. Listening will start/stop after the appropriate lifecycle events.
getOwner
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
Apache-2.0
@NonNull public Builder<T> setSnapshotArray(@NonNull ObservableSnapshotArray<T> snapshots) { assertNull(mSnapshots, ERR_SNAPSHOTS_SET); mSnapshots = snapshots; return this; }
Directly set the {@link ObservableSnapshotArray} to be listened to. <p> Do not call this method after calling {@code setQuery}.
setSnapshotArray
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
Apache-2.0
@NonNull public Builder<T> setQuery(@NonNull Query query, @NonNull SnapshotParser<T> snapshotParser) { assertNull(mSnapshots, ERR_SNAPSHOTS_SET); mSnapshots = new FirebaseArray<>(query, snapshotParser); return this; }
Set the Firebase query to listen to, along with a {@link SnapshotParser} to parse snapshots into model objects. <p> Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArray)}.
setQuery
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
Apache-2.0
@NonNull public Builder<T> setQuery(@NonNull Query query, @NonNull Class<T> modelClass) { return setQuery(query, new ClassSnapshotParser<>(modelClass)); }
Set the Firebase query to listen to, along with a {@link Class} to which snapshots should be parsed. <p> Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArray)}.
setQuery
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
Apache-2.0
@NonNull public Builder<T> setIndexedQuery(@NonNull Query keyQuery, @NonNull DatabaseReference dataRef, @NonNull SnapshotParser<T> snapshotParser) { assertNull(mSnapshots, ERR_SNAPSHOTS_SET); mSnapshots ...
Set an indexed Firebase query to listen to, along with a {@link SnapshotParser} to parse snapshots into model objects. Keys are identified by the {@code keyQuery} and then data is fetched using those keys from the {@code dataRef}. <p> Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArra...
setIndexedQuery
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
Apache-2.0
@NonNull public Builder<T> setIndexedQuery(@NonNull Query keyQuery, @NonNull DatabaseReference dataRef, @NonNull Class<T> modelClass) { return setIndexedQuery(keyQuery, dataRef, new ClassSnapshotParser<>(modelClass))...
Set an indexed Firebase query to listen to, along with a {@link Class} to which snapshots should be parsed. Keys are identified by the {@code keyQuery} and then data is fetched using those keys from the {@code dataRef}. <p> Do not call this method after calling {@link #setSnapshotArray(ObservableSnapshotArray)}.
setIndexedQuery
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
Apache-2.0
@NonNull public Builder<T> setLifecycleOwner(@Nullable LifecycleOwner owner) { mOwner = owner; return this; }
Set the (optional) {@link LifecycleOwner}. Listens will start and stop after the appropriate lifecycle events.
setLifecycleOwner
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
Apache-2.0
@NonNull public FirebaseRecyclerOptions<T> build() { assertNonNull(mSnapshots, ERR_SNAPSHOTS_NULL); return new FirebaseRecyclerOptions<>(mSnapshots, mOwner); }
Build a {@link FirebaseRecyclerOptions} from the provided arguments.
build
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/FirebaseRecyclerOptions.java
Apache-2.0
@NonNull public LiveData<PagingData<DataSnapshot>> getData() { return mData; }
Options to configure an {@link FirebaseRecyclerPagingAdapter}. Use {@link Builder} to create a new instance.
getData
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
Apache-2.0
@NonNull public SnapshotParser<T> getParser() { return mParser; }
Options to configure an {@link FirebaseRecyclerPagingAdapter}. Use {@link Builder} to create a new instance.
getParser
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
Apache-2.0
@NonNull public DiffUtil.ItemCallback<DataSnapshot> getDiffCallback() { return mDiffCallback; }
Options to configure an {@link FirebaseRecyclerPagingAdapter}. Use {@link Builder} to create a new instance.
getDiffCallback
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
Apache-2.0
@Nullable public LifecycleOwner getOwner() { return mOwner; }
Options to configure an {@link FirebaseRecyclerPagingAdapter}. Use {@link Builder} to create a new instance.
getOwner
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
Apache-2.0
@NonNull public Builder<T> setQuery(@NonNull Query query, @NonNull PagingConfig config, @NonNull Class<T> modelClass) { return setQuery(query, config, new ClassSnapshotParser<>(modelClass)); }
Sets the query using a {@link ClassSnapshotParser} based on the given class. See {@link #setQuery(Query, PagingConfig, SnapshotParser)}.
setQuery
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
Apache-2.0
@NonNull public Builder<T> setDiffCallback(@NonNull DiffUtil.ItemCallback<DataSnapshot> diffCallback) { mDiffCallback = diffCallback; return this; }
Sets an optional custom {@link DiffUtil.ItemCallback} to compare {@link T} objects. @return this, for chaining.
setDiffCallback
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
Apache-2.0
@NonNull public Builder<T> setLifecycleOwner(@NonNull LifecycleOwner owner) { mOwner = owner; return this; }
Sets an optional {@link LifecycleOwner} to control the lifecycle of the adapter. Otherwise, you must manually call {@link FirebaseRecyclerPagingAdapter#startListening()} and {@link FirebaseRecyclerPagingAdapter#stopListening()}. @return this, for chaining.
setLifecycleOwner
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DatabasePagingOptions.java
Apache-2.0
@SuppressLint("RestrictedApi") @NonNull @Override public Single<LoadResult<String, DataSnapshot>> loadSingle(@NonNull LoadParams<String> params) { Task<DataSnapshot> task; if (params.getKey() == null) { task = mQuery.limitToFirst(params.getLoadSize()).get(); } else { ...
DatabaseError.fromStatus() is not meant to be public.
loadSingle
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/DatabasePagingSource.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DatabasePagingSource.java
Apache-2.0
private LoadResult<String, DataSnapshot> toLoadResult( @NonNull List<DataSnapshot> snapshots, String nextPage ) { return new LoadResult.Page<>( snapshots, null, // Only paging forward. nextPage, LoadResult.Page.COUNT_UND...
DatabaseError.fromStatus() is not meant to be public.
toLoadResult
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/DatabasePagingSource.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DatabasePagingSource.java
Apache-2.0
@Nullable private String getLastPageKey(@NonNull List<DataSnapshot> data) { if (data.isEmpty()) { return null; } else { return data.get(data.size() - 1).getKey(); } }
DatabaseError.fromStatus() is not meant to be public.
getLastPageKey
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/DatabasePagingSource.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DatabasePagingSource.java
Apache-2.0
@Nullable @Override public String getRefreshKey(@NonNull PagingState<String, DataSnapshot> state) { return null; }
DatabaseError.fromStatus() is not meant to be public.
getRefreshKey
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/DatabasePagingSource.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DatabasePagingSource.java
Apache-2.0
@Override public boolean areItemsTheSame(@NonNull DataSnapshot oldItem, @NonNull DataSnapshot newItem) { return oldItem.getKey().equals(newItem.getKey()); }
Default diff callback implementation for Firebase Data snapshots.
areItemsTheSame
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/DefaultSnapshotDiffCallback.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DefaultSnapshotDiffCallback.java
Apache-2.0
@SuppressLint("DiffUtilEquals") @Override public boolean areContentsTheSame(@NonNull DataSnapshot oldItem, @NonNull DataSnapshot newItem) { T oldModel = mParser.parseSnapshot(oldItem); T newModel = mParser.parseSnapshot(newItem); return oldModel.equ...
Default diff callback implementation for Firebase Data snapshots.
areContentsTheSame
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/DefaultSnapshotDiffCallback.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/DefaultSnapshotDiffCallback.java
Apache-2.0
@Override public void onChanged(@Nullable PagingData<DataSnapshot> snapshots) { if (snapshots == null) { return; } submitData(mOptions.getOwner().getLifecycle(), snapshots); }
Paginated RecyclerView Adapter for a Firebase Realtime Database query. Configured with {@link DatabasePagingOptions}.
onChanged
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
Apache-2.0
public void updateOptions(@NonNull DatabasePagingOptions<T> options) { mOptions = options; // Tear down old options boolean hasObservers = mPagingData.hasObservers(); if (mOptions.getOwner() != null) { mOptions.getOwner().getLifecycle().removeObserver(this); } ...
Re-initialize the Adapter with a new set of options. Can be used to change the query without re-constructing the entire adapter.
updateOptions
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
Apache-2.0
@OnLifecycleEvent(Lifecycle.Event.ON_START) public void startListening() { mPagingData.observeForever(mDataObserver); }
Start listening to paging / scrolling events and populating adapter data.
startListening
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
Apache-2.0
@OnLifecycleEvent(Lifecycle.Event.ON_STOP) public void stopListening() { mPagingData.removeObserver(mDataObserver); }
Unsubscribe from paging / scrolling events, no more data will be populated, but the existing data will remain.
stopListening
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
Apache-2.0
@Override public void onBindViewHolder(@NonNull VH viewHolder, int position) { DataSnapshot snapshot = getItem(position); onBindViewHolder(viewHolder, position, mParser.parseSnapshot(snapshot)); }
Unsubscribe from paging / scrolling events, no more data will be populated, but the existing data will remain.
onBindViewHolder
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
Apache-2.0
@NonNull public DatabaseReference getRef(int position){ return getItem(position).getRef(); }
@param model the model object containing the data that should be used to populate the view. @see #onBindViewHolder(RecyclerView.ViewHolder, int)
getRef
java
firebase/FirebaseUI-Android
database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
https://github.com/firebase/FirebaseUI-Android/blob/master/database/src/main/java/com/firebase/ui/database/paging/FirebaseRecyclerPagingAdapter.java
Apache-2.0
@Override public void onChildChanged(@NonNull ChangeEventType type, @NonNull DocumentSnapshot snapshot, int newIndex, int oldIndex) { Log.d(TAG, "onChildChanged: " + type + " at index " + newInde...
Simple listener that logs all events, to make test debugging easier.
onChildChanged
java
firebase/FirebaseUI-Android
firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
Apache-2.0
@Override public void onDataChanged() { Log.d(TAG, "onDataChanged"); }
Simple listener that logs all events, to make test debugging easier.
onDataChanged
java
firebase/FirebaseUI-Android
firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
Apache-2.0
@Override public void onError(@NonNull FirebaseFirestoreException e) { Log.w(TAG, "onError", e); }
Simple listener that logs all events, to make test debugging easier.
onError
java
firebase/FirebaseUI-Android
firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
Apache-2.0
@Before public void setUp() throws Exception { FirebaseApp app = getAppInstance(ApplicationProvider.getApplicationContext()); // Configure Firestore and disable persistence FirebaseFirestore.getInstance(app) .setFirestoreSettings(new FirebaseFirestoreSettings.Builder() ...
Simple listener that logs all events, to make test debugging easier.
setUp
java
firebase/FirebaseUI-Android
firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
Apache-2.0
@After public void tearDown() { if (mArray != null && mListener != null) { mArray.removeChangeEventListener(mListener); } else { Log.w(TAG, "mArray is null in tearDown"); } }
Simple listener that logs all events, to make test debugging easier.
tearDown
java
firebase/FirebaseUI-Android
firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
Apache-2.0
@Test public void testPushIncreasesSize() throws Exception { runAndVerify(() -> mCollectionRef.document().set(new IntegerDocument(4)), () -> mArray.size() == (INITIAL_SIZE + 1)); }
Append a single document and confirm size increases by one.
testPushIncreasesSize
java
firebase/FirebaseUI-Android
firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
Apache-2.0
@Test public void testAddToEnd() throws Exception { final int value = 4; runAndVerify(() -> mCollectionRef.document().set(new IntegerDocument(value)), () -> { if (mArray.size() == (INITIAL_SIZE + 1)) { return mArray.get(mArray.size() - 1).field == value; } ...
Append a single document to the query and confirm that size increases by one and that the document is added to the end of the array.
testAddToEnd
java
firebase/FirebaseUI-Android
firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
Apache-2.0
@Test public void testAddToBeginning() throws Exception { final int value = -1; runAndVerify(() -> mCollectionRef.document().set(new IntegerDocument(value)), () -> { if (mArray.size() == (INITIAL_SIZE + 1)) { return mArray.get(0).field == value; } ...
Append a single document to the query and confirm that size increases by one and that the document is added to the beginning of the array.
testAddToBeginning
java
firebase/FirebaseUI-Android
firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
Apache-2.0
@SuppressWarnings("unchecked") private void runAndVerify(Callable<Task<?>> setup, Callable<Boolean> verify) throws Exception { final Semaphore semaphore = new Semaphore(0); long startTime = System.currentTimeMillis(); // Run the setup action and release the semaphore when it is complete ...
Runs some setup action, waits until it is complete, and then waits for a verification condition to be met. Times out after {@link #TIMEOUT}.
runAndVerify
java
firebase/FirebaseUI-Android
firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
Apache-2.0
private FirebaseApp getAppInstance(Context context) { try { return FirebaseApp.getInstance(FIREBASE_APP_NAME); } catch (IllegalStateException e) { return initializeApp(context); } }
Runs some setup action, waits until it is complete, and then waits for a verification condition to be met. Times out after {@link #TIMEOUT}.
getAppInstance
java
firebase/FirebaseUI-Android
firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
Apache-2.0
private FirebaseApp initializeApp(Context context) { return FirebaseApp.initializeApp(context, new FirebaseOptions.Builder() .setApplicationId("firebaseuitests-app123") .setApiKey("AIzaSyCIA_uf-5Y4G83vlZmjMmCM_wkX62iWXf0") .setProjectId("firebaseuitests") ...
Runs some setup action, waits until it is complete, and then waits for a verification condition to be met. Times out after {@link #TIMEOUT}.
initializeApp
java
firebase/FirebaseUI-Android
firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
Apache-2.0
private String getConsoleLink(CollectionReference reference) { String base = "https://console.firebase.google.com/project/firebaseuitests/database/firestore/data/"; return base + reference.getPath(); }
Runs some setup action, waits until it is complete, and then waits for a verification condition to be met. Times out after {@link #TIMEOUT}.
getConsoleLink
java
firebase/FirebaseUI-Android
firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java
Apache-2.0
@NonNull @Override public String getId(@NonNull DocumentSnapshot snapshot) { return snapshot.getId(); }
Implementation of {@link BaseCachingSnapshotParser} for {@link DocumentSnapshot}.
getId
java
firebase/FirebaseUI-Android
firestore/src/main/java/com/firebase/ui/firestore/CachingSnapshotParser.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/CachingSnapshotParser.java
Apache-2.0
@NonNull @Override public T parseSnapshot(@NonNull DocumentSnapshot snapshot) { return snapshot.toObject(mModelClass); }
An implementation of {@link SnapshotParser} that converts {@link DocumentSnapshot} to a class using {@link DocumentSnapshot#toObject(Class)}.
parseSnapshot
java
firebase/FirebaseUI-Android
firestore/src/main/java/com/firebase/ui/firestore/ClassSnapshotParser.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/ClassSnapshotParser.java
Apache-2.0
@NonNull @Override protected List<DocumentSnapshot> getSnapshots() { return mSnapshots; }
@param changes metadata options for the query listen. @see #FirestoreArray(Query, SnapshotParser)
getSnapshots
java
firebase/FirebaseUI-Android
firestore/src/main/java/com/firebase/ui/firestore/FirestoreArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/FirestoreArray.java
Apache-2.0
@Override protected void onCreate() { super.onCreate(); mRegistration = mQuery.addSnapshotListener(mMetadataChanges, this); }
@param changes metadata options for the query listen. @see #FirestoreArray(Query, SnapshotParser)
onCreate
java
firebase/FirebaseUI-Android
firestore/src/main/java/com/firebase/ui/firestore/FirestoreArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/FirestoreArray.java
Apache-2.0
@Override protected void onDestroy() { super.onDestroy(); mRegistration.remove(); mRegistration = null; }
@param changes metadata options for the query listen. @see #FirestoreArray(Query, SnapshotParser)
onDestroy
java
firebase/FirebaseUI-Android
firestore/src/main/java/com/firebase/ui/firestore/FirestoreArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/FirestoreArray.java
Apache-2.0
@Override public void onEvent(@Nullable QuerySnapshot snapshots, @Nullable FirebaseFirestoreException e) { if (e != null) { notifyOnError(e); return; } // Break down each document event List<DocumentChange> changes = snapshots.getDocumentChanges(mMetadataChan...
@param changes metadata options for the query listen. @see #FirestoreArray(Query, SnapshotParser)
onEvent
java
firebase/FirebaseUI-Android
firestore/src/main/java/com/firebase/ui/firestore/FirestoreArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/FirestoreArray.java
Apache-2.0
private void onDocumentAdded(DocumentChange change) { QueryDocumentSnapshot snapshot = change.getDocument(); mSnapshots.add(change.getNewIndex(), snapshot); notifyOnChildChanged(ChangeEventType.ADDED, snapshot, change.getNewIndex(), -1); }
@param changes metadata options for the query listen. @see #FirestoreArray(Query, SnapshotParser)
onDocumentAdded
java
firebase/FirebaseUI-Android
firestore/src/main/java/com/firebase/ui/firestore/FirestoreArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/FirestoreArray.java
Apache-2.0
private void onDocumentRemoved(DocumentChange change) { mSnapshots.remove(change.getOldIndex()); QueryDocumentSnapshot snapshot = change.getDocument(); notifyOnChildChanged(ChangeEventType.REMOVED, snapshot, -1, change.getOldIndex()); }
@param changes metadata options for the query listen. @see #FirestoreArray(Query, SnapshotParser)
onDocumentRemoved
java
firebase/FirebaseUI-Android
firestore/src/main/java/com/firebase/ui/firestore/FirestoreArray.java
https://github.com/firebase/FirebaseUI-Android/blob/master/firestore/src/main/java/com/firebase/ui/firestore/FirestoreArray.java
Apache-2.0