7

I am using Google's PlaceAutoCompleteFragment in a recent project that I am currently working on. When I click on the PlaceAutoCompleteFragment very quickly it open multiple overlays on my app which is really annoying. how can I prevent it from opening multiple overlays? My code for the fragment is given below:

if (autocompleteFragment == null) {
        autocompleteFragment = (PlaceAutocompleteFragment)getFragmentManager().findFragmentById(R.id.place_autocompletehome_fragment);
}

autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
        @Override
        public void onPlaceSelected(Place place) {
            // TODO: Get info about the selected place.
            try {
                Log.i("esty", "Place: " + place.getName());



            } catch (Exception e) {
                Log.e("esty", "Error: " + e.getMessage());
            }

        }

        @Override
        public void onError(Status status) {
            // TODO: Handle the error.
            Log.e("esty", "An error occurred: " + status);
        }
    });
Shafayat Mamun
  • 439
  • 1
  • 6
  • 22

2 Answers2

5

It looks like this is a bug in PlaceAutocompleteFragment (and SupportPlaceAutocompleteFragment). Thank you for bringing it to our attention. We'll look at fixing this in an upcoming release.

AndrewR
  • 10,759
  • 10
  • 45
  • 56
1

Why don't you try a hack to solve this problem. Put a on click listener on the whole fragment and use multi click blocker to pass the click event once.

Refer to the below solution : https://stackoverflow.com/a/23103227/4901098

Community
  • 1
  • 1
Arpit Ratan
  • 2,976
  • 1
  • 12
  • 20
  • PlaceAutoCompleteFragment doesn't have an onclicklistener. but your solution may have given me an idea. Gonna use PlaceAutoComplete Intent Builder to implement this solution. – Shafayat Mamun Jun 12 '16 at 05:10