Skip to content

Commit f35be2c

Browse files
committed
JavaDoc for paging adapter
Change-Id: I25da3c9dd6d468551fd6028aa52fcbbf57769384
1 parent 957f7af commit f35be2c

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

firestore/src/main/java/com/firebase/ui/firestore/paging/FirestorePagingOptions.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
/**
1818
* Options to configure an {@link FirestorePagingAdapter}.
19+
*
20+
* Use {@link Builder} to create a new instance.
1921
*/
2022
public final class FirestorePagingOptions<T> {
2123

@@ -54,27 +56,47 @@ public LifecycleOwner getOwner() {
5456
return mOwner;
5557
}
5658

59+
/**
60+
* Builder for {@link FirestorePagingOptions}.
61+
*/
5762
public static final class Builder<T> {
5863

5964
private LiveData<PagedList<DocumentSnapshot>> mData;
6065
private SnapshotParser<T> mParser;
6166
private LifecycleOwner mOwner;
6267
private DiffUtil.ItemCallback<DocumentSnapshot> mDiffCallback;
6368

69+
/**
70+
* Sets the query using {@link Source#SERVER} and a {@link ClassSnapshotParser} based
71+
* on the given Class.
72+
*
73+
* See {@link #setQuery(Query, Source, PagedList.Config, SnapshotParser)}.
74+
*/
6475
@NonNull
6576
public Builder<T> setQuery(@NonNull Query query,
6677
@NonNull PagedList.Config config,
6778
@NonNull Class<T> modelClass) {
6879
return setQuery(query, Source.DEFAULT, config, modelClass);
6980
}
7081

82+
/**
83+
* Sets the query using {@link Source#SERVER} and a custom {@link SnapshotParser}.
84+
*
85+
* See {@link #setQuery(Query, Source, PagedList.Config, SnapshotParser)}.
86+
*/
7187
@NonNull
7288
public Builder<T> setQuery(@NonNull Query query,
7389
@NonNull PagedList.Config config,
7490
@NonNull SnapshotParser<T> parser) {
7591
return setQuery(query, Source.DEFAULT, config, parser);
7692
}
7793

94+
/**
95+
* Sets the query using a custom {@link Source} amd a {@link ClassSnapshotParser} based
96+
* on the given class.
97+
*
98+
* See {@link #setQuery(Query, Source, PagedList.Config, SnapshotParser)}.
99+
*/
78100
@NonNull
79101
public Builder<T> setQuery(@NonNull Query query,
80102
@NonNull Source source,
@@ -83,6 +105,16 @@ public Builder<T> setQuery(@NonNull Query query,
83105
return setQuery(query, source, config, new ClassSnapshotParser<>(modelClass));
84106
}
85107

108+
/**
109+
* Sets the Firestore query to page.
110+
* @param query the Firestore query. This query should only contain where() and
111+
* orderBy() clauses. Any limit() pr pagination clauses will cause errors.
112+
* @param source the data source to use for query data.
113+
* @param config paging configuration, passed directly to the support paging library.
114+
* @param parser the {@link SnapshotParser} to parse {@link DocumentSnapshot} into model
115+
* objects.
116+
* @return this, for chaining.
117+
*/
86118
@NonNull
87119
public Builder<T> setQuery(@NonNull Query query,
88120
@NonNull Source source,
@@ -96,18 +128,34 @@ public Builder<T> setQuery(@NonNull Query query,
96128
return this;
97129
}
98130

131+
/**
132+
* Sets an optional custom {@link DiffUtil.ItemCallback} to compare
133+
* {@link DocumentSnapshot} objects.
134+
*
135+
* The default implementation is {@link DefaultSnapshotDiffCallback}.
136+
* @return this, for chaining.
137+
*/
99138
@NonNull
100139
public Builder<T> setDiffCallback(@NonNull DiffUtil.ItemCallback<DocumentSnapshot> diffCallback) {
101140
mDiffCallback = diffCallback;
102141
return this;
103142
}
104143

144+
/**
145+
* Sets an optional {@link LifecycleOwner} to control the lifecycle of the view. Otherwise,
146+
* developer must manually call {@link FirestorePagingAdapter#startListening()}
147+
* and {@link FirestorePagingAdapter#stopListening()}.
148+
* @return this, for chaining.
149+
*/
105150
@NonNull
106151
public Builder<T> setLifecycleOwner(@NonNull LifecycleOwner owner) {
107152
mOwner = owner;
108153
return this;
109154
}
110155

156+
/**
157+
* Build the {@link FirestorePagingOptions} object.
158+
*/
111159
@NonNull
112160
public FirestorePagingOptions<T> build() {
113161
if (mData == null || mParser == null) {

firestore/src/main/java/com/firebase/ui/firestore/paging/LoadingState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
public enum LoadingState {
77
/**
8-
* Loading initial data.Pag
8+
* Loading initial data.
99
*/
1010
LOADING_INITIAL,
1111

0 commit comments

Comments
 (0)