Giter VIP home page Giter VIP logo

android-placesautocompletetextview's Introduction

android-PlacesAutocompleteTextView

Build Status Android Arsenal

An AutocompleteTextView that interacts with the Google Maps Places API to provide location results and caches selected results in a history file for later use

gif

Installing

The PlacesAutocompleteTextView is available from the sonatype snapshots repository. Use the following in your build.gradle:

repositories {
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}

dependencies {
    compile 'com.seatgeek:placesautocomplete:0.3-SNAPSHOT'
}

Basic setup and usage

  1. You'll need a Google Server API key for you application. There are instructions on how to set up your API project and generate a key here

  2. Your application will need the android.permission.INTERNET permission in its manifest for the View to interact with the Google Maps API

  3. With your API key, you're ready to add the PlacesAutocompleteTextView to your layout xml:

    <com.seatgeek.placesautocomplete.PlacesAutocompleteTextView
       android:id="@+id/places_autocomplete"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       app:pacv_googleMapsApiKey="<YOUR_GOOGLE_API_KEY>"/>
  4. Finally, you'll likely want a listener in your UI to know when the user has selected an item from the dropdown:

    placesAutocomplete.setOnPlaceSelectedListener(
           new OnPlaceSelectedListener() {
               @Override
               public void onPlaceSelected(final Place place) {
                  // do something awesome with the selected place
               }
           }
    );
  5. That's it!

Note: you can treat the PlacesAutocompleteTextView the same as any AutocompleteTextView as it extends from the framework AutocompleteTextView. This means you can use custom styles with all the standard view properties.

Advanced usage/customization

XML properties

There are a few XML properties that can control some of the functionality of the autocomplete view:

xml property java method description
pacv_historyFile setHistoryManager() By default, the PlacesAutocompleteTextView will save the history of the selected Place's in a file on the file system. This is great for cases when your user may be typing in the same address in different parts of your UI or across different sessions. If you'd like to simply change the location of the file on the filesystem, you can specify the path string here. By default, the file is stored in the application cache dir under autocomplete/pacv_history.json. If this is a feature that you'd like to disable, you can set the property in xml to @null or call setHistoryManager(null).
pacv_resultType setResultType() The Places API can return various types of Places depending on what your application is looking to allow the user to select. By default, the PlacesAutocompleteTextView only requests items of type address, which returns locations associated with a full postal address, public or residential. You can change this to also be geocode for any address or establishment for non-residential addresses
pacv_adapterClass setAdapter() If you don't like the default Adapter for displaying the items in the dropdown list (it is pretty basic by default), you can override it by specifying your own in xml (by passing the fully-qualified classname) or using setAdapter(). An important note: because of how the filtering functionality works in the PlacesAutocompleteTextView, your custom adapter must extend AbstractPlacesAutocompleteAdapter.
pacv_clearEnabled showClearButton() Show the typicall X button to the right of the PlacesAutocompleteTextView to let user clear the text. Defaults to false. Other methods for controlling the clear button is setImgClearButton() Override the default Clear image and add your own, setOnClearListener() Override the clear listener like what should happen when the X is pressed, default is clear text, showClearButton() show/hide it.

Need more details? PlaceDetails

One of the requirements of our usage of this view was autofilling the payment and shipping addresses in our checkout flow. By default, the returned Place from the Google Maps API doesn't have the full set of address components (city, state, postal, street address, etc.) and instead provides it "conveniently" in a human readable string like "235 Park Ave South, New York, NY 10003". Which is probably pretty tricky to parse to get the address components. Enter the "Place Details" API. The PlacesAutocompleteTextView provides a helper method getDetailsFor(Place, DetailsCallback) that you can use to easily fetch the extra details that you might need. The PlaceDetails object has a lot more than just address components as well, so if you're building a complex UI around a location, this is probably the API call that you'll need to make.

If you have concerns about configuration changes while the details request is in-flight, you can grab the instance of the PlacesApi from PlacesAutoCompleteTextView#getApi() and manage the details request yourself.

See the example project for this API in use.

Getting stylish

The PlacesAutocompleteTextView is styleable using the pacv_placesAutoCompleteTextViewStyle global style attribute. The style should extend from PACV.Widget.PlacesAutoCompleteTextView to get the default style's parameters, e.g.:

styles.xml:

        <style name="Widget.PlacesAutoCompleteTextView.Styled"
               parent="PACV.Widget.PlacesAutoCompleteTextView">
            <item name="android:background">@drawable/my_edit_text_background</item>
            <item name="android:textAppearance">@style/MyTextAppearance</item>
        </style>

themes.xml:

        <style name="AppTheme" parent="@style/YourParentStyle">
            <item name="pacv_placesAutoCompleteTextViewStyle">@style/Widget.PlacesAutoCompleteTextView.Styled</item>
        </style>

Location biasing

A common thing that you might want to do is bias the place results to the location of the user. By default, the PlacesAutocompleteTextView will bias the results by a geoip lookup of the device's IP address. If your app has different requirements for where you want to bias the address results to or you want more accuracy than a geoip lookup, you can pass an Android Location into the PlacesAutocompleteTextView using the #setCurrentLocation() method.

You can tweak the biasing radius by using the setRadiusMeters(Long) method.

If you'd like to disable biasing completely, you can setLocationBiasEnabled(false)

Purpose and "why not use Google Play Services?"

This project was started internally before the Places API was released on Google Play Services and we needed a way to make entering your payment and shipping addresses in our Android app easier. The reason that this project is still alive and hasn't migrated to Google Play Services is twofold:

  1. It's still impossible to fetch the full PlaceDetails from the Google Play Services implementation [ref], without which you cannot get the full breakdown of address components
  2. It handles hooking the UI components to the data for you to accelerate your development process. With Google Play Services you still need to create your own FilterAdapter, AutocompleteTextView, etc.

Contributing

  1. Fork this repo and clone your fork
  2. Make your desired changes
  3. Add tests for your new feature and ensure all tests are passing
  4. Commit and push
  5. Submit a Pull Request through Github's interface and a project maintainer will decide your change's fate.

Note: issues can be submitted via github issues

License

PlacesAutocompleteTextView is released under a BSD 2-Clause License, viewable here

android-placesautocompletetextview's People

Contributors

cstarner avatar qtmspin avatar re3lex avatar sddamico avatar taslimoseni avatar tpincumbe avatar vitalnik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-placesautocompletetextview's Issues

Set text color of suggestions?

I'm having trouble with styling the popup window. My application has a dark theme and the color of the suggestion text is nearly white on the nearly white background. My efforts to change the text color to something legible have thus far been unfruitful. Assistance would be most appreciated!

Crash APK signée

Crash when try to enter word in TextView
AndroidRuntime: FATAL EXCEPTION: Filter
Process: com.visitou.visitouandroid, PID: 20333
java.lang.AssertionError: java.lang.NoSuchFieldException: ROUTE
at com.google.a.b.a.n$a.(Unknown Source)
at com.google.a.b.a.n$24.a(Unknown Source)
at com.google.a.f.a(Unknown Source)
at com.google.a.b.a.b.a(Unknown Source)
at com.google.a.f.a(Unknown Source)
at com.google.a.b.a.i.a(Unknown Source)
at com.google.a.b.a.i.a(Unknown Source)
at com.google.a.b.a.i.a(Unknown Source)
at com.google.a.f.a(Unknown Source)
at com.google.a.b.a.b.a(Unknown Source)
at com.google.a.f.a(Unknown Source)
at com.google.a.b.a.i.a(Unknown Source)
at com.google.a.b.a.i.a(Unknown Source)
at com.google.a.b.a.i.a(Unknown Source)
at com.google.a.f.a(Unknown Source)
at com.google.a.f.a(Unknown Source)
at com.google.a.f.a(Unknown Source)
at com.seatgeek.placesautocomplete.d.b.a(Unknown Source)
at com.seatgeek.placesautocomplete.f.a$1.a(Unknown Source)
at com.seatgeek.placesautocomplete.f.a$1.b(Unknown Source)
at com.seatgeek.placesautocomplete.f.b.a(Unknown Source)
at com.seatgeek.placesautocomplete.f.a.a(Unknown Source)
at com.seatgeek.placesautocomplete.d.a(Unknown Source)
at com.seatgeek.placesautocomplete.a.c.performFiltering(Unknown Source)
at android.widget.Filter$RequestHandler.handleMessage(Filter.java:234)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: java.lang.NoSuchFieldException: ROUTE
at java.lang.Class.getField(Class.java:891)
at com.google.a.b.a.n$a.(Unknown Source) 
at com.google.a.b.a.n$24.a(Unknown Source) 
at com.google.a.f.a(Unknown Source) 
at com.google.a.b.a.b.a(Unknown Source) 
at com.google.a.f.a(Unknown Source) 
at com.google.a.b.a.i.a(Unknown Source) 
at com.google.a.b.a.i.a(Unknown Source) 
at com.google.a.b.a.i.a(Unknown Source) 
at com.google.a.f.a(Unknown Source) 
at com.google.a.b.a.b.a(Unknown Source) 
at com.google.a.f.a(Unknown Source) 
at com.google.a.b.a.i.a(Unknown Source) 
at com.google.a.b.a.i.a(Unknown Source) 
at com.google.a.b.a.i.a(Unknown Source) 
at com.google.a.f.a(Unknown Source) 
at com.google.a.f.a(Unknown Source) 
at com.google.a.f.a(Unknown Source) 
at com.seatgeek.placesautocomplete.d.b.a(Unknown Source) 
at com.seatgeek.placesautocomplete.f.a$1.a(Unknown Source) 
at com.seatgeek.placesautocomplete.f.a$1.b(Unknown Source) 
at com.seatgeek.placesautocomplete.f.b.a(Unknown Source) 
at com.seatgeek.placesautocomplete.f.a.a(Unknown Source) 
at com.seatgeek.placesautocomplete.d.a(Unknown Source) 
at com.seatgeek.placesautocomplete.a.c.performFiltering(Unknown Source) 
at android.widget.Filter$RequestHandler.handleMessage(Filter.java:234) 
at android.os.Handler.dispatchMessage(Handler.java:111) 
at android.os.Looper.loop(Looper.java:207) 
at android.os.HandlerThread.run(HandlerThread.java:61) 

Progueard rules

Hello, I use your project in my one and when I compile app with proguard I receive this error:

android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class com.seatgeek.placesautocomplete.PlacesAutocompleteTextView
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)

I tried

-keep class com.seatgeek.* {;}

But it doesn't help
Can you provide prgoard rules for your project?

NoSuchMethodException

Caused by: java.lang.NoSuchMethodException: [class android.content.Context, class com.seatgeek.placesautocomplete.PlacesApi, class com.seatgeek.placesautocomplete.model.AutocompleteResultType, interface com.seatgeek.placesautocomplete.history.AutocompleteHistoryManager]
at java.lang.Class.getConstructorOrMethod(Class.java:423)
at java.lang.Class.getConstructor(Class.java:397)

Troubling styling to a dark themed dropdown

Hey I am having trouble styling the dropdown to be a dark theme. This is what I get:

darktheme

My custom adapter looks like this:

public class PlacesAutocompleteAdapter extends AbstractPlacesAutocompleteAdapter {
    public PlacesAutocompleteAdapter(final Context context, final PlacesApi api, final AutocompleteResultType autocompleteResultType, final AutocompleteHistoryManager history) {
        super(context, api, autocompleteResultType, history);
    }

    @Override
    protected View newView(final ViewGroup parent) {
        return LayoutInflater.from(parent.getContext()).inflate(R.layout.dark_list_item, parent, false);
    }

    @Override
    protected void bindView(final View view, final Place item) {
        ((TextView)view).setText(item.description);
    }
}

The view is defined in my XML like this:

            <com.seatgeek.placesautocomplete.PlacesAutocompleteTextView
                android:id="@+id/et_di_address_line_1"
                style="@style/ClearableEditTextCheckout"
                android:completionThreshold="2"
                android:inputType="textPostalAddress|textCapWords|textNoSuggestions"
                android:nextFocusDown="@+id/et_di_address_line_2"
                android:text="@={deliveryViewModel.address1}"
                app:pacv_adapterClass="com.my.app.PlacesAutocompleteAdapter"
                app:pacv_googleMapsApiKey="@string/google_maps_key"/>

I have set the theme in my styles.xml:
@style/Widget.PlacesAutoCompleteTextView.Styled

<style name="Widget.PlacesAutoCompleteTextView.Styled"
       parent="PACV.Widget.PlacesAutoCompleteTextView">
    <item name="android:background">@color/suggested_card_dialog</item>
    <item name="android:textColor">@android:color/white</item>
</style>

Is there a way to force not to show results with Abbreviations

Using the PlacesAutocompleteTextView and search for
"Sydney, Camperdown, New South Wales, Australien"

Thanks for the PlacesAutocompleteTextView it's a grate view
I get result with both the Abbreviations result and without, like this:

Sydney, Camperdown, NSW, Australien
Sydney, Camperdown, New South Wales, Australien

It's the same on the web https://www.google.se/maps/

System scenario:
Lets say I have a system where user select a place including the "NSW" and from that on a database is setup with the address user have selected. Now lets say another user is doing the same and select the "New South Wales". Now my system hold two paths to the same place.

In PlacesAutocompleteTextView or maybe in Google Places Api, Is there some way to force eater on or do I have to detect this myself?

Google Server API key

Hello in using a Server key the production app throws this exception: This IP, site or mobile application is not authorized to use this API key. Request received from IP address How can I solve this?

Adapter View

Dude, I love your work man. I was using the AutoCompleteTextView, created custom adapter ext,. and working all these days.

I started using yours and love it, the only problem is my earlier AutoCompleteTextView was showing many suggestions (like 8-10) as soon as i begin typing a place name. But yours shows only 2 ... Kindly help.

Several problem

The following classes could not be instantiated:
- com.seatgeek.placesautocomplete.PlacesAutocompleteTextView (Open Class, Show Exception, Clear Cache)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE. If this is an unexpected error you can also try to build the project, then manually refresh the layout. Exception Details Write access not allowed during rendering (autocomplete)   at com.android.ide.common.rendering.RenderSecurityException.create(RenderSecurityException.java:52)   at java.io.File.mkdir(File.java:1311)   at java.io.File.mkdirs(File.java:1343)   at com.seatgeek.placesautocomplete.history.DefaultAutocompleteHistoryManager.fromPath   ... (DefaultAutocompleteHistoryManager.java:40)   at com.seatgeek.placesautocomplete.PlacesAutocompleteTextView.init(PlacesAutocompleteTextView.java:116)   at com.seatgeek.placesautocomplete.PlacesAutocompleteTextView.(PlacesAutocompleteTextView.java:81)   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)   at android.view.LayoutInflater.inflate(LayoutInflater.java:518)   at android.view.LayoutInflater.inflate(LayoutInflater.java:397) Copy stack to clipboard

And another problem

Turn off custom view rendering sandbox Diagnostic info for Studio bug report: Failed path: autocomplete Normal temp dir: C:\Users\hpProsg\AppData\Local\Temp\ Normalized temp dir: C:\Users\hpProsg\AppData\Local\Temp Canonical temp dir: C:\Users\hpProsg\AppData\Local\Temp os.name: Windows 10 os.version: 10.0 java.runtime.version: 1.8.0_112-release-b06Write access not allowed during rendering (autocomplete)   at com.android.ide.common.rendering.RenderSecurityException.create(RenderSecurityException.java:52)   at java.io.File.mkdir(File.java:1311)   at java.io.File.mkdirs(File.java:1343)   at com.seatgeek.placesautocomplete.history.DefaultAutocompleteHistoryManager.fromPath   ... (DefaultAutocompleteHistoryManager.java:40)   at com.seatgeek.placesautocomplete.PlacesAutocompleteTextView.init(PlacesAutocompleteTextView.java:116)   at com.seatgeek.placesautocomplete.PlacesAutocompleteTextView.(PlacesAutocompleteTextView.java:81)   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)   at android.view.LayoutInflater.inflate(LayoutInflater.java:518)   at android.view.LayoutInflater.inflate(LayoutInflater.java:397) Copy stack to clipboard Tip: Try to refresh the layout.

In the OnPlaceSelectedListener I wonder how to get a hold of the Status Codes

In the OnPlaceSelectedListener I wonder how to get a hold of the Status Codes I cannot see that it is propagated up to public void onPlaceSelected(final Place place)

The "status" field within the search response object contains the status of the request, and may contain debugging information to help you track down why the request failed. The "status" field may contain the following values:

OK indicates that no errors occurred; the place was successfully detected and at least one result was returned.
ZERO_RESULTS indicates that the search was successful but returned no results. This may occur if the search was passed a latlng in a remote location.
OVER_QUERY_LIMIT indicates that you are over your quota.
REQUEST_DENIED indicates that your request was denied, generally because of lack of an invalid key parameter.
INVALID_REQUEST generally indicates that a required query parameter (location or radius) is missing.

/Thanks

Location

How to get latitude and longitude

Add suggestion

One suggestion I have is that when you begin to write in the EditText appears something indicating that it is loading the search

I have issue in runtime. I am not getting autoplace data in this.

I got error When I have run the program. This error message is paste below.

E/MapsPlacesAutoComplete: Unable to fetch autocomplete results from the api
com.seatgeek.placesautocomplete.model.PlacesApiException: This IP, site or mobile application is not authorized to use this API key. Request received from IP address 0.00.000.00, with empty referer

add text before sent for search

i wanted to add a text (e.g: city name like New York) when user input a text for search.
in short i want to restrict the search area for address but the location and radius method doesn't work for me. so i want to add the name of the city before sending for search address and get the results only for that city. like implement the adapter class for PlaceAutocompleteTextView and Override the textChange method before calling the super add the wanted text or something like it.
is there any way for it?

How to get latitude and logitude from place?

I seen how you implement detailcallback to get city details but i want the exact latitude of the place we select.

 mAutocomplete.setOnPlaceSelectedListener(new OnPlaceSelectedListener() {
            @Override
public void onPlaceSelected(final Place place) {
       double lat = place.getLatitude();
       double lng = place.getLongitude();
});

Is there any way to get it that easily? If not then how? I am currently getting lat, lng via passing it in custom getAddress(String address). But want if any easy way available as I mentioned in my above code.

Thanks in advance

How to add a ProgressDialog before the public void onPlaceSelected(@No..

Thanks for the PlacesAutocompleteTextView.
I want to have a ProgressDialog while waiting for the onPlaceSelectedto fire.
How can I do that?
I try the .setOnItemSelectedListener()but that returned UnsupportedOperationException:
In the setOnItemSelectedListener() I could do showProgressDialog()

I see the AutoCompleteTextView``setOnItemClickListener() is not exposed but instead you throw new UnsupportedOperationException(), why is that?
I will try to fork it and modify :) would like a comment on this so it does not blow up

setOnPlaceSelectedListener in Fragment

Hi!

Is there a way to get the setOnPlaceSelectedListener working in a fragment? I can implement a Button.OnClickListener in a Fragment, but I do not know how to do that with the setOnPlaceSelectedListener.

Thanks.

I try to find a way to insert a `Fragment` `Context` into the adapter

Thanks all for the PlacesAutocompleteTextView it´s really helpful
I try to find a way to insert a Fragment Context into the adapter but ended up creating the setContext(..method as you can see down below.
Any ide how to do this in a better way?
in Fragment..

        mAutocomplete = (PlacesAutocompleteTextView) v.findViewById(R.id.autocomplete);
        mAutocomplete.setOnPlaceSelectedListener(this);
        ((TestPlacesAutocompleteAdapter)mAutocomplete.getAutocompleteAdapter()).setContext(this);

in AbstractPlacesAutocompleteAdapter

public class TestPlacesAutocompleteAdapter extends AddressFilterAdapter {
    public TestPlacesAutocompleteAdapter(final Context context, final PlacesApi api, final AutocompleteResultType resultType, final AutocompleteHistoryManager history) {
        super(context, api, resultType, history);
    }
    @Override
    protected View newView(final ViewGroup parent) {
        return LayoutInflater.from(parent.getContext()).inflate(R.layout.places_autocomplete_item, parent, false);
    }

    @Override
    protected void bindView(final View view, final Place item) {
        ((TextView) view).setText(item.description);
    }
}

public abstract class AddressFilterAdapter extends AbstractPlacesAutocompleteAdapter implements
       , Runnable {
    public AddressFilterAdapter(final Context context,
                                final PlacesApi api,
                                final AutocompleteResultType resultType,
                                final AutocompleteHistoryManager history) {
        super(context, api, resultType, history);
        mRefreshLock = new Object();
        mHandler = new Handler();
        mRefreshRequested = false;
        mRefreshInProgess = false;
        mNextRefresh = new Date();
    }
    public void setContext(HomeFragment context){

        this.mWeakReference = new WeakReference<HomeFragment>(context);
    }
    @Override
    public void run() {
        onChange();
    }
}

Consider a SearchView implementation

Some users of the library may prefer the ease of the SearchView interface. If there's enough support, it shouldn't be too difficult of a refactor to allow most of the Places Autocomplete components to provide data to a SearchView.

FileNotFound when historyFile set to null

From #11

E/MapsPlacesAutoComplete: Unable to load history from history file
E/MapsPlacesAutoComplete: java.io.FileNotFoundException: History file does not exist
E/MapsPlacesAutoComplete: at com.seatgeek.placesautocomplete.history.DefaultAutocompleteHistoryManager$1.executeInBackground(DefaultAutocompleteHistoryManager.java:68)
E/MapsPlacesAutoComplete: at com.seatgeek.placesautocomplete.history.DefaultAutocompleteHistoryManager$1.executeInBackground(DefaultAutocompleteHistoryManager.java:64)
E/MapsPlacesAutoComplete: at com.seatgeek.placesautocomplete.async.BackgroundExecutorService$2.run(BackgroundExecutorService.java:43)
E/MapsPlacesAutoComplete: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/MapsPlacesAutoComplete: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/MapsPlacesAutoComplete: at java.lang.Thread.run(Thread.java:818)

My google api key for the specific project does not work.

While using the com.seatgeek.placesautocomplete.PlacesAutocompleteTextView got the exception while search for place

Exception name com.seatgeek.placesautocomplete.model.PlacesApiException.
This IP, site or mobile application is not authorized to use this API key. Request received from IP address 122.169.212.109, with empty referer

Autocomplete crashing in Play Store version of app

The PlacesAutoCompleteTextView works perfectly fine when I'm running my app in Android Studio deployed to my USB device (using both release and debug build variants), but for some reason, when I deploy a Beta version and download it through the Play store, the app just stops when I start typing in an address.

My API key is using the Google Places API Web Service with no restrictions.

Any idea what's going on or how I can debug this?

search for an address or a business?

Is it possible to request a list of matching address and businesses? I've tried all
pacv_resultType combos, and it seems I'm limited to either businesses or addresses.

a request for dismissbutton

Wonder if it would be hard to add this functionality to PlacesAutocompleteTextView like:
Creating a clearable AutoCompleteTextView. (adding an ´x´ button to delete text content?

Here´s a tutorial doing this:
https://www.drzon.net/how-to-create-a-clearable-autocomplete-dropdown-with-autocompletetextview/

Some code from tutorial:

/**
 * sub class of {@link android.widget.AutoCompleteTextView} that includes a clear (dismiss / close) button with
 * a OnClearListener to handle the event of clicking the button
 * based on code from {@link http://www.gubed.net/clearableautocompletetextview}
 * @author Michael Derazon
 *
 */
public class ClearableAutoCompleteTextView extends AutoCompleteTextView {
	// was the text just cleared?
	boolean justCleared = false;

	// if not set otherwise, the default clear listener clears the text in the
	// text view
	private OnClearListener defaultClearListener = new OnClearListener() {

		@Override

Proguard rule needed

I´m building a release build but cannot get past his proguard related error:

Process: com.toy.android.production, PID: 13817
java.lang.NullPointerException: Attempt to read from field 'java.lang.Object android.widget.Filter$FilterResults.values' on a null object reference
   at com.seatgeek.placesautocomplete.adapter.PlacesApiFilter.publishResults(SourceFile:120)
   at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:282)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:158)
   at android.app.ActivityThread.main(ActivityThread.java:7225)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

In my proguard-rules.pro file I have the:

-keep class com.seatgeek{ *; }
-keep public class com.toy.android.ui.adapter.PlacesAutocompleteAdapter{ *; }

What am I missing please advice

Problem with a custom adapter

Hi everyone! First, awesome library. I realy like it.
I try create a custom a adapter and passing it to my xml, however i get a error occurs at run activity.
How to fix this bug? Thanks

Here is my xml

com.seatgeek.placesautocomplete.PlacesAutocompleteTextView
                            android:id="@+id/places_autocomplete"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            app:pacv_googleMapsApiKey="@string/API_server_key"
                        app:pacv_adapterClass="adapter.TestPlacesAutocompleteAdapter"

Here is log

Caused by: android.view.InflateException: Unable to find valid constructor with params Context, PlacesApi, AutocompleteResultType, and DefaultAutocompleteHistoryManager for specified adapterClass: com.teusoft.sirved.adapter.TestPlacesAutocompleteAdapter
                                           at com.seatgeek.placesautocomplete.PlacesAutocompleteTextView.adapterForClass(PlacesAutocompleteTextView.java:225)
                                           at com.seatgeek.placesautocomplete.PlacesAutocompleteTextView.init(PlacesAutocompleteTextView.java:127)
                                           at com.seatgeek.placesautocomplete.PlacesAutocompleteTextView.(PlacesAutocompleteTextView.java:78)
                                           at java.lang.reflect.Constructor.newInstance(Native Method) 
                                           at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 

Support language different than english in PlaceDetails

Hi,

getDetailsFor() method alway returning PlaceDetails in english because language parameter is not set in URL generated by PlacesApi.details() method.
This is an issue for non-english users.

I think best way is take to take system language as a base.

Not yet implemented, please have Gson on your classpath

I really like your lib, great job!

But I have following exception:
java.lang.UnsupportedOperationException: Not yet implemented, please have Gson on your classpath at com.seatgeek.placesautocomplete.json.AndroidPlacesApiJsonParser.autocompleteFromStream(AndroidPlacesApiJsonParser.java:15) at com.seatgeek.placesautocomplete.network.AbstractPlacesHttpClient$1.handleStreamResult(AbstractPlacesHttpClient.java:28) at com.seatgeek.placesautocomplete.network.AbstractPlacesHttpClient$1.handleStreamResult(AbstractPlacesHttpClient.java:24) at com.seatgeek.placesautocomplete.network.HttpUrlConnectionMapsHttpClient.executeNetworkRequest(HttpUrlConnectionMapsHttpClient.java:34) at com.seatgeek.placesautocomplete.network.AbstractPlacesHttpClient.executeAutocompleteRequest(AbstractPlacesHttpClient.java:24) at com.seatgeek.placesautocomplete.PlacesApi.autocomplete(PlacesApi.java:147) at com.seatgeek.placesautocomplete.adapter.PlacesApiFilter.performFiltering(PlacesApiFilter.java:76) at android.widget.Filter$RequestHandler.handleMessage(Filter.java:234) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.os.HandlerThread.run(HandlerThread.java:61)

Please tell me if You have some suggetions. Thanks in advance!

Information missing

setCurrentLocation() not give current location until set the radius by calling setRadiusMeters(). There is not mention in the document that user have to first set call the setRadiusMeters(radius) method for getting the current locations places.

Proguard can't find referrenced class com.squareup.okhttp.OkHttpClient

Hi, with proguard on and building I'm getting this issue:

21:48:44.593 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient
21:48:44.593 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient
21:48:44.593 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient
21:48:44.593 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient
21:48:44.593 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient
21:48:44.593 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.Request$Builder
21:48:44.593 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.Request$Builder
21:48:44.593 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.Request$Builder
21:48:44.594 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.Request$Builder
21:48:44.594 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient
21:48:44.594 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.Call
21:48:44.594 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.Response
21:48:44.594 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.ResponseBody
21:48:44.594 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.Request
21:48:44.594 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.Response
21:48:44.594 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.Request
21:48:44.594 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.Call
21:48:44.594 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.Response
21:48:44.594 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.ResponseBody
21:48:44.594 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.OkHttpClient
21:48:44.594 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.Request
21:48:44.594 [ERROR] [system.err] Warning: com.seatgeek.placesautocomplete.network.OkHttpPlacesHttpClient: can't find referenced class com.squareup.okhttp.Response

Manually importing Okhttp 2.2.0 results in the app running, but the features of this library not working (the autocomplete does not pop up).

Has anyone had this issue and know how to resolve it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.