неиспользуемый функционал
This commit is contained in:
parent
5e992dbf8a
commit
1a72d6d368
@ -55,7 +55,7 @@ class CinemaRemoteMediator(
|
||||
|
||||
try {
|
||||
val cinemas = service.getCinemas(page, state.config.pageSize).map { it.toCinema() }
|
||||
val sessionsFromCinemas = cinemas.map { cinema ->
|
||||
val sessionsFromCinemas = cinemas.flatMap { cinema ->
|
||||
service.getCinemaWithSessions(cinema.uid).toSessions()
|
||||
}
|
||||
val endOfPaginationReached = cinemas.isEmpty()
|
||||
@ -77,13 +77,7 @@ class CinemaRemoteMediator(
|
||||
}
|
||||
dbRemoteKeyRepository.createRemoteKeys(keys)
|
||||
dbCinemaRepository.insertCinemas(cinemas)
|
||||
sessionsFromCinemas.forEach {
|
||||
try {
|
||||
dbSessionRepository.insertSessions(it)
|
||||
} catch (_: Exception) {
|
||||
|
||||
}
|
||||
}
|
||||
dbSessionRepository.insertSessions(sessionsFromCinemas)
|
||||
}
|
||||
return MediatorResult.Success(endOfPaginationReached = endOfPaginationReached)
|
||||
} catch (exception: IOException) {
|
||||
|
@ -4,6 +4,7 @@ import androidx.paging.PagingSource
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import androidx.room.Update
|
||||
import com.example.myapplication.database.entities.model.Cinema
|
||||
@ -14,6 +15,7 @@ import kotlinx.coroutines.flow.Flow
|
||||
interface CinemaDao {
|
||||
@Query("select * from cinemas order by name")
|
||||
fun getAll(): PagingSource<Int, Cinema>
|
||||
|
||||
@Query("select * from cinemas where cinemas.name like :name order by name collate nocase asc")
|
||||
fun getAll(name: String): PagingSource<Int, Cinema>
|
||||
|
||||
@ -27,7 +29,7 @@ interface CinemaDao {
|
||||
)
|
||||
fun getByUid(cinemaId: Int?): Flow<Map<Cinema, List<SessionFromCinema>>>
|
||||
|
||||
@Insert
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insert(vararg cinema: Cinema)
|
||||
|
||||
@Update
|
||||
|
@ -4,6 +4,7 @@ import androidx.paging.PagingSource
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import androidx.room.Update
|
||||
import com.example.myapplication.database.entities.model.Order
|
||||
@ -23,7 +24,7 @@ interface OrderDao {
|
||||
)
|
||||
fun getByUid(orderId: Int?): List<SessionFromOrder>
|
||||
|
||||
@Insert
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insert(vararg order: Order): List<Long>
|
||||
|
||||
@Update
|
||||
|
@ -3,6 +3,7 @@ package com.example.myapplication.database.entities.dao
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import androidx.room.Update
|
||||
import com.example.myapplication.database.entities.model.Session
|
||||
@ -12,7 +13,7 @@ interface SessionDao {
|
||||
@Query("select * from sessions where sessions.uid = :uid")
|
||||
suspend fun getByUid(uid: Int): Session
|
||||
|
||||
@Insert
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insert(vararg session: Session)
|
||||
|
||||
@Update
|
||||
|
@ -3,6 +3,7 @@ package com.example.myapplication.database.entities.dao
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import androidx.room.Update
|
||||
import com.example.myapplication.database.entities.model.SessionFromCart
|
||||
@ -27,7 +28,7 @@ interface UserDao {
|
||||
)
|
||||
suspend fun getCartByUid(userId: Int): List<SessionFromCart>
|
||||
|
||||
@Insert
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insert(vararg user: User)
|
||||
|
||||
@Update
|
||||
|
@ -18,7 +18,7 @@ class OfflineCinemaRepository(private val cinemaDao: CinemaDao) : CinemaReposito
|
||||
pageSize = AppContainer.LIMIT,
|
||||
enablePlaceholders = false
|
||||
),
|
||||
pagingSourceFactory = cinemaDao::getAll
|
||||
pagingSourceFactory = { cinemaDao.getAll(name) }
|
||||
).flow
|
||||
|
||||
|
||||
|
31000
server/data.json
31000
server/data.json
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user