我正在使用改造和rxjava2。我有一个问题,那就是当我第一次打开应用程序或打开新活动时,我必须使用限制和偏移量从服务器检索数据。然后将数据存储回本地数据库(领域数据库)中。 API服务界面如下:
@GET(ApiUri.GET_LIST_CITY)
fun getlistOfCityWithOutParameter(
@Query("limit") limit: Int,@Query("offset") offset: Int
): Observable<ResponseDataList<ResponseDataCityWithoutParameter>>
ResponseDataList像这样:
class ResponseDataList<T> : BaseResponse() {
@SerializedName("results")
@Expose
var result: MutableList<T>? = null
}
和BaseResponse()函数可在显示数据方面实现REST服务器的响应。像这样:
open class BaseResponse {
@SerializedName("status")
var status: Int = 0
@SerializedName("code")
var code: Int = 0
@SerializedName("message")
var message: String? = null
@SerializedName("generated")
var generated: String? = null
@SerializedName("serverTime")
var serverTime: String? = null
@SerializedName("totaldata")
var totaldata: Int = 0
@SerializedName("totalresult")
var totalresult: Int = 0
}
然后我问如何使用rxjava进行分页API进行调用,直到检索到所有数据为止。