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