Giter VIP home page Giter VIP logo

drabu / placeautocomplete Goto Github PK

View Code? Open in Web Editor NEW
26.0 2.0 6.0 8.32 MB

A Kotlin library that helps developers save weeks of effort in migrating from the default Google Places Autocomplete feature.It uses the latest Places API and is build on top of MVVM Architecture and uses various RxJava operators to optimise location requests.

License: MIT License

Kotlin 97.75% Java 2.25%
placeautocompletefragment locationapi searchlocation places google-places place-autocomplete

placeautocomplete's People

Contributors

drabu 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

Watchers

 avatar  avatar

placeautocomplete's Issues

Crash in StructuredFormatting.getMainText

Thanks for the library, it saved a lot of time implementing similar. I've just deployed a release with this library in and I'm seeing the following crash (currently Android 8 and 9 but it's early days so that could be irrelevant).

Fatal Exception: java.lang.NullPointerException: throw with null exception
       at com.oneclickaway.opensource.placeautocomplete.api.bean.places_response.StructuredFormatting.getMainText(StructuredFormatting.java:3)
       at com.oneclickaway.opensource.placeautocomplete.ui.SearchResultAdapter.onBindViewHolder(SearchResultAdapter.java:31)
       at com.oneclickaway.opensource.placeautocomplete.ui.SearchResultAdapter.onBindViewHolder(SearchResultAdapter.java:16)
       at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6781)
       at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6823)

Recent searches improvement

Hi, I like your library it's easy to use and very straight forward but I noticed that you're calling the details API again when you click the item on the recent searches, why do you need to do that? you already saved the details in your local DB, we can save the daily usage of the API if we don't need to query again. Thank you! just a thought. :)

Wrong position when clicked in Adapter

Test case :
1, Input search : "Ha"
2, loading adapter complete
3, add : "Noi " -> edittext : "Ha Noi"
4, loading adapter complete
5, when i choose one item , the result will be wrong place

 override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.binding.placeTitleTV.text =
            listOfCandidatesItem?.get(position)?.structuredFormatting?.mainText
        holder.binding.placeFormattedAddressTV.text =
            listOfCandidatesItem?.get(position)?.structuredFormatting?.secondaryText
        Log.e("HVV1312Json", "AAA ${listOfCandidatesItem!![position]?.terms?.get(0)?.value}")

        RxView.clicks(holder.itemView)
            .throttleFirst(700, TimeUnit.MILLISECONDS)
            .subscribe {
                placeClickListerner.onPlaceClicked(listOfCandidatesItem?.get(holder.adapterPosition))
            }

    }

if i do this , => the result correct

Unresolved reference: Builder

I am getting this error:
Unresolved reference: Builder

builder

Please inform us how to fix it, thank you

Here's my full code:

import android.app.ActivityOptions
import android.content.Intent
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.EditText
import android.widget.TextView
import com.oneclickaway.opensource.placeautocomplete.components.SearchPlacesStatusCodes
import com.oneclickaway.opensource.placeautocomplete.ui.SearchPlaceActivity

import android.util.Pair

class MainActivity : AppCompatActivity() {

lateinit var searchLocationET: EditText
lateinit var placeDetailsTV: TextView
var REQUEST_CODE = 700

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    searchLocationET = findViewById(R.id.searchLocationBTN)
    placeDetailsTV = findViewById(R.id.resultPlaceDetailsTV)

    val intent = Intent(this, SearchPlaceActivity::class.java)
    intent.putExtra(
        SearchPlacesStatusCodes.CONFIG,
        SearchPlaceActivity.Config.Builder(apiKey = "myapikey")
            .setSearchBarTitle("Enter Source Location")
            .setMyLocation("12.9716,77.5946")
            .setEnclosingRadius("500")
            .build()
    )

    searchLocationET.setOnClickListener {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            val pair = Pair.create(searchLocationET as View, SearchPlacesStatusCodes.PLACEHOLDER_TRANSITION)
            val options = ActivityOptions.makeSceneTransitionAnimation(this, pair).toBundle()
            startActivityForResult(intent, REQUEST_CODE, options)

        } else {
            startActivityForResult(intent, REQUEST_CODE)
            overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out)
        }
    }
}

}

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.