Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple PlaceAutoCompleteFragment opens when clicked on it very quickly

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);
        }
    });
like image 567
Shafayat Mamun Avatar asked May 29 '16 12:05

Shafayat Mamun


2 Answers

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.

like image 190
AndrewR Avatar answered Nov 06 '22 15:11

AndrewR


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

like image 1
Arpit Ratan Avatar answered Nov 06 '22 15:11

Arpit Ratan