请查看以下简单代码:
private void refreshData(String endpoint)
{
KProgressHUD busy = Utils.showBusyIndicator(MainActivity.this);
MCityEndpoint mcityService = ServiceFactory.createRetrofitService(MCityEndpoint.class, Configuration.getApiUrl());
Disposable disposable = Observable.zip
(
mcityService.getMcityDictionaries(selectedCity.id),
mcityService.getEvents(selectedCity.id, endpoint),
mcityService.getUserDetails(selectedCity.id),
(dictionaries,events, userInfo) ->
{
processData(dictionaries, events, userInfo);
return events.events;
}
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result ->
{
if(mFragment instanceof ListFragment)
{
((ListFragment) mFragment).refreshData(result);
}
updateUserDetails();
busy.dismiss();
Log.d(Configuration.tag,"Refresh data complete");
}, throwable ->
{
Log.d(Configuration.tag,throwable.toString());
busy.dismiss();
this.logout(true);
});
mCompositeDisposable.add(disposable);
}
我想调用3个可观察对象,处理它们的值,最后将数据加载到列表中。可以,但是我迟到了1秒。结果是:
在这种情况下,我无法理解延迟的原因。一切都应刷新,并且可见繁忙的指示器。你有什么主意吗?