Skip to content

Commit 7c0e2dc

Browse files
authored
JavaDoc for paging adapter (#1298)
2 parents 8a8fd8d + 7edd9d1 commit 7c0e2dc

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

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

Lines changed: 51 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#DEFAULT} 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#DEFAULT} 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} and 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,17 @@ 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 paginate.
110+
*
111+
* @param query the Firestore query. This query should only contain where() and
112+
* orderBy() clauses. Any limit() or pagination clauses will cause errors.
113+
* @param source the data source to use for query data.
114+
* @param config paging configuration, passed directly to the support paging library.
115+
* @param parser the {@link SnapshotParser} to parse {@link DocumentSnapshot} into model
116+
* objects.
117+
* @return this, for chaining.
118+
*/
86119
@NonNull
87120
public Builder<T> setQuery(@NonNull Query query,
88121
@NonNull Source source,
@@ -96,18 +129,36 @@ public Builder<T> setQuery(@NonNull Query query,
96129
return this;
97130
}
98131

132+
/**
133+
* Sets an optional custom {@link DiffUtil.ItemCallback} to compare
134+
* {@link DocumentSnapshot} objects.
135+
*
136+
* The default implementation is {@link DefaultSnapshotDiffCallback}.
137+
*
138+
* @return this, for chaining.
139+
*/
99140
@NonNull
100141
public Builder<T> setDiffCallback(@NonNull DiffUtil.ItemCallback<DocumentSnapshot> diffCallback) {
101142
mDiffCallback = diffCallback;
102143
return this;
103144
}
104145

146+
/**
147+
* Sets an optional {@link LifecycleOwner} to control the lifecycle of the adapter. Otherwise,
148+
* you must manually call {@link FirestorePagingAdapter#startListening()}
149+
* and {@link FirestorePagingAdapter#stopListening()}.
150+
*
151+
* @return this, for chaining.
152+
*/
105153
@NonNull
106154
public Builder<T> setLifecycleOwner(@NonNull LifecycleOwner owner) {
107155
mOwner = owner;
108156
return this;
109157
}
110158

159+
/**
160+
* Build the {@link FirestorePagingOptions} object.
161+
*/
111162
@NonNull
112163
public FirestorePagingOptions<T> build() {
113164
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)