更方便的使用retrofit2,兼容retrofit1.x
来源:互联网 发布:淘宝网披肩女装 编辑:程序博客网 时间:2024/06/05 06:05
RetrofitPlus
retrofit2的扩展库,方便的使用https、callback、兼容retrofit1.x的用法
【Github源码地址,欢迎Star和Follow】
Feature
1、已经 rebase 到最新 retrofit2 代码(目前是最新的retrofit2.0.1),支持原生 retrofit2 所有特性。
2、增加@HTTPS Annotation,可以灵活配置哪些方法使用 https。
例如:
@HTTPS@GET("/search/users")Call<GitResult> getUsersByName(@Query("q") String name);
3、为 okhttp3 的 https 设置certificate pinning。
例如:
* 将证书文件放入assets文件夹
OkHttpClientUtil.getSSLClient(okClient, context, "xxx.pem");
- 直接设置证书字符串
OkHttpClientUtil.getSSLClientByCertificateString(okClient, certificateString);
4、兼容 Retrofit 1.x,可以把 callback 放到参数里,执行方法后直接发送异步请求,此时方法返回值必须void。
例如:
@GET("/search/users")void getUsersByName2(@Query("q") String name, Callback<GitResult> callback);
5、添加 RetrofitPlusCallBack 类,回调方法更完整清晰
onCallStart();onCallFinish();onHttpSuccess(Call<T> call, Response<T> response);onHttpFailure(Call<T> call, Response<T> response);onNetFailure(Call<T> call, Throwable t);
Usage
repositories { maven { url "https://jitpack.io" }}dependencies { compile 'com.github.MasonLiuChn:RetrofitPlus:2.0.1.0'}
Demo:https://github.com/MasonLiuChn/RetrofitPlus/tree/master/retrofit-plus-demo
Usage of retrofit2.0:https://realm.io/cn/news/droidcon-jake-wharton-simple-http-retrofit-2
Contact me:
Blog:http://blog.csdn.net/masonblog
Email:MasonLiuChn@gmail.com
0 0
- 更方便的使用retrofit2,兼容retrofit1.x
- Retrofit1切换到Retrofit2的注意事项
- Cocos2d-x Lua 读取Csv文件,更方便的使用数据
- 一个更方便使用的upload类
- 更方便的单选框
- easypoi 更方便使用poi
- VisualSVN Server----更方便使用的SVN服务器
- 快捷操作更方便的使用Fedora 1
- 使用MiniTools更方便的调试TQ210裸机程序
- 使用MiniTools更方便的调试TQ210裸机程序
- 让sqlplus使用更方便的rlwrap工具安装
- ini文件的保存,使用map更方便
- cocos2dx3.2 添加现成的VisibleRect使用更方便。
- Android应用开发技巧之更方便的使用Sqlite
- 【Android】只为更方便--RecyclerView的使用(一)
- XMind 8备注/批注该怎样更方便的使用
- retrofit2兼容rxjava的配置和demo
- 更方便,更强大的分页方式
- linux 下利用 crontab 备份mysql
- 第九周项目1--深复制体验
- mybatis懒加载特性详解,以及多对多映射详解
- 搭建struts2开发环境
- Android 自定义变化的文本控件ColorChangeView
- 更方便的使用retrofit2,兼容retrofit1.x
- 不为测试而测试
- Redis Notes
- MultipartEntity 和 UrlEncodedFormEntity || application/x-www-form-urlencoded 和 multipart/form-data
- ]MySQL操作命令语句实例
- launcher点击,加载,拖动图标过程三
- emmet插件使用(Css)
- WebRTC VideoEngine综合应用示例(二)——集成OPENH264编解码器
- iOS开发系列--单个音乐文件的播放