rxjava2封装使用
2018-03-06 17:14
204 查看
转载标明出处:http://blog.csdn.net/u012840567/article/details/79459834 https://www.jianshu.com/p/0cd258eecf60 借鉴这篇文章为基础了解rxjava2
封装的demo 仅做参考 https://github.com/wbq19920501/rxjava
![](https://img-blog.csdn.net/2018030617135468?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjg0MDU2Nw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
首先引入的是rxjava2相关的库 android studio3.0 工具编写的,里面还包含了kotlin
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.1.2'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.squareup.okhttp3:okhttp:3.8.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'
![](https://img-blog.csdn.net/20180306162406673?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjg0MDU2Nw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
数据成功处理防止万一数据出现错误或者解析异常出现崩溃统一处理异常
基础工具类
![](https://img-blog.csdn.net/2018030616515660?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjg0MDU2Nw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
基础BASEURL为接口地址,这里随便写的一个雅虎天气地址
![](https://img-blog.csdn.net/20180306170150898?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjg0MDU2Nw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
![](https://img-blog.csdn.net/20180306170256899?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjg0MDU2Nw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
统一做一个封装的httputils
![](https://img-blog.csdn.net/20180306170405153?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjg0MDU2Nw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
接口传值采用map键值对的形式发送json数据接收json数据带参数的post提交
![](https://img-blog.csdn.net/20180306170539993?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjg0MDU2Nw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
其余示例
![](https://img-blog.csdn.net/20180306170615864?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjg0MDU2Nw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
大致的封装就是这么多
接下来是6.0权限请求
![](https://img-blog.csdn.net/20180306170824477?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjg0MDU2Nw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
kotlin 语言使用下载apk安装包使用updateManager管理帮助类自己封装的可以当做参考在githup地址上面,本文最上面
![](https://img-blog.csdn.net/20180306171015188?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjg0MDU2Nw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
里面还有一个头像上传封装,这个就不说明了,都是使用的kotlin编写的,仅做参考。时间有限以后有机会再维护、、
封装的demo 仅做参考 https://github.com/wbq19920501/rxjava
首先引入的是rxjava2相关的库 android studio3.0 工具编写的,里面还包含了kotlin
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.1.2'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.squareup.okhttp3:okhttp:3.8.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'
implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.4@aar'//6.0动态权限申请库
网络请求就涉及到数据请求成功或者失败
数据成功处理防止万一数据出现错误或者解析异常出现崩溃统一处理异常
基础工具类
基础BASEURL为接口地址,这里随便写的一个雅虎天气地址
统一做一个封装的httputils
接口传值采用map键值对的形式发送json数据接收json数据带参数的post提交
其余示例
大致的封装就是这么多
接下来是6.0权限请求
kotlin 语言使用下载apk安装包使用updateManager管理帮助类自己封装的可以当做参考在githup地址上面,本文最上面
里面还有一个头像上传封装,这个就不说明了,都是使用的kotlin编写的,仅做参考。时间有限以后有机会再维护、、
相关文章推荐
- Mvp+Retrofit+Rxjava+RxLifecycle的封装和使用
- Retrofit 和 RxJava的简单使用以及简单封装
- Rxjava,retrofit,Rxjava结合使用与代码封装
- Retrofit+RxJava + OkHttp的封装使用
- 说说我是怎么封装使用Retrofi+Rxjava的
- Retrofit+RXJava的结合使用与封装
- Rxjava 和 Retrofit 的封装使用
- Novate 封装Rxjava2.0 的使用
- RxJava和Retrofit结合使用 封装类
- Retrofit+Rxjava结合使用封装
- RxJava2+Retrofit2网络请求框架封装及使用
- Kotlin + Retrofit + RxJava简单封装使用详解
- 使用retrofit2和rxjava封装的网络框架RNet:(二)RNet的源码解析
- 使用Retrofit和Rxjava对联网进行简单封装
- 优雅地封装使用rxjava2+retrofit2发送http请求
- RxJava2+retrofit简单使用,基于POST请求封装工具类
- 使用retrofit2和rxjava封装网络框架RNet:(一)RNet的使用
- RxJava和Retrofit的结合封装使用
- 封装Okhttp+retrofit+rxjava使用MVP模式实现登录注册
- [置顶] RxJava的Subscriber使用,封装加载进度条ProgressSubscriber