riku
2021-02-25 e102578ebfc95c27aeb13dce13fb82af53a2bead
app/src/main/java/cn/flightfeather/thirdapp/common/net/ResultObserver.kt
@@ -1,6 +1,7 @@
package cn.flightfeather.thirdapp.common.net
import android.accounts.NetworkErrorException
import cn.flightfeather.thirdapp.model.bean.BaseResponse
import io.reactivex.Observer
import io.reactivex.disposables.Disposable
import retrofit2.Response
@@ -66,8 +67,11 @@
        var currentPage = -1
        var totalPage = -1
        try {
            currentPage = response.headers().get("currentPage")?.toInt() ?: -1
            totalPage = response.headers().get("totalPage")?.toInt() ?: -1
            val body = response.body()
            if (body is BaseResponse<*>) {
                currentPage = body.head?.page ?: -1
                totalPage = body.head?.totalPage ?: -1
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }