发布于 2016-03-12 23:29:52 | 179 次阅读 | 评论: 0 | 来源: 网友投递
Retrofit REST 客户端
retrofit 是一个类型安全的 REST 客户端,用于 Android 平台。
Retrofit 2.0.0 正式发布了,retrofit 是一个类型安全的 REST 客户端,用于 Android 平台。。
该版本的重点是提升扩展性,因此包含大量 API 的改动,与上一个版本不兼容。详细的变化请看这里。
与 Beta4 版本比较的改进包括:
New: RxJavaCallAdapterFactory
now supports service methods which return Completable
which ignores and discards response bodies, if any.
New: RxJavaCallAdapterFactory
supports supplying a default Scheduler
which will be used for subscribeOn
on returned Observable
, Single
, and Completable
instances.
New: MoshiConverterFactory
supports creating an instance which uses lenient parsing.
New: @Part
can omit the part name and use OkHttp's MultipartBody.Part
type for supplying parts. This lets you customize the headers, name, and filename and provide the part body in a single argument.
The BaseUrl
interface and support for changeable base URLs was removed. This functionality can be done using an OkHttp interceptor and a sample showcasing it was added.
Response.isSuccess()
was renamed to Response.isSuccessful()
for parity with the name of OkHttp's version of that method.
Fix: Throw a more appropriate exception with a message when a resolved url (base URL + relative URL) is malformed.
Fix: GsonConverterFactory
now honors settings on the Gson
instance (like leniency).
Fix: ScalarsConverterFactory
now supports primitive scalar types in addition to boxed for response body parsing.
Fix: Retrofit.callbackExecutor()
may now return an executor even when one was not explicitly provided. This allows custom CallAdapter.Factory
implementations to use it when triggering callbacks to ensure they happen on the appropriate thread for the platform (e.g., Android).
下载地址:
https://github.com/square/retrofit/releases/tag/parent-2.0.0