retrofit2.Retrofit.nextCallAdapter()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中retrofit2.Retrofit.nextCallAdapter方法的一些代码示例,展示了Retrofit.nextCallAdapter的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Retrofit.nextCallAdapter方法的具体详情如下:
包路径:retrofit2.Retrofit
类名称:Retrofit
方法名:nextCallAdapter

Retrofit.nextCallAdapter介绍

[英]Returns the CallAdapter for returnType from the available #callAdapterFactories() except skipPast.
[中]从可用的#CallAdapterFactorys()中返回returnType的CallAdapter,skipPast除外。

代码示例

代码示例来源:origin: square/retrofit

/**
 * 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);
}

代码示例来源:origin: com.squareup.retrofit2/retrofit

/**
 * 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);
}

代码示例来源:origin: square/retrofit

@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();
   }
  };
 }
}

代码示例来源:origin: NightlyNexus/logging-retrofit

@Override
public CallAdapter<?, ?> get(Type returnType, Annotation[] annotations, Retrofit retrofit) {
 CallAdapter<?, ?> delegate = retrofit.nextCallAdapter(this, returnType, annotations);
 return new LoggingCallAdapter<>(delegate, logger);
}

相关文章