-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbdb4d1
commit 1c224b2
Showing
25 changed files
with
244 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...sistence/src/main/kotlin/org/michaelbel/movies/persistence/database/AccountPersistence.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.michaelbel.movies.persistence.database | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import org.michaelbel.movies.persistence.database.dao.AccountDao | ||
import org.michaelbel.movies.persistence.database.entity.AccountDb | ||
import javax.inject.Inject | ||
|
||
class AccountPersistence @Inject internal constructor( | ||
private val accountDao: AccountDao | ||
) { | ||
|
||
fun accountById(accountId: Int): Flow<AccountDb?> { | ||
return accountDao.accountById(accountId) | ||
} | ||
|
||
suspend fun insert(account: AccountDb) { | ||
accountDao.insert(account) | ||
} | ||
|
||
suspend fun removeById(accountId: Int) { | ||
accountDao.removeById(accountId) | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...ersistence/src/main/kotlin/org/michaelbel/movies/persistence/database/ImagePersistence.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.michaelbel.movies.persistence.database | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import org.michaelbel.movies.persistence.database.dao.ImageDao | ||
import org.michaelbel.movies.persistence.database.entity.ImageDb | ||
import javax.inject.Inject | ||
|
||
class ImagePersistence @Inject internal constructor( | ||
private val imageDao: ImageDao | ||
) { | ||
|
||
fun imagesFlow(movieId: Int): Flow<List<ImageDb>> { | ||
return imageDao.imagesFlow(movieId) | ||
} | ||
|
||
suspend fun insert(images: List<ImageDb>) { | ||
imageDao.insert(images) | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...ersistence/src/main/kotlin/org/michaelbel/movies/persistence/database/MoviePersistence.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.michaelbel.movies.persistence.database | ||
|
||
import androidx.paging.PagingSource | ||
import kotlinx.coroutines.flow.Flow | ||
import org.michaelbel.movies.persistence.database.dao.MovieDao | ||
import org.michaelbel.movies.persistence.database.entity.MovieDb | ||
import org.michaelbel.movies.persistence.database.entity.mini.MovieDbMini | ||
import javax.inject.Inject | ||
|
||
class MoviePersistence @Inject internal constructor( | ||
private val movieDao: MovieDao | ||
) { | ||
|
||
fun pagingSource(movieList: String): PagingSource<Int, MovieDb> { | ||
return movieDao.pagingSource(movieList) | ||
} | ||
|
||
fun moviesFlow(movieList: String, limit: Int): Flow<List<MovieDb>> { | ||
return movieDao.moviesFlow(movieList, limit) | ||
} | ||
|
||
suspend fun movies(movieList: String, limit: Int): List<MovieDb> { | ||
return movieDao.movies(movieList, limit) | ||
} | ||
|
||
suspend fun moviesMini(movieList: String, limit: Int): List<MovieDbMini> { | ||
return movieDao.moviesMini(movieList, limit) | ||
} | ||
|
||
suspend fun insertMovies(movies: List<MovieDb>) { | ||
movieDao.insertMovies(movies) | ||
} | ||
|
||
suspend fun insertMovie(movie: MovieDb) { | ||
movieDao.insertMovie(movie) | ||
} | ||
|
||
suspend fun removeMovies(movieList: String) { | ||
movieDao.removeMovies(movieList) | ||
} | ||
|
||
suspend fun removeMovie(movieList: String, movieId: Int) { | ||
movieDao.removeMovie(movieList, movieId) | ||
} | ||
|
||
suspend fun movieById(pagingKey: String, movieId: Int): MovieDb? { | ||
return movieDao.movieById(pagingKey, movieId) | ||
} | ||
|
||
suspend fun maxPosition(movieList: String): Int? { | ||
return movieDao.maxPosition(movieList) | ||
} | ||
|
||
suspend fun isEmpty(movieList: String): Boolean { | ||
return movieDao.isEmpty(movieList) | ||
} | ||
|
||
suspend fun updateMovieColors(movieId: Int, containerColor: Int, onContainerColor: Int) { | ||
movieDao.updateMovieColors(movieId, containerColor, onContainerColor) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
.../persistence/src/main/kotlin/org/michaelbel/movies/persistence/database/MoviesDatabase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.michaelbel.movies.persistence.database | ||
|
||
import androidx.room.withTransaction | ||
import org.michaelbel.movies.persistence.database.db.AppDatabase | ||
import javax.inject.Inject | ||
|
||
class MoviesDatabase @Inject internal constructor( | ||
private val database: AppDatabase | ||
) { | ||
|
||
suspend fun <R> withTransaction(block: suspend () -> R): R { | ||
return database.withTransaction(block) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...stence/src/main/kotlin/org/michaelbel/movies/persistence/database/PagingKeyPersistence.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.michaelbel.movies.persistence.database | ||
|
||
import org.michaelbel.movies.persistence.database.dao.PagingKeyDao | ||
import org.michaelbel.movies.persistence.database.entity.PagingKeyDb | ||
import javax.inject.Inject | ||
|
||
class PagingKeyPersistence @Inject internal constructor( | ||
private val pagingKeyDao: PagingKeyDao | ||
) { | ||
|
||
suspend fun page(pagingKey: String): Int? { | ||
return pagingKeyDao.page(pagingKey) | ||
} | ||
|
||
suspend fun totalPages(pagingKey: String): Int? { | ||
return pagingKeyDao.totalPages(pagingKey) | ||
} | ||
|
||
suspend fun removePagingKey(pagingKey: String) { | ||
pagingKeyDao.removePagingKey(pagingKey) | ||
} | ||
|
||
suspend fun insertPagingKey(pagingKey: PagingKeyDb) { | ||
pagingKeyDao.insertPagingKey(pagingKey) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...tence/src/main/kotlin/org/michaelbel/movies/persistence/database/SuggestionPersistence.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.michaelbel.movies.persistence.database | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import org.michaelbel.movies.persistence.database.dao.SuggestionDao | ||
import org.michaelbel.movies.persistence.database.entity.SuggestionDb | ||
import javax.inject.Inject | ||
|
||
class SuggestionPersistence @Inject internal constructor( | ||
private val suggestionDao: SuggestionDao | ||
) { | ||
|
||
fun suggestionsFlow(): Flow<List<SuggestionDb>> { | ||
return suggestionDao.suggestionsFlow() | ||
} | ||
|
||
suspend fun insert(suggestions: List<SuggestionDb>) { | ||
suggestionDao.insert(suggestions) | ||
} | ||
|
||
suspend fun removeAll() { | ||
suggestionDao.removeAll() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.