Giter Site home page Giter Site logo

msoftware / smarty-streets-autocompletetextview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from raczo/smarty-streets-autocompletetextview

0.0 2.0 0.0 126 KB

Gradle library. Android AutocompleteTextView that receives and displays address suggestions from Smarty Streets.

License: Apache License 2.0

Java 100.00%

smarty-streets-autocompletetextview's Introduction

Smarty Streets AutoCompleteTextView

Download

Gradle library. Android AutoCompleteTextView that receives and displays US address suggestions from SmartyStreets's US Autocomplete API.

SmartyStreet's Android SDK does not offer address suggestions, it only offers address verification and zip code lookup.

Demo

Yes, there is a demo app!

Demo app repository: https://github.com/RacZo/SmartyStreets-AutoComplete-Demo

Dependencies

If your app is already using the following SUPER AWESOME libraries:

  1. Google's Gson version 2.8.0 https://github.com/google/gson
  2. Square's okhttp version 3.6.0 https://github.com/square/okhttp
  3. Square's okhttp-logging-interceptor version 3.6.0 https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor

you are set! If not, add the following to your app's build.gradle:

compile 'com.google.code.gson:gson:2.8.'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'

Installation

Via Gradle, by putting the following in your build.gradle:

compile 'com.oscarsalguero:smartystreetsautocomplete:0.0.3'

Or Maven:

<dependency>
  <groupId>com.oscarsalguero</groupId>
  <artifactId>smartystreetsautocomplete</artifactId>
  <version>0.0.3</version>
  <type>pom</type>
</dependency>

Usage

  1. Sign up for an account on https://smartystreets.com and create a Website key (API key).

  2. Do not forget to add <uses-permission android:name="android.permission.INTERNET" /> to your app's Manifest.xml.

  3. Create an adapter class called "AddressAutocompleteAdapter" and make it extend "AbstractAddressAutocompleteAdapter", implement the required methods and define a layout for the dropdown item (R.layout.dropdown_text_item).

  4. You will need your API key and a "referer" (host you entered when you created your key). The referer in your app must have "https://" as prefix or the API won't work.

    <com.oscarsalguero.smartystreetsautocomplete.SmartyStreetsAutocompleteTextView
        android:id="@+id/autocomplete_text_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:completionHint="Number Street, City State"
        android:completionThreshold="1"
        android:hint="Address"
        android:maxLength="100"
        app:ssacv_adapterClass=".adapter.AddressAutocompleteAdapter"
        app:ssacv_referer="YOUR_REFERER"
        app:ssacv_suggestions="5"
        app:ssacv_webApiKey="YOUR_WEBSITE_KEY" />
  5. To capture the address selection (when the user taps a suggestion) you'll use the provided listener:

    autoCompleteTextView.setOnAddressSelectedListener(new OnAddressSelectedListener() {
       @Override
       public void onAddressSelected(@NonNull Address address) {
       }
    });

And... voilà!

Contributing

  1. Fork this repo and clone your fork. Create an empty file called "bintray.gradle" in the root of your project.
  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 I'll review your changes to see if they make it to the next release.

Issues

Use this repo's github issues.

Based On

SeatGeek's autocomplete library for Google Places https://github.com/seatgeek/android-PlacesAutocompleteTextView and the fact SmartyStreet's Android SDK does not offer address suggestions.

License

Copyright 2017 Oscar Salguero

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

smarty-streets-autocompletetextview's People

Contributors

raczo avatar

Watchers

Michael jentsch avatar  avatar

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.