package com.jld.vod.repository

import androidx.paging.PagingSource
import com.jld.vod.interfaces.remote.Apis
import com.jld.vod.model.bean.BrowserBean
import com.jld.vod.model.bean.FindAboutAllBean
import com.jld.vod.model.bean.GameBean
import com.jld.vod.utils.LogUtils

class AboutPagingSource (private val articleApi: Apis, val mid:Long, val lid:Long) : PagingSource<Int, FindAboutAllBean>() {

    override suspend fun load(params: LoadParams<Int>): LoadResult<Int, FindAboutAllBean> {
        val page = params.key ?: 0
        return try {
            val response = articleApi.findAboutAll(mid,lid)
            if (response.code == 20000) {
                LoadResult.Page(
                    data = response.data!!,
                    prevKey = null,
                    nextKey = null
                )
            } else {
                LoadResult.Error(Throwable(response.message))
            }
        } catch (e: Exception) {
            e.printStackTrace()
            LoadResult.Error(e)
        }
    }
}