неиспользуемый функционал

This commit is contained in:
dasha 2023-12-19 20:49:30 +04:00
parent 5e992dbf8a
commit 1a72d6d368
7 changed files with 31010 additions and 15 deletions

View File

@ -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) {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -18,7 +18,7 @@ class OfflineCinemaRepository(private val cinemaDao: CinemaDao) : CinemaReposito
pageSize = AppContainer.LIMIT,
enablePlaceholders = false
),
pagingSourceFactory = cinemaDao::getAll
pagingSourceFactory = { cinemaDao.getAll(name) }
).flow

File diff suppressed because it is too large Load Diff