本文整理汇总了Java中com.firebase.geofire.GeoFire类的典型用法代码示例。如果您正苦于以下问题:Java GeoFire类的具体用法?Java GeoFire怎么用?Java GeoFire使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GeoFire类属于com.firebase.geofire包,在下文中一共展示了GeoFire类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.firebase.geofire.GeoFire; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
Firebase.setAndroidContext(this);
firebase = new Firebase("https://brilliant-inferno-9747.firebaseio.com/web/data");
geofire = new GeoFire(firebase);
if(mGoogleApiClient == null){
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tutor);
}
示例2: waitForGeoFireReady
import com.firebase.geofire.GeoFire; //导入依赖的package包/类
/** This lets you blockingly wait until the onGeoFireReady was fired on the provided Geofire instance. */
public void waitForGeoFireReady(GeoFire geoFire) throws InterruptedException {
final Semaphore semaphore = new Semaphore(0);
geoFire.getDatabaseReference().addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
semaphore.release();
}
@Override
public void onCancelled(DatabaseError databaseError) {
fail("Firebase error: " + databaseError);
}
});
assertTrue("Timeout occured!", semaphore.tryAcquire(timeout, TimeUnit.SECONDS));
}
示例3: HabitEventRepository
import com.firebase.geofire.GeoFire; //导入依赖的package包/类
/**
* An event repository is tied to a particular user id
* @param userId the user id
*/
public HabitEventRepository(String userId) {
mHabitEventsRef = FirebaseDatabase.getInstance().getReference("events/" + userId);
this.userId = userId;
mGeoFireRef = FirebaseDatabase.getInstance().getReference("events_geofire/");
geoFire = new GeoFire(mGeoFireRef);
}
示例4: open
import com.firebase.geofire.GeoFire; //导入依赖的package包/类
/**
* Set query radius to 5km
*/
@Override
public void open() {
nearbyEvents.clear();
DatabaseReference geofire_ref = FirebaseDatabase.getInstance().getReference("events_geofire");
GeoFire geoFire = new GeoFire(geofire_ref);
geoQuery = geoFire.queryAtLocation(loc, 5);
geoQuery.addGeoQueryEventListener(this);
}
示例5: saveToFirebase
import com.firebase.geofire.GeoFire; //导入依赖的package包/类
public static void saveToFirebase(GeoFire geoFire,Firebase db, Tutor tutor, Location location){
if(location != null) {
Firebase tutorStore = db.child("tutors").child(tutor.getFullName());
tutorStore.setValue(tutor);
geoFire.setLocation(tutor.getFullName(), new GeoLocation(location.getLatitude(), location.getLongitude()));
}
}
示例6: onCreate
import com.firebase.geofire.GeoFire; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sfvehicles);
// setup map and camera position
SupportMapFragment mapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
this.map = mapFragment.getMap();
LatLng latLngCenter = new LatLng(INITIAL_CENTER.latitude, INITIAL_CENTER.longitude);
this.searchCircle = this.map.addCircle(new CircleOptions().center(latLngCenter).radius(1000));
this.searchCircle.setFillColor(Color.argb(66, 255, 0, 255));
this.searchCircle.setStrokeColor(Color.argb(66, 0, 0, 0));
this.map.moveCamera(CameraUpdateFactory.newLatLngZoom(latLngCenter, INITIAL_ZOOM_LEVEL));
this.map.setOnCameraChangeListener(this);
FirebaseOptions options = new FirebaseOptions.Builder().setApplicationId("geofire").setDatabaseUrl(GEO_FIRE_DB).build();
FirebaseApp app = FirebaseApp.initializeApp(this, options);
// setup GeoFire
this.geoFire = new GeoFire(FirebaseDatabase.getInstance(app).getReferenceFromUrl(GEO_FIRE_REF));
// radius in km
this.geoQuery = this.geoFire.queryAtLocation(INITIAL_CENTER, 1);
// setup markers
this.markers = new HashMap<String, Marker>();
}
示例7: onCreate
import com.firebase.geofire.GeoFire; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_nearby);
geokeys = new ArrayList<>();
geoLocations = new ArrayList<>();
geoDistances = new ArrayList<>();
mToolbar = findViewById(R.id.nearby_app_bar);
msharedPref = PreferenceManager.getDefaultSharedPreferences(this);
setSupportActionBar(mToolbar);
if(getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("Nearby Areas");
}
//initializing the Firebase storage
ref = FirebaseDatabase.getInstance().getReference("GeoFire");
mEntertainmentref = FirebaseDatabase.getInstance().getReference("Entertainments");
geoFire = new GeoFire(ref);
//for displaying the results
mRecyclerView = findViewById(R.id.nearby_recyclerView);
mRecyclerView.setHasFixedSize(true);
mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
//Location Manager book keeping stuff
locationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
Criteria locationCriteria = new Criteria();
String providerName = locationManager.getBestProvider(locationCriteria,
true);
if(providerName != null) {
mlocation = locationManager.getLastKnownLocation(providerName);
if(mlocation == null){
locationManager.requestLocationUpdates(providerName, 1000, 0, this);
}else{
processLocation();
}
}
}
示例8: initDBConnection
import com.firebase.geofire.GeoFire; //导入依赖的package包/类
public static void initDBConnection(){
rootReference = new Firebase("https://brilliant-inferno-9747.firebaseio.com/web/data");
geoFire = new GeoFire(rootReference);
}
示例9: getGeoFire
import com.firebase.geofire.GeoFire; //导入依赖的package包/类
public static GeoFire getGeoFire(){
return geoFire;
}
示例10: newTestGeoFire
import com.firebase.geofire.GeoFire; //导入依赖的package包/类
/** This will return you a new Geofire instance that can be used for testing. */
public GeoFire newTestGeoFire() {
return new GeoFire(databaseReference.child(randomAlphaNumericString(16)));
}
示例11: setLoc
import com.firebase.geofire.GeoFire; //导入依赖的package包/类
/**
* Sets a given location key from the latitude and longitude on the provided Geofire instance.
* This operation will run asychronously.
*/
public void setLoc(GeoFire geoFire, String key, double latitude, double longitude) {
setLoc(geoFire, key, latitude, longitude, false);
}
示例12: removeLoc
import com.firebase.geofire.GeoFire; //导入依赖的package包/类
/**
* Removes a location on the provided Geofire instance.
* This operation will run asychronously.
*/
public void removeLoc(GeoFire geoFire, String key) {
removeLoc(geoFire, key, false);
}