firebase / geofire-android

GeoFire for Android apps
Apache License 2.0
133 stars 36 forks source link

Query works twice with startAfter(lastVisible) clause. #16

Open nasirhasanov opened 3 years ago

nasirhasanov commented 3 years ago

I am using Geoquery to fetch nearest documents from Firestore in Android/Java. I try to paginate data with recyclerview. But somehow, .startAfter(lastVisible) clause makes the query work twice for different bound tasks. So, after first fetch, all queries works twice.

List<GeoQueryBounds> bounds = GeoFireUtils.getGeoHashQueryBounds(center, radiusInM); final List<Task<QuerySnapshot>> nextTasks = new ArrayList<>(); for (GeoQueryBounds b : bounds) { Query nextQuery = db.collection("posts") .whereEqualTo("country_code", sharedpreferences.getString("country_code", "")) .orderBy("geohash") .startAt(b.startHash) .endAt(b.endHash) .startAfter(lastVisible) .limit(10); nextTasks.add(nextQuery.get()); }