我使用SwipeRefreshLayout来处理拉刷新并使用Retrofit返回Observable来获取我的数据,但是Observable.subscribeOn(AndroidSchedulers.mainThread()) 不起作用。
private SwipeRefreshLayout.OnRefreshListener refreshListener
= new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
apis.getData()
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<BookedClass>() {
@Override
public void onCompleted() {
Log.e(TAG,""+(Thread.currentThread() == Looper.getMainLooper().getThread()));
}
@Override
public void onError(Throwable e) {
...
}
@Override
public void onNext(Data data) { {
...
}
}
}
}
日志:假
我的代码错了吗?