【Android】Retrofit源码学习
【Android】Retrofit源码学习使用Retrofit的流程#通过Builder创建Retrofit对象:CopyRetrofit retrofit = new Retrofit.Builder().baseUrl("").addConverterFactory().build();用Java注解描述APICopypublic interface MyApi { @GET("/api") Call<Data> getData(); }通过retrofit创建api对象,并建立Call对象CopyMyApi api = retrofit.create(MyApi.class);Call call = api.getData();通过Call对象获取数据,enqueue()方法发送异步请求,同步方式则使用execute()方法Copycall.enqueue(new Callback() { @Override public void onResponse(Response<ZhuanLanAuthor> author) { System.out.print...
