Skip to content

Commit

Permalink
收藏夹列表分页加载
Browse files Browse the repository at this point in the history
  • Loading branch information
10miaomiao committed Jun 7, 2023
1 parent e68e1b7 commit c9a4640
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class UserFollowFragment : Fragment(), DIAware, MyPage {
_leftPadding = contentInsets.left
_rightPadding = contentInsets.right
_topPadding = contentInsets.top
_bottomPadding = contentInsets.bottom
_bottomPadding = contentInsets.bottom + windowStore.bottomAppBarHeight

views {
+view<WebView>(ID_webView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.a10miaomiao.bilimiao.MainNavGraph
import com.a10miaomiao.bilimiao.comm.MiaoBindingUi
import com.a10miaomiao.bilimiao.comm.entity.ListAndCountInfo
import com.a10miaomiao.bilimiao.comm.entity.ResultInfo
import com.a10miaomiao.bilimiao.comm.entity.comm.PaginationInfo
import com.a10miaomiao.bilimiao.comm.entity.media.MediaListInfo
Expand Down Expand Up @@ -46,18 +47,20 @@ class UserFavouriteListViewModel(
ui.setState {
list.loading = true
}
val res = BiliApiService.userApi.favFolderList(id).awaitCall()
.gson<ResultInfo<UserSpaceFavFolderInfo>>()
val res = BiliApiService.userApi.favFolderList(
id,
pageNum = pageNum,
pageSize = list.pageSize
).awaitCall().gson<ResultInfo<ListAndCountInfo<MediaListInfo>>>()
if (res.code == 0) {
val result = res.data
val defaultFolderDetail = result.default_folder.folder_detail
val media0 = result.space_infos[0]
ui.setState {
list.finished = true
list.data.add(defaultFolderDetail)
if (media0 != null) {
list.data.addAll(media0.mediaListResponse.list)
if (pageNum == 1) {
list.data = result.list.toMutableList()
} else {
list.data.addAll(result.list)
}
list.finished = !result.has_more
}
list.pageNum = pageNum
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,15 @@ class UserApi {

fun favFolderList(
up_mid: String,
pageNum: Int,
pageSize: Int,
) = MiaoHttp.request {
// 用户空间 x/v3/fav/folder/space/v2
url = BiliApiService.biliApi(
"x/v3/fav/folder/space/v2",
"up_mid" to up_mid
"x/v3/fav/folder/created/list",
"up_mid" to up_mid,
"pn" to pageNum.toString(),
"ps" to pageSize.toString(),
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.a10miaomiao.bilimiao.comm.entity

data class ListAndCountInfo<T> (
val count: Int,
val list: List<T>,
val has_more: Boolean,
)

0 comments on commit c9a4640

Please sign in to comment.