diff --git a/app/src/main/java/com/example/labwork/button_navigation/Screens.kt b/app/src/main/java/com/example/labwork/button_navigation/Screens.kt index cbca3e1..a225f6d 100644 --- a/app/src/main/java/com/example/labwork/button_navigation/Screens.kt +++ b/app/src/main/java/com/example/labwork/button_navigation/Screens.kt @@ -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 diff --git a/app/src/main/java/com/example/labwork/database/DAO/BicycleDao.kt b/app/src/main/java/com/example/labwork/database/DAO/BicycleDao.kt index c29a84f..5dac7cb 100644 --- a/app/src/main/java/com/example/labwork/database/DAO/BicycleDao.kt +++ b/app/src/main/java/com/example/labwork/database/DAO/BicycleDao.kt @@ -27,6 +27,6 @@ interface BicycleDao { @Query("SELECT * FROM bicycles WHERE userId = :userId") suspend fun getBicyclesByUserId(userId: Int): List - @Query("SELECT * FROM bicycles ORDER BY id DESC LIMIT :pageSize OFFSET :offset") - suspend fun getBicycles(offset: Int, pageSize: Int): List + @Query("SELECT * FROM bicycles ORDER BY id ASC LIMIT :limit OFFSET :offset") + suspend fun getBicycles(limit: Int, offset: Int): List } \ No newline at end of file diff --git a/app/src/main/java/com/example/labwork/database/Paging/BicyclePagingSource.kt b/app/src/main/java/com/example/labwork/database/Paging/BicyclePagingSource.kt index fe815a0..14dd00d 100644 --- a/app/src/main/java/com/example/labwork/database/Paging/BicyclePagingSource.kt +++ b/app/src/main/java/com/example/labwork/database/Paging/BicyclePagingSource.kt @@ -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, diff --git a/app/src/main/java/com/example/labwork/repository/OfflineBicycleRepository.kt b/app/src/main/java/com/example/labwork/repository/OfflineBicycleRepository.kt index 13bf5b9..64a1b51 100644 --- a/app/src/main/java/com/example/labwork/repository/OfflineBicycleRepository.kt +++ b/app/src/main/java/com/example/labwork/repository/OfflineBicycleRepository.kt @@ -33,7 +33,7 @@ class OfflineBicycleRepository(private val bicycleDao: BicycleDao) : BicycleRepo return bicycleDao.getBicycleById(bicycleId) } - override fun getBicycles(): Flow> = Pager(config = PagingConfig(pageSize = 4, jumpThreshold = 4, initialLoadSize = 4) ) + override fun getBicycles(): Flow> = Pager(config = PagingConfig(pageSize = 3, jumpThreshold = 3, initialLoadSize = 3) ) { BicyclePagingSource(bicycleDao) }.flow