suiko1984 / geofirestore-android

GeoFire for Android - Realtime location queries with Firebase Cloud Firestore
13 stars 4 forks source link

Has the library stopped working? #12

Closed lJanusl closed 4 years ago

lJanusl commented 4 years ago

I am testing this library in my application, it was working correctly for two days and on the third I just stopped doing it.

1. My Firebase-Firestore version:

implementation 'com.google.firebase:firebase-core:17.2.2'
//Firestore
implementation 'com.google.firebase:firebase-firestore:21.4.2'

2. And i have "g" and "l" path in DB to query. I manually typed the fields "g" and "l" in my DB **

As I mentioned before, for two days I obtained the documents of my collection but then I stopped obtaining them.

3. But I also can't add .setLocation to my DB, I get this error. java.lang.NoSuchMethodError: No virtual method set(Ljava/util/Map;Lcom/google/firebase/firestore/SetOptions;)Lcom/google/android/gms/tasks/Task; in class Lcom/google/firebase/firestore/DocumentReference; or its super classes (declaration of 'com.google.firebase.firestore.DocumentReference' appears in /data/app/com.example.geofire-JDEDG5FqcN1UH5LrL1HGeA==/base.apk!classes3.dex) at com.koalap.geofirestore.GeoFire.setLocation(GeoFire.java:174)

4. Mi codigo es

`public class Firestore { private FirestoreAPI mFirestoreAPI; private GeoQuery mGeoQueryJava; public Firestore() { mFirestoreAPI = FirestoreAPI.getInstance(); } public void suscribeToGeoJava(double lat, double lon, TiendaEventListener listener){ @NonNull GeoFire geoFire = new GeoFire(mFirestoreAPI.getEmpresasColl()); // .whereEqualTo("categoria", path));

    mGeoQueryJava = geoFire.queryAtLocation(new GeoLocation(lat,lon), 100);
    mGeoQueryJava.addGeoQueryDataEventListener(new GeoQueryDataEventListener() {
        @Override
        public void onDataEntered(DocumentSnapshot documentSnapshot, GeoLocation location) {
            if (documentSnapshot!=null){
                listener.onDocumentAdded(getTienda(documentSnapshot));
            }else {
                listener.onEmpty();
            }
        }
        @Override
        public void onDataExited(DocumentSnapshot documentSnapshot) {
            listener.onDocumentRemoved(getTienda(documentSnapshot));
        }
        @Override
        public void onDataMoved(DocumentSnapshot documentSnapshot, GeoLocation location) {}
        @Override
        public void onDataChanged(DocumentSnapshot documentSnapshot, GeoLocation location) {
            listener.onDocumentUpdated(getTienda(documentSnapshot));
        }
        @Override
        public void onGeoQueryReady() {}

        @Override
        public void onGeoQueryError(Exception error) {
            listener.onError(R.string.error_server);
        }
    });
}
public void unSuscribeGeoJava(){
    if(mGeoQueryJava!=null){
        mGeoQueryJava.removeAllListeners();
    }
}
private Tienda getTienda(DocumentSnapshot documentSnapshot) {
    Tienda tienda = documentSnapshot.toObject(Tienda.class);
    tienda.setId(documentSnapshot.getId());
    return tienda;
}

`

ghost commented 4 years ago

I have the same problem, please fix this.

KelvinPac commented 4 years ago

Which firestore version are you using?

On Thu, Apr 30, 2020 at 12:29 AM Chicago4303 notifications@github.com wrote:

I have the same problem, please fix this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/suiko1984/geofirestore-android/issues/12#issuecomment-621474816, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEISQEYDVRWQTC25I2KRK3LRPCL2PANCNFSM4MQN3RLA .

KelvinPac commented 4 years ago

My existing app is still working. It might be the new firestore versions. Also can you save the geolocation successfully?

On Thu, Apr 30, 2020 at 12:34 AM Kelvin Murithi flyboypac@gmail.com wrote:

Which firestore version are you using?

On Thu, Apr 30, 2020 at 12:29 AM Chicago4303 notifications@github.com wrote:

I have the same problem, please fix this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/suiko1984/geofirestore-android/issues/12#issuecomment-621474816, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEISQEYDVRWQTC25I2KRK3LRPCL2PANCNFSM4MQN3RLA .

KelvinPac commented 4 years ago

I have the same problem, please fix this.

Try a lower firestore version and confirm if it works

lJanusl commented 4 years ago

What firestore version, are you using? @KelvinPac

KelvinPac commented 4 years ago

implementation 'com.google.firebase:firebase-firestore:21.4.0'

suiko1984 commented 4 years ago

Hi guys, I have updated the library with the latest dependency versions. Feel free to update to 1.2.0. Tell me if you are still having this issue.

I have also added a small feature : Since GeoFiretore 1.2.0, in some cases you may want a callback to be called once and then immediately removed, such as when initializing a UI element that you don't expect to change. You can use the addGeoQueryForSingleValueEvent() method to simplify this scenario: it triggers once and then does not trigger again.

This is useful for data that only needs to be loaded once and isn't expected to change frequently or require active listening.

KelvinPac commented 4 years ago

That's a very nice feature you have added. With this, we don't have to add geoQuery.removeAllListeners(); on the onGeoQueryReady callback

lJanusl commented 4 years ago

@suiko1984 Thank you very much, now it works excellent and thanks for the library.

KelvinPac commented 4 years ago

@suiko1984 Is there a single value event listener for GeoQueryDataEventListener?

suiko1984 commented 4 years ago

@KelvinPac I have updated the library (1.2.1). You can now make use of addGeoQueryDataForSingleValueEvent. Please tell me if it works well.