0
Observable.zip(...)でリクエストをいくつか組み合わせようとしましたが、android.os.NetworkOnMainThreadExceptionというエラーが発生しました。私は間違っているの?RxJavaとRetrofit2:android.os.NetworkOnMainThreadException
Call<EmployeeInfo> companyInfo = apiService.employee();
companyInfo.enqueue(new Callback<EmployeeInfo>() {
@Override
public void onResponse(Call<EmployeeInfo> call, Response<EmployeeInfo> response) {
EmployeeInfo info = response.body();
Observable.zip(
apiService.getOrders("https://exaple.com"),
apiService.getOrders("https://exaple.com"),
apiService.getOrders("https://exaple.com"),
apiService.companyInfo("1"), new Func4<Orders, Orders, Orders, CompanyInfo, OrdersDataWrapper>() {
@Override
public OrdersDataWrapper call(Orders currentOrders, Orders waitingOrders, Orders enterOrders, CompanyInfo companyInfo) {
OrdersDataWrapper data = new OrdersDataWrapper();
return data;
}
}).onErrorReturn(new Func1<Throwable, OrdersDataWrapper>() {
@Override
public OrdersDataWrapper call(Throwable throwable) {
return null;
}
})
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<OrdersDataWrapper>() {
@Override
public void call(OrdersDataWrapper alDataWrapper) {
}
});
}
@Override
public void onFailure(Call<EmployeeInfo> call, Throwable t) {
}
});
u r missing subscribeOn –