Giter Site home page Giter Site logo

codemybrainsout / place-search-dialog Goto Github PK

View Code? Open in Web Editor NEW
234.0 13.0 59.0 3.67 MB

A place autocomplete search dialog which uses Google's places API for finding results.

License: Apache License 2.0

Java 100.00%
android google-places autocomplete-search-dialog location search

place-search-dialog's Introduction

Place Search Dialog

A place autocomplete search dialog which uses Google's places API for finding results.

The dialog searches for locations from all around the world. To customize it, set the new location bounds using .setLatLngBounds(BOUNDS)

How to use

Setup

PlaceSearchDialog requires Places API key by Google. You can get it from here.

Use the dialog as it is

 PlaceSearchDialog placeSearchDialog = new PlaceSearchDialog.Builder(this)
                .setLocationNameListener(new PlaceSearchDialog.LocationNameListener() {
                    @Override
                    public void locationName(String locationName) {
                        //set textview or edittext
                    }
                })
                .build();
placeSearchDialog.show();

or Customize it accordingly

 PlaceSearchDialog placeSearchDialog = new PlaceSearchDialog.Builder(this)
                .setHeaderImage(R.drawable.dialog_header)
                .setHintText("Enter location name")
                .setHintTextColor(R.color.light_gray)
                .setNegativeText("CANCEL")
                .setNegativeTextColor(R.color.gray)
                .setPositiveText("SUBMIT")
                .setPositiveTextColor(R.color.red)
                .setLatLngBounds(BOUNDS)
                .setLocationNameListener(new PlaceSearchDialog.LocationNameListener() {
                    @Override
                    public void locationName(String locationName) {
                        //set textview or edittext
                    }
                })
                .build();
placeSearchDialog.show();

Add this in your applications AndroidManifest.xml

<meta-data android:name="com.google.android.geo.API_KEY"
            android:value="YOUR_API_KEY" />

Installation

Gradle

Just use it as a dependency in your app's build.gradle file

dependencies {
    compile 'com.codemybrainsout.placesearchdialog:placesearch:1.0.1'
}

Maven

Ensure you have android-maven-plugin version that support aar archives and add following dependency:

<dependency>
  <groupId>com.codemybrainsout.placesearchdialog</groupId>
  <artifactId>placesearch</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>

Credits

This project was initiated by Code My Brains Out. You can contribute to this project by submitting issues or/and by forking this repo and sending a pull request.

Follow us on:

Facebook     Twitter

Author: Rahul Juneja

License

Copyright (C) 2016 Code My Brains Out

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.

place-search-dialog's People

Contributors

ahulr 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

place-search-dialog's Issues

Change string values

Hello , this dialog looks awesome. I got a question before using it : Is it possible to change those string values like "enter location" , "ok", "cancel" ? I would like them displayed in another language =) Thanks

and a side question:

What is this ? Do I need an api key for using location API's?

Crash on the second search

This library working perfectly, unless when I try to search again for the second time, the app crash. This is the error message:

FATAL EXCEPTION: main
                                                                       Process: app.trekkon.muslimdaily, PID: 3389
                                                                       java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(-1, class android.widget.DropDownListView) with Adapter(class com.codemybrainsout.placesearch.PlaceAutocompleteAdapter)]
                                                                           at android.widget.ListView.layoutChildren(ListView.java:1618)
                                                                           at android.widget.AbsListView.onLayout(AbsListView.java:2162)
                                                                           at android.view.View.layout(View.java:17637)
                                                                           at android.view.ViewGroup.layout(ViewGroup.java:5575)
                                                                           at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
                                                                           at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
                                                                           at android.view.View.layout(View.java:17637)
                                                                           at android.view.ViewGroup.layout(ViewGroup.java:5575)
                                                                           at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
                                                                           at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
                                                                           at android.view.View.layout(View.java:17637)
                                                                           at android.view.ViewGroup.layout(ViewGroup.java:5575)
                                                                           at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2346)
                                                                           at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2068)
                                                                           at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
                                                                           at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337)
                                                                           at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
                                                                           at android.view.Choreographer.doCallbacks(Choreographer.java:686)
                                                                           at android.view.Choreographer.doFrame(Choreographer.java:621)
                                                                           at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
                                                                           at android.os.Handler.handleCallback(Handler.java:751)
                                                                           at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                           at android.os.Looper.loop(Looper.java:154)
                                                                           at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                           at java.lang.reflect.Method.invoke(Native Method)
                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

add my own suggestions

hi! can I add setOnQueryChangeListener and implement my own suggestions in addition to google's locations?

locationName(String) is nowhere to be found

java.lang.NoSuchMethodError:
No static method zzb(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
in class Lcom/google/android/gms/common/internal/zzaa;
or its super classes (declaration of 'com.google.android.gms.common.internal.zzaa'
appears in /data/data/com.braulio.cassule.designfocus/files/instant-run/dex/slice-com.google.android.gms-play-services-basement-9.6.1_a90f1e9ce9bdbcb44b81e93fad4cebe23b3cf46c-classes.dex)

Searching

Hi, can i search within a particular area ?? suppose with in a geofence or ploylines ?? if not can we set Priority of searching ?

When Search Location Suggestion Show Below

Hi,

When i search location suggestion show below instead of above. so if search return 5 result then i can only see 1 suggestion other 4 suggestion are hidden below keyboard. i also attach my screenshot so you get idea.

Inside Manifest i use
android:windowSoftInputMode="stateHidden|adjustNothing"

device-2017-03-11-225515

Please Use Tag Release

Hello,
thanks for your developments.

Only one thing I would suggest to you: you could use tag release for every new release commited.

This behaviour permit to us to find more quickly the new releases and even your GitHub page is more standard for GitHub specifications.

Really appreciate that.

Thanks in advance.

cattura

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.