Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Fixes #134 and #28 #146

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions common/src/main/java/com/firebase/geofire/GeoFire.java
Original file line number Diff line number Diff line change
@@ -28,17 +28,20 @@

package com.firebase.geofire;

import static com.firebase.geofire.util.GeoUtils.capRadius;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

import com.firebase.geofire.core.GeoHash;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.ValueEventListener;
import com.google.firebase.database.GenericTypeIndicator;
import java.lang.Throwable;
import java.util.*;
import java.util.logging.Logger;

import static com.firebase.geofire.util.GeoUtils.capRadius;
import com.google.firebase.database.ValueEventListener;

/**
* A GeoFire instance is used to store geo location data in Firebase.
@@ -172,14 +175,14 @@ public void setLocation(final String key, final GeoLocation location, final Comp
updates.put("g", geoHash.getGeoHashString());
updates.put("l", Arrays.asList(location.latitude, location.longitude));
if (completionListener != null) {
keyRef.setValue(updates, geoHash.getGeoHashString(), new DatabaseReference.CompletionListener() {
keyRef.updateChildren(updates, new DatabaseReference.CompletionListener() {
@Override
public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
completionListener.onComplete(key, databaseError);
}
});
} else {
keyRef.setValue(updates, geoHash.getGeoHashString());
keyRef.updateChildrenAsync(updates);
}
}

@@ -212,7 +215,7 @@ public void onComplete(DatabaseError databaseError, DatabaseReference databaseRe
}
});
} else {
keyRef.setValue(null);
keyRef.setValueAsync(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain your decision to move to Async here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like, that the firebase developer changed the name of that function if you do not add a CompletionListener. Before you could call setValue without listener, now you have to call setValueAsync if you do not want to use a listener. Since there is no listener required, i changed it to setValueAsync.

Copy link
Author

@jwiesmann jwiesmann Sep 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to mention. I assume this is the fix for #28, since this function has been changed! (if you check some posts on stackoverflow.com, you will see that they suggest you to use a CompletionListener, which would call the 'old' function) And SetValue must have always been async

}
}