Skip to content

Commit 0bea78b

Browse files
authored
Add back FirestoreArray constructor without QueryListenOptions (#16)
2 parents 70184f2 + 74454d8 commit 0bea78b

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

firestore/src/androidTest/java/com/firebase/ui/firestore/FirestoreArrayTest.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import com.google.firebase.firestore.FirebaseFirestoreException;
3333
import com.google.firebase.firestore.FirebaseFirestoreSettings;
3434
import com.google.firebase.firestore.Query;
35-
import com.google.firebase.firestore.QueryListenOptions;
3635

3736
import org.junit.After;
3837
import org.junit.Before;
@@ -123,16 +122,15 @@ public void setUp() throws Exception {
123122

124123
// Query is the whole collection ordered by field
125124
mQuery = mCollectionRef.orderBy("field", Query.Direction.ASCENDING);
126-
mArray = new FirestoreArray<>(mQuery, new QueryListenOptions(),
127-
new ClassSnapshotParser<>(IntegerDocument.class));
125+
mArray = new FirestoreArray<>(mQuery, new ClassSnapshotParser<>(IntegerDocument.class));
128126

129127
// Add a listener to the array so that it's active
130128
mListener = mArray.addChangeEventListener(new LoggingListener());
131129

132130
// Add some initial data
133131
runAndVerify(new Callable<Task<?>>() {
134132
@Override
135-
public Task<?> call() throws Exception {
133+
public Task<?> call() {
136134
List<Task> tasks = new ArrayList<>();
137135
for (int i = 0; i < INITIAL_SIZE; i++) {
138136
tasks.add(mCollectionRef.document().set(new IntegerDocument(i)));
@@ -142,14 +140,14 @@ public Task<?> call() throws Exception {
142140
}
143141
}, new Callable<Boolean>() {
144142
@Override
145-
public Boolean call() throws Exception {
143+
public Boolean call() {
146144
return mArray.size() == INITIAL_SIZE;
147145
}
148146
});
149147
}
150148

151149
@After
152-
public void tearDown() throws Exception {
150+
public void tearDown() {
153151
if (mArray != null && mListener != null) {
154152
mArray.removeChangeEventListener(mListener);
155153
} else {
@@ -164,12 +162,12 @@ public void tearDown() throws Exception {
164162
public void testPushIncreasesSize() throws Exception {
165163
runAndVerify(new Callable<Task<?>>() {
166164
@Override
167-
public Task<?> call() throws Exception {
165+
public Task<?> call() {
168166
return mCollectionRef.document().set(new IntegerDocument(4));
169167
}
170168
}, new Callable<Boolean>() {
171169
@Override
172-
public Boolean call() throws Exception {
170+
public Boolean call() {
173171
return mArray.size() == (INITIAL_SIZE + 1);
174172
}
175173
});
@@ -185,12 +183,12 @@ public void testAddToEnd() throws Exception {
185183

186184
runAndVerify(new Callable<Task<?>>() {
187185
@Override
188-
public Task<?> call() throws Exception {
186+
public Task<?> call() {
189187
return mCollectionRef.document().set(new IntegerDocument(value));
190188
}
191189
}, new Callable<Boolean>() {
192190
@Override
193-
public Boolean call() throws Exception {
191+
public Boolean call() {
194192
if (mArray.size() == (INITIAL_SIZE + 1)) {
195193
if (mArray.getObject(mArray.size() - 1).field == value) {
196194
return true;
@@ -212,12 +210,12 @@ public void testAddToBeginning() throws Exception {
212210

213211
runAndVerify(new Callable<Task<?>>() {
214212
@Override
215-
public Task<?> call() throws Exception {
213+
public Task<?> call() {
216214
return mCollectionRef.document().set(new IntegerDocument(value));
217215
}
218216
}, new Callable<Boolean>() {
219217
@Override
220-
public Boolean call() throws Exception {
218+
public Boolean call() {
221219
if (mArray.size() == (INITIAL_SIZE + 1)) {
222220
if (mArray.getObject(0).field == value) {
223221
return true;

firestore/src/main/java/com/firebase/ui/firestore/FirestoreArray.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@ public class FirestoreArray<T> extends ObservableSnapshotArray<T>
2929
/**
3030
* Create a new FirestoreArray.
3131
*
32-
* @param query query to listen to.
33-
* @param options options for the query listen.
32+
* @param query query to listen to.
3433
* @param parser parser for DocumentSnapshots.
35-
*
3634
* @see ObservableSnapshotArray#ObservableSnapshotArray(SnapshotParser)
3735
*/
38-
public FirestoreArray(Query query,
39-
QueryListenOptions options,
40-
SnapshotParser<T> parser) {
36+
public FirestoreArray(Query query, SnapshotParser<T> parser) {
37+
this(query, new QueryListenOptions(), parser);
38+
}
39+
40+
/**
41+
* @param options options for the query listen.
42+
* @see #FirestoreArray(Query, SnapshotParser)
43+
*/
44+
public FirestoreArray(Query query, QueryListenOptions options, SnapshotParser<T> parser) {
4145
super(parser);
4246
mQuery = query;
4347
mOptions = options;

0 commit comments

Comments
 (0)