@@ -144,7 +144,8 @@ public static interface OnQueryLoadListener<T extends ParseObject> {
144
144
145
145
private List <T > objects = new ArrayList <>();
146
146
147
- private Set <ParseQuery > runningQueries = Collections .newSetFromMap (new ConcurrentHashMap <ParseQuery , Boolean >());
147
+ private Set <ParseQuery > runningQueries =
148
+ Collections .newSetFromMap (new ConcurrentHashMap <ParseQuery , Boolean >());
148
149
149
150
150
151
// Used to keep track of the pages of objects when using CACHE_THEN_NETWORK. When using this,
@@ -375,7 +376,8 @@ private void loadObjects(final int page, final boolean shouldClear) {
375
376
objectPages .add (page , new ArrayList <T >());
376
377
}
377
378
378
- // In the case of CACHE_THEN_NETWORK, two callbacks will be called. Using this flag to keep track,
379
+ // In the case of CACHE_THEN_NETWORK, two callbacks will be called. Using this flag to keep
380
+ // track of the callbacks.
379
381
final Capture <Boolean > firstCallBack = new Capture <>(true );
380
382
381
383
runningQueries .add (query );
@@ -390,18 +392,22 @@ public void done(List<T> foundObjects, ParseException e) {
390
392
}
391
393
// In the case of CACHE_THEN_NETWORK, two callbacks will be called. We can only remove the
392
394
// query after the second callback.
393
- if (query .getCachePolicy () != CachePolicy .CACHE_THEN_NETWORK ||
394
- (query .getCachePolicy () == CachePolicy .CACHE_THEN_NETWORK && !firstCallBack .get ())) {
395
+ if (Parse .isLocalDatastoreEnabled () ||
396
+ (query .getCachePolicy () != CachePolicy .CACHE_THEN_NETWORK ) ||
397
+ (query .getCachePolicy () == CachePolicy .CACHE_THEN_NETWORK && !firstCallBack .get ())) {
395
398
runningQueries .remove (query );
396
399
}
400
+
397
401
if ((!Parse .isLocalDatastoreEnabled () &&
398
- query .getCachePolicy () == CachePolicy .CACHE_ONLY )
399
- && (e != null ) && e .getCode () == ParseException .CACHE_MISS ) {
402
+ query .getCachePolicy () == CachePolicy .CACHE_ONLY ) &&
403
+ (e != null ) && e .getCode () == ParseException .CACHE_MISS ) {
400
404
// no-op on cache miss
401
405
return ;
402
406
}
403
407
404
- if ((e != null ) && ((e .getCode () == ParseException .CONNECTION_FAILED ) || (e .getCode () != ParseException .CACHE_MISS ))) {
408
+ if ((e != null ) &&
409
+ ((e .getCode () == ParseException .CONNECTION_FAILED ) ||
410
+ (e .getCode () != ParseException .CACHE_MISS ))) {
405
411
hasNextPage = true ;
406
412
} else if (foundObjects != null ) {
407
413
if (shouldClear && firstCallBack .get ()) {
0 commit comments