1.引入依赖
//协程 implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0' //rxjava api 'io.reactivex.rxjava2:rxjava:2.2.8' api 'io.reactivex.rxjava2:rxandroid:2.1.1' def retrofit_version = "2.1.0" //Rxjava + retrofit 用到的一个依赖库,使接口回调的数据以Rxjava形式供我们接受 implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0-RC3' //retrofig依赖包 implementation 'com.squareup.retrofit2:retrofit:' + retrofit_version //自动将服务器返回的数据 以及 我们传给一个JavaBeen实体,转换成json implementation 'com.squareup.retrofit2:converter-gson:' + retrofit_version //gson实体解析库 api 'com.google.code.gson:gson:2.8.6' //OKHttp日志拦截器,OKHttp官方提供。 implementation 'com.squareup.okhttp3:logging-interceptor:3.3.0'
2.数据对象