【发布时间】:2019-01-15 15:09:54
【问题描述】:
在将 Place API 与 rxjava 结合使用时,我发现了一个问题。
当获取数据如此之快时,api 返回"status" : "OVER_QUERY_LIMIT"。
我想重复以获取具有特定延迟时间的数据以避免它。如何使用 rxjava 操作符来实现。
getCompositeDisposable().add(
getDataManager().getAtmsByBankName(nameSearch, location, radius, apiKey)
.subscribeOn(getSchedulerProvider().io())
.observeOn(getSchedulerProvider().ui())
.subscribe(atmResponse -> {
if (atmResponse.getStatus().equals("OK")) {
if (atmResponse.getAtmList() != null) {
atmListLiveData.setValue(atmResponse.getAtmList());
}
}
Log.e("LOG", "inside onNext");
}, throwable -> {
getNavigator().handleError(throwable);
Log.e("LOG", "inside onError");
}));
这是 okhttp3 的日志:
D/OkHttp: {
"error_message" : "You have exceeded your daily request quota for this API.",
"html_attributions" : [],
"results" : [],
"status" : "OVER_QUERY_LIMIT"
}
<-- END HTTP (166-byte body)
我为 http 使用 Retrofit。
public Observable<ATMResponse> getAtmsByBankName(String nameSearch, String location, String radius, String apiKey) {
ApiInterface apiInterface = retrofit.create(ApiInterface.class);
//return apiInterface.getAtms(nameSearch, location, radius, apiKey);
return apiInterface.getAtms(nameSearch, location, radius, apiKey);
}
【问题讨论】:
标签: android rx-java retrofit rx-android okhttp3