use of com.firebase.geofire.GeoLocation in project geofire-java by firebase.
the class SFVehiclesActivity method onCameraChange.
@Override
public void onCameraChange(CameraPosition cameraPosition) {
// Update the search criteria for this geoQuery and the circle on the map
LatLng center = cameraPosition.target;
double radius = zoomLevelToRadius(cameraPosition.zoom);
this.searchCircle.setCenter(center);
this.searchCircle.setRadius(radius);
this.geoQuery.setCenter(new GeoLocation(center.latitude, center.longitude));
// radius in km
this.geoQuery.setRadius(radius / 1000);
}
use of com.firebase.geofire.GeoLocation in project geofire-java by firebase.
the class GeoFireTestingRule method setLocation.
/**
* Sets a given location key from the latitude and longitude on the provided Geofire instance.
* This operation will run asychronously or synchronously depending on the wait boolean.
*/
public void setLocation(GeoFire geoFire, String key, double latitude, double longitude, boolean wait) {
final SimpleFuture<DatabaseError> futureError = new SimpleFuture<DatabaseError>();
geoFire.setLocation(key, new GeoLocation(latitude, longitude), new GeoFire.CompletionListener() {
@Override
public void onComplete(String key, DatabaseError error) {
futureError.put(error);
}
});
if (wait) {
try {
assertNull(futureError.get(timeout, TimeUnit.SECONDS));
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (TimeoutException e) {
fail("Timeout occured!");
}
}
}
Aggregations