什么是Retrofit A type-safe HTTP client for Android and Java 一款在Java和Android平台上使用的类型安全的Http客户端 Retrofit的特点
将API请求转化为接口,具体的接口方法代替各个API使用注解标记请求方法类型、参数类型支持Multipart和文件上传将返回结果转化…
源代码:RxKotlinRetrofitDemo 1.定义统一的返回结果类 ResultData data class ResultData<T>(var code: Int, var message: String, var data: T?) code:接口返回数据状态码(状态码与后台人员协商),0代表成功&a…
Retrofit 使用方法简介
1. 创建一个 interface 作为 Web Service 的请求集合,在里面用注解(Annotation)写入需要配置的请求方法
public interface GitHubService {@GET("users/{user}/repos")Call<List<Repo>> listRepos(@Path(
A type-safe HTTP client for Android and Java
官网:Retrofit Retrofit turns your HTTP API into a Java interface.
public interface GitHubService { GET("users/{user}/repos") Call<List<Repo>> listRepos(Path("user"…