imperiumlabs / GeoFirestore-Android

GeoFirestore for Android - Realtime location queries with Firestore
MIT License
123 stars 36 forks source link

Error in setLocation README documentation #43

Closed betegon closed 4 years ago

betegon commented 4 years ago

This is the setLocation function (copypaste) from GeoFirestore.kt

fun setLocation(documentID: String?, location: GeoPoint, completionCallback: CompletionCallback?) {
    if (documentID == null) {
        completionCallback?.onComplete(NullPointerException("Document ID is null"))
        return
    }
    //Get the DocumentReference for this documentID
    val docRef = this.getRefForDocumentID(documentID)
    val geoHash = GeoHash(GeoLocation(location.latitude, location.longitude))
    //Create a Map with the fields to add
    val updates = HashMap<String, Any>()
    updates["g"] = geoHash.geoHashString
    updates["l"] = location
    //Update the DocumentReference with the location data
    docRef.set(updates, SetOptions.merge())
        .addOnSuccessListener { completionCallback?.onComplete(null) }
        .addOnFailureListener { completionCallback?.onComplete(it) }
} 

As you can see on the last lines:

.addOnSuccessListener { completionCallback?.onComplete(null) }
.addOnFailureListener { completionCallback?.onComplete(it) }

This should return null if the function is completed successfully, therefore, in the README appears the following (screenshot below):

image

This is wrong, as if it was successfully, exception will be null. It should be the other way around.

Do you accept Pull requests?

betegon commented 4 years ago

Closing issue as it is fixed by my pull request #44 (already merged).