Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/foursquare/placepicker-sdk-sample
An SDK to help developers add a place picker to their app and also quickly access the Foursquare place that their user is at.
https://github.com/foursquare/placepicker-sdk-sample
Last synced: 3 days ago
JSON representation
An SDK to help developers add a place picker to their app and also quickly access the Foursquare place that their user is at.
- Host: GitHub
- URL: https://github.com/foursquare/placepicker-sdk-sample
- Owner: foursquare
- License: apache-2.0
- Created: 2015-11-14T01:28:10.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-07T10:48:37.000Z (about 7 years ago)
- Last Synced: 2024-04-14T07:56:09.816Z (7 months ago)
- Language: Java
- Size: 899 KB
- Stars: 11
- Watchers: 6
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Place Picker SDK
==================
An SDK to help developers add a place picker to their app and also quickly access the Foursquare place that their user is at.Download
----------
```groovy
compile 'com.foursquare:placepicker:0.6.1'
```Demo
----------
![currentplace](resources/placepicker-currentplace.gif)
![pickplace](resources/placepicker-pickplace.gif)
![changelocation](resources/placepicker-changelocation.gif)Usage
----------Initialize the SDK with your consumer key and secret.
```java
PlacePickerSdk.with(new PlacePickerSdk.Builder(this)
.consumer(CONSUMER_KEY, CONSUMER_SECRET)
.imageLoader(new PlacePickerSdk.ImageLoader() {
@Override
public void loadImage(Context context, ImageView v, String url) {
Glide.with(context)
.load(url)
.placeholder(R.drawable.category_none)
.dontAnimate()
.into(v);
}
})
.build());
```If you want to get the current place of your user:
```java
private void getClosestPlace() {
PlacePickerSdk.get().getCurrentPlace(new PlacePickerSdk.CurrentPlaceResult() {
@Override
public void success(Venue venue, boolean confident) {
Toast.makeText(MainActivity.this,"Got closest place " + venue.getName() + " Confident? " + confident, Toast.LENGTH_LONG).show();
}@Override
public void fail() {
}
});
}
```To launch the place picker, open the intent and handle the result in onActivityResult():
```java
private void pickPlace() {
Intent intent = new Intent(this, PlacePicker.class);
startActivityForResult(intent, 9001);
}@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == PlacePicker.PLACE_PICKED_RESULT_CODE) {
Venue place = data.getParcelableExtra(PlacePicker.EXTRA_PLACE);
Toast.makeText(this, place.getName(), Toast.LENGTH_LONG).show();
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
```