Day 32:来呼叫星战 Profile List 下一页吧(1/2)

在 Day 31 分享 RecyclerView 如何载入更多之後,先来帮大家回顾之前星战的 Profile List 回传格式。

{
  "count": 82,
  "next": "http://swapi.dev/api/people/?page=2",
  "previous": null,
  "results": [
  ]
}

其中,next & previous 是一个网址,跟官方网站对照嫁接 API 的 domain 其实可以知道 page 就是 api 的取得页数的参数

https://ithelp.ithome.com.tw/upload/images/20201014/20130546uUehHtvKdq.png

回到 MainPresenter 先试试 page = 1 时,是不是跟原先的资料相同

val call = NetworkManager.client.profileList(1)
call.enqueue(object : NetworkCallback<ProfileListResponse>() {
    override fun onSuccess(response: ProfileListResponse) {
        view.showProfileList(response.results)
    }

    override fun onFailure(
        call: Call<ProfileListResponse>,
        statusCode: Int,
        errorBody: ResponseBody?
    ) {
        view.showApiError("statusCode= $statusCode & errorBody= $errorBody")
    }
})

<<:  倒数第二天

>>:  RxJS 错误处理 Operators (1) - catchError / finalize / retry / retryWhen

学习笔记:一起进入 PixiJS 的世界 (五)

目前已接触的DisplayObject包含了PIXI.Graphics()的图像绘制、PIXI.Te...

【Day19】SPI 状态机的实现

SPI是什麽? SPI(Serial Peripheral Interface),是一种同步的传输协...

有时差的我如何跟团队协作

由於目前人在美东,与台湾的时差刚好 12hr,完全可以说出:「当我在睡觉时,台湾的大家都还在认真工作...

Flutter体验 Day 25-SharedPreferences

SharedPreferences 有时候我们在应用程序会需要保存登入Session资料、个人偏好设...

30天程序语言研究

今天是30天程序语言研究的第四天,研究的语言是python,今天主要学习的部分是tuple和func...