Skip to content

Instantly share code, notes, and snippets.

@adipascu
Created October 23, 2015 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adipascu/0942364293ddd13ef5f3 to your computer and use it in GitHub Desktop.
Save adipascu/0942364293ddd13ef5f3 to your computer and use it in GitHub Desktop.
.addCallAdapterFactory(new CallAdapter.Factory() {
//relevant SO: https://github.com/square/retrofit/pull/1117
RxJavaCallAdapterFactory delegate = RxJavaCallAdapterFactory.create();
@Override
public CallAdapter<?> get(Type returnType, Annotation[] annotations, Retrofit retrofit) {
//noinspection unchecked
CallAdapter<Observable<?>> delegate2 = (CallAdapter<Observable<?>>) delegate.get(returnType, annotations, retrofit);
return new CallAdapter<Object>() {
@Override
public Type responseType() {
return delegate2.responseType();
}
@Override
public <R> Object adapt(Call<R> call) {
return delegate2.adapt(call).subscribeOn(Schedulers.io());
}
};
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment