简介:This adapter allows synchronous return types for Retrofit 2.
更多:作者   提 Bug   

License Build Status Coverage Status Twitter Follow

A synchronous CallAdapter.Factory implementation for Retrofit 2.

This project brings Retrofit 1's synchronous usage to Retrofit 2.


// Setup retrofit
Retrofit retrofit = new Retrofit.Builder()

// Create your service
interface Service {
  @GET("/") ApiResponse response();                 // Return type directly
  @GET("/") Response<ApiResponse> responseApi();    // Return Response information with type
  @GET("/") ResponseBody body();                    // Return generic type directly
  @GET("/") Response<ResponseBody> responseBody();  // Return Response information with generic type

// Initiate the service
Service example = retrofit.create(Service.class);

// Make your HTTP request
ApiResponse response = example.response();
ResponseBody body = example.body();
Response<ResponseBody> responseBody = example.responseBody();
Response<ApiResponse> responseApi = example.responseApi();



repositories {

compile "com.jaredsburrows.retrofit:retrofit2-synchronous-adapter:0.4.0"

Snapshot versions are available in the JFrog Artifactory repository:

Android 开发经验分享
C 轮融资近 30 亿元理财推荐
Android 开发经验分享
C 轮融资近 30 亿元理财推荐