Retrofit是基于OkHttp设计的一个网络请求框架。其实说Retrofit是一个网络不是那么准确,准确来说,Retrofit就是OkHttp的一个外壳,Retrofit的底层网络请求使用就是OkHttp。
Retrofit的使用流程:


retrofit.create(Api.class)
创建接口实现类:创建并返回一个会拦截接口方法的动态代理对象实例 - 接口方法被调用时,会被其拦截,内部将接口方法适配成HTTP Call,再构造对应的OkHttpCall,最后通过CallAdapter.adapt()转换成Retrofit适用的call delegates(即ExecutorCallbackCall)。



网友评论