-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathFruitRepository.kt
46 lines (40 loc) · 1.29 KB
/
FruitRepository.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.ocnyang.recyclerviewevent.paging3
import com.ocnyang.recyclerviewevent.R
import kotlinx.coroutines.delay
class FruitRepository {
companion object {
const val PAGE_MAX = 6
val IMG_IDS = listOf(
R.drawable.ic_fruit_icons_01,
R.drawable.ic_fruit_icons_02,
R.drawable.ic_fruit_icons_03,
R.drawable.ic_fruit_icons_04,
R.drawable.ic_fruit_icons_05,
R.drawable.ic_fruit_icons_06,
)
}
suspend fun requestFruitList(
fruitName: String,
pageNumber: Int
): BaseBean<PagingFruitResultBean> {
delay(1000)
val fruitList = mutableListOf<PagingFruitBean>()
for (i in 0..9) {
fruitList.add(
PagingFruitBean(
"$fruitName $pageNumber$i 代",
imgId = IMG_IDS[(pageNumber + i) % IMG_IDS.size]
)
)
}
return BaseBean(
isSuccess = true,
msg = "success",
data = PagingFruitResultBean(
fruits = fruitList,
currentPage = pageNumber,
totalPage = PAGE_MAX
)
)
}
}