Так и живем
This commit is contained in:
parent
2884f2b4eb
commit
c358c953ba
@ -83,10 +83,10 @@ fun ScreenListProduct(
|
||||
bicycles.apply {
|
||||
when {
|
||||
loadState.refresh is LoadState.Loading -> {
|
||||
item { CircularProgressIndicator(modifier = Modifier.fillParentMaxSize(), color = Color(0xff423a99)) }
|
||||
item { CircularProgressIndicator(modifier = Modifier.fillParentMaxSize(), color = LightBluePolitech) }
|
||||
}
|
||||
loadState.append is LoadState.Loading -> {
|
||||
item { CircularProgressIndicator(modifier = Modifier.fillParentMaxSize(), color = Color(0xff423a99)) }
|
||||
item { CircularProgressIndicator(modifier = Modifier.fillParentMaxSize(), color = LightBluePolitech) }
|
||||
}
|
||||
loadState.refresh is LoadState.Error -> {
|
||||
val err = bicycles.loadState.refresh as LoadState.Error
|
||||
|
@ -27,6 +27,6 @@ interface BicycleDao {
|
||||
@Query("SELECT * FROM bicycles WHERE userId = :userId")
|
||||
suspend fun getBicyclesByUserId(userId: Int): List<Bicycle>
|
||||
|
||||
@Query("SELECT * FROM bicycles ORDER BY id DESC LIMIT :pageSize OFFSET :offset")
|
||||
suspend fun getBicycles(offset: Int, pageSize: Int): List<Bicycle>
|
||||
@Query("SELECT * FROM bicycles ORDER BY id ASC LIMIT :limit OFFSET :offset")
|
||||
suspend fun getBicycles(limit: Int, offset: Int): List<Bicycle>
|
||||
}
|
@ -15,7 +15,7 @@ class BicyclePagingSource(private val dao: BicycleDao,
|
||||
return try {
|
||||
Log.d("MainPagingSource", "load: $page")
|
||||
val entities = dao.getBicycles(params.loadSize, page * params.loadSize)
|
||||
if (page != 0) delay(1000)
|
||||
if (page != 0) delay(2000)
|
||||
LoadResult.Page(
|
||||
data = entities,
|
||||
prevKey = if (page == 0) null else page - 1,
|
||||
|
@ -33,7 +33,7 @@ class OfflineBicycleRepository(private val bicycleDao: BicycleDao) : BicycleRepo
|
||||
return bicycleDao.getBicycleById(bicycleId)
|
||||
}
|
||||
|
||||
override fun getBicycles(): Flow<PagingData<Bicycle>> = Pager(config = PagingConfig(pageSize = 4, jumpThreshold = 4, initialLoadSize = 4) )
|
||||
override fun getBicycles(): Flow<PagingData<Bicycle>> = Pager(config = PagingConfig(pageSize = 3, jumpThreshold = 3, initialLoadSize = 3) )
|
||||
{
|
||||
BicyclePagingSource(bicycleDao)
|
||||
}.flow
|
||||
|
Loading…
x
Reference in New Issue
Block a user