【发布时间】:2018-06-11 14:44:58
【问题描述】:
Android SDK https://developers.google.com/places/android-sdk/autocomplete (以编程方式查找获取地点预测)
GeoDataClient.getAutocompletePredictions() - 我想忽略不是最后一个请求的响应... 自动完成输入例如: '新'->'新Y'->'新哟'
3 响应 - 但我只想抓住最后一个.. (不使用 RX)
// Submit the query to the autocomplete API and retrieve a PendingResult that will
// contain the results when the query completes.
Task<AutocompletePredictionBufferResponse> results =
geoDataClient.getAutocompletePredictions(constraint, bounds, typeFilter);
results.addOnSuccessListener(autocompletePredictions -> {
if (autoCompletePredictionsListener != null) {
autoCompletePredictionsListener.onAutoCompleteSuccess(autocompletePredictions);
}
//****Here I want to ignore(or cancel somewhere before) previous requests
autocompletePredictions.release();
});
iOS SDK - 由 Google 开发者解决 https://developers.google.com/places/ios-sdk/reference/interface_g_m_s_autocomplete_fetcher
只有当这些预测是针对最近一次调用 sourceTextHasChanged 时提供的文本时,才会使用预测结果调用委托。
【问题讨论】:
标签: android google-places-api google-places googleplacesautocomplete