/** * Returns the {@link CallAdapter} for {@code returnType} from the available {@linkplain * #callAdapterFactories() factories}. * * @throws IllegalArgumentException if no call adapter available for {@code type}. */ public CallAdapter<?, ?> callAdapter(Type returnType, Annotation[] annotations) { return nextCallAdapter(null, returnType, annotations); }
/** * Returns the {@link CallAdapter} for {@code returnType} from the available {@linkplain * #callAdapterFactories() factories}. * * @throws IllegalArgumentException if no call adapter available for {@code type}. */ public CallAdapter<?, ?> callAdapter(Type returnType, Annotation[] annotations) { return nextCallAdapter(null, returnType, annotations); }
@Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Observable.class) { return null; // Ignore non-Observable types. } // Look up the next call adapter which would otherwise be used if this one was not present. //noinspection unchecked returnType checked above to be Observable. final CallAdapter<Object, Observable<?>> delegate = (CallAdapter<Object, Observable<?>>) retrofit.nextCallAdapter(this, returnType, annotations); return new CallAdapter<Object, Object>() { @Override public Object adapt(Call<Object> call) { // Delegate to get the normal Observable... Observable<?> o = delegate.adapt(call); // ...and change it to send notifications to the observer on the specified scheduler. return o.observeOn(scheduler); } @Override public Type responseType() { return delegate.responseType(); } }; } }
@Override public CallAdapter<?, ?> get(Type returnType, Annotation[] annotations, Retrofit retrofit) { CallAdapter<?, ?> delegate = retrofit.nextCallAdapter(this, returnType, annotations); return new LoggingCallAdapter<>(delegate, logger); }