private fun getAddressListFromPrediction(result: FindAutocompletePredictionsResponse?): List
{
val addressList = ArrayList()
result?.let { predictionsResults ->
for (prediction in predictionsResults.autocompletePredictions) {
val placeFields = listOf(Place.Field.ID, Place.Field.NAME, Place.Field.LAT_LNG, Place.Field.ADDRESS, Place.Field.ADDRESS_COMPONENTS)
val fetchPlaceRequest = FetchPlaceRequest.builder(prediction.placeId, placeFields).build()
val placeBufferResponseTask = geoDataClient.fetchPlace(fetchPlaceRequest)
try {
Tasks.await(placeBufferResponseTask, PLACE_BY_ID_WAITING_TIME, TimeUnit.SECONDS)
} catch (ignored: ExecutionException) {
} catch (ignored: InterruptedException) {
} catch (ignored: TimeoutException) {
}
val placeBufferResponse = placeBufferResponseTask.result
val place = placeBufferResponse?.place
place?.let {
addressList.add(mapPlaceToAddress(it))
}
}
}
return addressList
}
Please provide proper solution for this..
private fun getAddressListFromPrediction(result: FindAutocompletePredictionsResponse?): List
{ val addressList = ArrayList() result?.let { predictionsResults -> for (prediction in predictionsResults.autocompletePredictions) { val placeFields = listOf(Place.Field.ID, Place.Field.NAME, Place.Field.LAT_LNG, Place.Field.ADDRESS, Place.Field.ADDRESS_COMPONENTS) val fetchPlaceRequest = FetchPlaceRequest.builder(prediction.placeId, placeFields).build() val placeBufferResponseTask = geoDataClient.fetchPlace(fetchPlaceRequest) try { Tasks.await(placeBufferResponseTask, PLACE_BY_ID_WAITING_TIME, TimeUnit.SECONDS) } catch (ignored: ExecutionException) { } catch (ignored: InterruptedException) { } catch (ignored: TimeoutException) { }