public void setLocation ( final String key , final GeoLocation location , final CompletionListener completionListener ) { if ( key == null ) { throw new NullPointerException ( ) ; } DatabaseReference keyRef = this . getDatabaseRefForKey ( key ) ; GeoHash geoHash = new GeoHash ( location ) ; Map < String , Object > updates = new HashMap <> ( ) ; 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 ( ) { @ Override public void onComplete ( DatabaseError databaseError , DatabaseReference databaseReference ) { completionListener . onComplete ( key , databaseError ) ; } } ) ; } else { keyRef . setValue ( updates , geoHash . getGeoHashString ( ) ) ; } }
Sets the location for a given key .