本文整理汇总了Java中com.parse.ParseGeoPoint类的典型用法代码示例。如果您正苦于以下问题:Java ParseGeoPoint类的具体用法?Java ParseGeoPoint怎么用?Java ParseGeoPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParseGeoPoint类属于com.parse包,在下文中一共展示了ParseGeoPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLocationEvent
import com.parse.ParseGeoPoint; //导入依赖的package包/类
public void onLocationEvent(Location location) {
if (location.getAccuracy() < LOCATION_ACCURACY_THRESHOLD) {
if (_locationCache.size() == 10) {
_locationCache.remove(0);
}
_locationCache.add(location);
if (isActive()) {
Record record = new Record();
int lastDetectedActivity = getLastDetectedActivityType();
if (lastDetectedActivity == ON_FOOT) {
lastDetectedActivity = WALKING;
}
record.setActivityType(lastDetectedActivity);
record.setUser(ParseUser.getCurrentUser());
record.setLocation(new ParseGeoPoint(location.getLatitude(),
location.getLongitude()));
Account.get()
.addRecord(record);
}
}
}
示例2: getEventFromParseObject
import com.parse.ParseGeoPoint; //导入依赖的package包/类
public static Event getEventFromParseObject(@NonNull ParseObject parseObject){
ParseGeoPoint location = parseObject.getParseGeoPoint(Event.LOCATION);
ParseFile parseFile = parseObject.getParseFile(Event.IMAGE);
return new Event(parseObject.getObjectId(),
parseObject.getString(Event.TITLE),
parseObject.getString(Event.DESCRIPTION),
location != null? location.getLatitude() : Event.INVALID_LOCATION,
location != null? location.getLongitude() : Event.INVALID_LOCATION,
parseObject.getString(Event.LOCATION_SUMMARY),
parseObject.getString(Event.LOCATION_DESCRIPTION),
parseFile != null? parseFile.getUrl() : null,
parseObject.getDate(Event.INITIAL_DATE),
// If end date is null, set it as initial date, so we can use it in our order by
parseObject.getDate(Event.END_DATE) != null? parseObject.getDate(Event.END_DATE) : parseObject.getDate(Event.INITIAL_DATE),
parseObject.getInt(Event.TYPE),
parseObject.getBoolean(Event.ENABLED),
(parseObject.getNumber(Event.GOING) != null)? parseObject.getNumber(Event.GOING).longValue() : 0,
parseObject.getString(Event.LINK_URL),
parseObject.getString(Event.LINK_TEXT),
parseObject.getUpdatedAt()
);
}
示例3: onItemClick
import com.parse.ParseGeoPoint; //导入依赖的package包/类
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ParseGeoPoint userLocation = mUsers.get(position)
.getUserDetail()
.getLocation();
LatLng latLng = new LatLng(userLocation.getLatitude(),
userLocation.getLongitude());
mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
Marker userMarker = mMarkers.get(mUsers.get(position).getObjectId());
if (userMarker != null) {
userMarker.showInfoWindow();
}
}
示例4: bindRestaurantViewHolder
import com.parse.ParseGeoPoint; //导入依赖的package包/类
public void bindRestaurantViewHolder() {
if (restaurantHolder != null && restaurant != null) {
activity.setTitle(restaurant.getName());
restaurantHolder.address.setText(restaurant.getAddressLine());
parseLocation = restaurant.getLocation();
if (parseLocation != null) {
LatLng deviceLoc = LocationService.pollDeviceLocation(activity);
restaurantHolder.proximity.setText(restaurant.getDistanceFromString(new ParseGeoPoint(deviceLoc.latitude,deviceLoc.longitude)));
LatLng resLoc = new LatLng(parseLocation.getLatitude(), parseLocation.getLongitude());
restaurantHolder.updateMap(resLoc, restaurant.getName());
}
}
}
示例5: getLocation
import com.parse.ParseGeoPoint; //导入依赖的package包/类
public ParseGeoPoint getLocation(Context context) {
// Geisel Library - Default Location
double latitude = 32.881122;
double longitude = -117.237631;
LocationService userLocation;
if (!Build.FINGERPRINT.startsWith("generic")) {
userLocation = new LocationService(context);
// Is user location available and are we not running in an emulator
if (userLocation.canGetLocation()) {
latitude = userLocation.getLatitude();
longitude = userLocation.getLongitude();
} else {
userLocation.showSettingsAlert();
}
}
return new ParseGeoPoint(latitude,longitude);
}
示例6: populateMap
import com.parse.ParseGeoPoint; //导入依赖的package包/类
private void populateMap() {
final GoogleMap map = fragment.getMap();
map.setMyLocationEnabled(false);
fragment.getView().post(new Runnable() {
@Override
public void run() {
LatLngBounds.Builder builder = new LatLngBounds.Builder();
final ParseGeoPoint pt = user.getLocation();
final LatLng latlng = new LatLng(pt.getLatitude(), pt
.getLongitude());
map.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_CYAN))
.position(latlng));
builder.include(latlng);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, 13));
}
});
}
示例7: loadMentors
import com.parse.ParseGeoPoint; //导入依赖的package包/类
private void loadMentors(final ParseGeoPoint geoPoint) {
Double distance = 50.0;
getProgressBar().setVisibility(View.VISIBLE);
DataService.getMentors(MentorListActivity.this, geoPoint, distance, mSkill, new FindCallback<User>() {
@Override
public void done(final List<User> users, ParseException e) {
if (e == null) {
User.saveAllUsers(users);
DataService.getMentees(User.getUserFacebookIds(users), new Runnable() {
@Override
public void run() {
mentorListAdapter.addAll(User.sortedByMenteeCount(users));
getProgressBar().setVisibility(View.INVISIBLE);
}
});
} else {
e.printStackTrace();
}
setupDrawer();
}
});
}
示例8: getDistanceFrom
import com.parse.ParseGeoPoint; //导入依赖的package包/类
public static String getDistanceFrom(ParseUser otherUser){
//Location
ParseGeoPoint myLocation = ParseUser.getCurrentUser().getParseGeoPoint(Enums.ParseKey.USER_LOCATION);
ParseGeoPoint otherLocation = null;
if(otherUser != null)
otherLocation = otherUser.getParseGeoPoint(Enums.ParseKey.USER_LOCATION);
//Calculate distance
double km = 0;
if(otherUser != null && otherLocation != null)
km = myLocation.distanceInKilometersTo(otherLocation);
else
km = Math.random() * 4;
//Update ui
if(km < 0.5){
int m = (int)(km * 100);
m = Math.max(m, 10); //10 meters at least
return String.format("within %d m from you", m);
}
else{
return String.format("within %.1f km from you", km);
}
}
示例9: onReceive
import com.parse.ParseGeoPoint; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
try {
final LocationInfo locationInfo = (LocationInfo) intent.getSerializableExtra(LocationLibraryConstants.LOCATION_BROADCAST_EXTRA_LOCATIONINFO);
ParseUser.getCurrentUser().put(Enums.ParseKey.USER_LOCATION,
new ParseGeoPoint(locationInfo.lastLat, locationInfo.lastLong));
Log.d("Location my", locationInfo.lastLat + " " + locationInfo.lastLong);
ParseUser.getCurrentUser().saveInBackground();
}
catch (Exception e){
Log.e("location error:", e.getMessage());
}
if(MainActivity.gi() != null)
MainActivity.gi().onLocationUpdate();
}
示例10: retrieveLocations
import com.parse.ParseGeoPoint; //导入依赖的package包/类
public void retrieveLocations(final Callback<List<LatLng>> locationsCallback) {
ParseQuery<ParseObject> query = ParseQuery.getQuery("Location");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> parseObjects, ParseException e) {
if (e == null) {
ArrayList<LatLng> locations = new ArrayList<LatLng>();
for (ParseObject object : parseObjects) {
ParseGeoPoint geo = object.getParseGeoPoint("geo");
locations.add(new LatLng(geo.getLatitude(), geo.getLongitude()));
}
locationsCallback.got(locations);
}
}
});
}
示例11: onStartCommand
import com.parse.ParseGeoPoint; //导入依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
Log.e("Network Loc Service", "Service running");
AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
Calendar timeOff9 = Calendar.getInstance();
Intent intent2 = new Intent(this,MyReceiver.class);
PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent2,
PendingIntent.FLAG_UPDATE_CURRENT);
am.set(AlarmManager.RTC_WAKEUP, timeOff9.getTimeInMillis() + 55000, sender);
ParseGeoPoint pt = new ParseGeoPoint(getLocation().getLatitude(),getLocation().getLongitude());
ParseUser person = ParseUser.getCurrentUser();
if(person==null)
{
stopSelf();
return 0;
}
person.put("Geolocation",pt);
person.saveInBackground();
return START_STICKY;
}
示例12: onLocationChanged
import com.parse.ParseGeoPoint; //导入依赖的package包/类
@Override
public void onLocationChanged(Location location) {
Log.d(ServiceLocationListener.class.getSimpleName(),
"Provider: " +location.getProvider() + "|" +
"Lat/Lng: " + location.getLatitude() + "/" + location.getLongitude());
if (LocalDb.getInstance() != null) {
mCurrentUser = LocalDb.getInstance().getCurrentUser();
UserDetail userDetail = mCurrentUser.getUserDetail();
userDetail.setLocation(
new ParseGeoPoint(
location.getLatitude(),
location.getLongitude()));
userDetail.setProvider(location.getProvider());
userDetail.setActive(true);
try {
userDetail.save();
} catch (ParseException e) {
Log.d(ServiceLocationListener.class.getSimpleName(),
e.getMessage());
}
}
}
示例13: getDistanceFrom
import com.parse.ParseGeoPoint; //导入依赖的package包/类
public double getDistanceFrom(ParseGeoPoint location) {
ParseGeoPoint restaurant = getParseGeoPoint("location");
if (restaurant == null) {
return 0.0;
}
return location.distanceInMilesTo(restaurant);
}
示例14: viewUserProfile
import com.parse.ParseGeoPoint; //导入依赖的package包/类
public static void viewUserProfile(final Context context, final long userId, final ParseGeoPoint geoPoint) {
final Intent intent = new Intent(context, ViewProfileActivity.class);
intent.putExtra(ViewProfileActivity.USER_ID_KEY, userId);
intent.putExtra(ViewProfileActivity.LATITUDE_KEY, geoPoint.getLatitude());
intent.putExtra(ViewProfileActivity.LONGITUDE_KEY, geoPoint.getLongitude());
context.startActivity(intent);
}
示例15: updateProfile
import com.parse.ParseGeoPoint; //导入依赖的package包/类
@Override
protected void updateProfile(final User profileUser) {
if (etAddress.getText() != null) {
profileUser.setAddress(etAddress.getText().toString().trim());
profileUser.setAboutMe(etAboutme.getText().toString().trim());
Utils.geocode(getActivity(), new Utils.LocationParams(etAddress.getText().toString()), new Async.Block<Address>() {
@Override
public void call(final Address address) {
if (address != null) {
profileUser.setLocation(new ParseGeoPoint(address.getLatitude(), address.getLongitude()));
}
}
});
}
}