rxjava2封装使用

转载标明出处:http://blog.csdn.net/u012840567/article/details/79459834

https://www.jianshu.com/p/0cd258eecf60  借鉴这篇文章为基础了解rxjava2

封装的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:[email protected]'//6.0动态权限申请库
网络请求就涉及到数据请求成功或者失败

    

    数据成功处理防止万一数据出现错误或者解析异常出现崩溃统一处理异常

    基础工具类

    

基础BASEURL为接口地址,这里随便写的一个雅虎天气地址



统一做一个封装的httputils


接口传值采用map键值对的形式发送json数据接收json数据带参数的post提交


其余示例


大致的封装就是这么多

接下来是6.0权限请求



kotlin 语言使用下载apk安装包使用updateManager管理帮助类自己封装的可以当做参考在githup地址上面,本文最上面


里面还有一个头像上传封装,这个就不说明了,都是使用的kotlin编写的,仅做参考。时间有限以后有机会再维护、、