-
-
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
b100280
commit 5a1598a
Showing
43 changed files
with
425 additions
and
112 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...ractor/src/androidMain/kotlin/org/michaelbel/movies/interactor/MovieBlockingInteractor.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,20 @@ | ||
@file:Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") | ||
|
||
package org.michaelbel.movies.interactor | ||
|
||
import androidx.paging.PagingData | ||
import kotlinx.coroutines.flow.Flow | ||
import org.michaelbel.movies.common.list.MovieList | ||
import org.michaelbel.movies.persistence.database.entity.pojo.MoviePojo | ||
import org.michaelbel.movies.persistence.database.typealiases.Query | ||
|
||
actual interface MovieBlockingInteractor { | ||
|
||
fun moviesPagingData( | ||
movieList: MovieList | ||
): Flow<PagingData<MoviePojo>> | ||
|
||
fun moviesPagingData( | ||
searchQuery: Query | ||
): Flow<PagingData<MoviePojo>> | ||
} |
21 changes: 21 additions & 0 deletions
21
...rc/androidMain/kotlin/org/michaelbel/movies/interactor/di/InteractorBlockingKoinModule.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,21 @@ | ||
package org.michaelbel.movies.interactor.di | ||
|
||
import org.koin.core.module.dsl.bind | ||
import org.koin.core.module.dsl.singleOf | ||
import org.koin.dsl.module | ||
import org.michaelbel.movies.analytics.di.moviesAnalyticsKoinModule | ||
import org.michaelbel.movies.common.dispatchers.di.dispatchersKoinModule | ||
import org.michaelbel.movies.interactor.MovieBlockingInteractor | ||
import org.michaelbel.movies.interactor.impl.MovieBlockingInteractorImpl | ||
import org.michaelbel.movies.persistence.database.di.moviesDatabaseKoinModule | ||
import org.michaelbel.movies.repository.di.repositoryBlockingKoinModule | ||
|
||
actual val interactorBlockingKoinModule = module { | ||
includes( | ||
dispatchersKoinModule, | ||
repositoryBlockingKoinModule, | ||
moviesDatabaseKoinModule, | ||
moviesAnalyticsKoinModule | ||
) | ||
singleOf(::MovieBlockingInteractorImpl) { bind<MovieBlockingInteractor>() } | ||
} |
72 changes: 72 additions & 0 deletions
72
...c/androidMain/kotlin/org/michaelbel/movies/interactor/impl/MovieBlockingInteractorImpl.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,72 @@ | ||
@file:OptIn(ExperimentalPagingApi::class) | ||
|
||
package org.michaelbel.movies.interactor.impl | ||
|
||
import androidx.paging.ExperimentalPagingApi | ||
import androidx.paging.Pager | ||
import androidx.paging.PagingConfig | ||
import androidx.paging.PagingData | ||
import kotlinx.coroutines.flow.Flow | ||
import org.michaelbel.movies.common.list.MovieList | ||
import org.michaelbel.movies.interactor.LocaleInteractor | ||
import org.michaelbel.movies.interactor.MovieBlockingInteractor | ||
import org.michaelbel.movies.interactor.ktx.nameOrLocalList | ||
import org.michaelbel.movies.interactor.remote.FeedMoviesRemoteMediator | ||
import org.michaelbel.movies.interactor.remote.SearchMoviesRemoteMediator | ||
import org.michaelbel.movies.network.model.MovieResponse | ||
import org.michaelbel.movies.persistence.database.MoviesDatabase | ||
import org.michaelbel.movies.persistence.database.entity.pojo.MoviePojo | ||
import org.michaelbel.movies.persistence.database.typealiases.Query | ||
import org.michaelbel.movies.repository.MovieBlockingRepository | ||
import org.michaelbel.movies.repository.MovieRepository | ||
import org.michaelbel.movies.repository.PagingKeyRepository | ||
import org.michaelbel.movies.repository.SearchRepository | ||
|
||
internal class MovieBlockingInteractorImpl( | ||
private val localeInteractor: LocaleInteractor, | ||
private val searchRepository: SearchRepository, | ||
private val movieRepository: MovieRepository, | ||
private val movieBlockingRepository: MovieBlockingRepository, | ||
private val pagingKeyRepository: PagingKeyRepository, | ||
private val moviesDatabase: MoviesDatabase | ||
): MovieBlockingInteractor { | ||
|
||
override fun moviesPagingData( | ||
movieList: MovieList | ||
): Flow<PagingData<MoviePojo>> { | ||
return Pager( | ||
config = PagingConfig( | ||
pageSize = MovieResponse.DEFAULT_PAGE_SIZE, | ||
enablePlaceholders = true | ||
), | ||
remoteMediator = FeedMoviesRemoteMediator( | ||
localeInteractor = localeInteractor, | ||
movieRepository = movieRepository, | ||
pagingKeyRepository = pagingKeyRepository, | ||
moviesDatabase = moviesDatabase, | ||
pagingKey = MovieList.name(movieList) | ||
), | ||
pagingSourceFactory = { movieBlockingRepository.moviesPagingSource(movieList.nameOrLocalList) } | ||
).flow | ||
} | ||
|
||
override fun moviesPagingData( | ||
searchQuery: Query | ||
): Flow<PagingData<MoviePojo>> { | ||
return Pager( | ||
config = PagingConfig( | ||
pageSize = MovieResponse.DEFAULT_PAGE_SIZE, | ||
enablePlaceholders = true | ||
), | ||
remoteMediator = SearchMoviesRemoteMediator( | ||
localeInteractor = localeInteractor, | ||
pagingKeyRepository = pagingKeyRepository, | ||
searchRepository = searchRepository, | ||
movieRepository = movieRepository, | ||
moviesDatabase = moviesDatabase, | ||
query = searchQuery | ||
), | ||
pagingSourceFactory = { movieBlockingRepository.moviesPagingSource(searchQuery) } | ||
).flow | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...eractor/src/commonMain/kotlin/org/michaelbel/movies/interactor/MovieBlockingInteractor.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,3 @@ | ||
package org.michaelbel.movies.interactor | ||
|
||
expect interface MovieBlockingInteractor |
18 changes: 1 addition & 17 deletions
18
core/interactor/src/commonMain/kotlin/org/michaelbel/movies/interactor/MovieInteractor.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
31 changes: 31 additions & 0 deletions
31
...src/commonMain/kotlin/org/michaelbel/movies/interactor/di/InteractorBlockingKoinModule.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,31 @@ | ||
package org.michaelbel.movies.interactor.di | ||
|
||
import org.koin.core.module.Module | ||
import org.koin.core.module.dsl.bind | ||
import org.koin.core.module.dsl.singleOf | ||
import org.koin.dsl.module | ||
import org.michaelbel.movies.analytics.di.moviesAnalyticsKoinModule | ||
import org.michaelbel.movies.common.dispatchers.di.dispatchersKoinModule | ||
import org.michaelbel.movies.interactor.AccountInteractor | ||
import org.michaelbel.movies.interactor.AuthenticationInteractor | ||
import org.michaelbel.movies.interactor.ImageInteractor | ||
import org.michaelbel.movies.interactor.Interactor | ||
import org.michaelbel.movies.interactor.LocaleInteractor | ||
import org.michaelbel.movies.interactor.MovieInteractor | ||
import org.michaelbel.movies.interactor.NotificationInteractor | ||
import org.michaelbel.movies.interactor.SearchInteractor | ||
import org.michaelbel.movies.interactor.SettingsInteractor | ||
import org.michaelbel.movies.interactor.SuggestionInteractor | ||
import org.michaelbel.movies.interactor.impl.AccountInteractorImpl | ||
import org.michaelbel.movies.interactor.impl.AuthenticationInteractorImpl | ||
import org.michaelbel.movies.interactor.impl.ImageInteractorImpl | ||
import org.michaelbel.movies.interactor.impl.MovieInteractorImpl | ||
import org.michaelbel.movies.interactor.impl.NotificationInteractorImpl | ||
import org.michaelbel.movies.interactor.impl.SearchInteractorImpl | ||
import org.michaelbel.movies.interactor.impl.SettingsInteractorImpl | ||
import org.michaelbel.movies.interactor.impl.SuggestionInteractorImpl | ||
import org.michaelbel.movies.interactor.impl.LocaleInteractorImpl | ||
import org.michaelbel.movies.persistence.database.di.moviesDatabaseKoinModule | ||
import org.michaelbel.movies.repository.di.repositoryKoinModule | ||
|
||
expect val interactorBlockingKoinModule: Module |
68 changes: 2 additions & 66 deletions
68
...ractor/src/commonMain/kotlin/org/michaelbel/movies/interactor/impl/MovieInteractorImpl.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
5 changes: 5 additions & 0 deletions
5
...ractor/src/desktopMain/kotlin/org/michaelbel/movies/interactor/MovieBlockingInteractor.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,5 @@ | ||
@file:Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") | ||
|
||
package org.michaelbel.movies.interactor | ||
|
||
actual interface MovieBlockingInteractor |
21 changes: 21 additions & 0 deletions
21
...rc/desktopMain/kotlin/org/michaelbel/movies/interactor/di/InteractorBlockingKoinModule.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,21 @@ | ||
package org.michaelbel.movies.interactor.di | ||
|
||
import org.koin.core.module.dsl.bind | ||
import org.koin.core.module.dsl.singleOf | ||
import org.koin.dsl.module | ||
import org.michaelbel.movies.analytics.di.moviesAnalyticsKoinModule | ||
import org.michaelbel.movies.common.dispatchers.di.dispatchersKoinModule | ||
import org.michaelbel.movies.interactor.MovieBlockingInteractor | ||
import org.michaelbel.movies.interactor.impl.MovieBlockingInteractorImpl | ||
import org.michaelbel.movies.persistence.database.di.moviesDatabaseKoinModule | ||
import org.michaelbel.movies.repository.di.repositoryBlockingKoinModule | ||
|
||
actual val interactorBlockingKoinModule = module { | ||
includes( | ||
dispatchersKoinModule, | ||
repositoryBlockingKoinModule, | ||
moviesDatabaseKoinModule, | ||
moviesAnalyticsKoinModule | ||
) | ||
singleOf(::MovieBlockingInteractorImpl) { bind<MovieBlockingInteractor>() } | ||
} |
11 changes: 11 additions & 0 deletions
11
...c/desktopMain/kotlin/org/michaelbel/movies/interactor/impl/MovieBlockingInteractorImpl.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,11 @@ | ||
@file:OptIn(ExperimentalPagingApi::class) | ||
|
||
package org.michaelbel.movies.interactor.impl | ||
|
||
import androidx.paging.ExperimentalPagingApi | ||
import org.michaelbel.movies.interactor.MovieBlockingInteractor | ||
import org.michaelbel.movies.repository.MovieBlockingRepository | ||
|
||
internal class MovieBlockingInteractorImpl( | ||
private val movieBlockingRepository: MovieBlockingRepository | ||
): MovieBlockingInteractor |
8 changes: 8 additions & 0 deletions
8
.../src/androidMain/kotlin/org/michaelbel/movies/network/HttpLoggingInterceptorKoinModule.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,8 @@ | ||
package org.michaelbel.movies.network | ||
|
||
import okhttp3.logging.HttpLoggingInterceptor | ||
import org.koin.dsl.module | ||
|
||
internal val httpLoggingInterceptorKoinModule = module { | ||
single<HttpLoggingInterceptor> { HttpLoggingInterceptor() } | ||
} |
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
17 changes: 17 additions & 0 deletions
17
...androidMain/kotlin/org/michaelbel/movies/persistence/database/MovieBlockingPersistence.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,17 @@ | ||
@file:Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") | ||
|
||
package org.michaelbel.movies.persistence.database | ||
|
||
import androidx.paging.PagingSource | ||
import org.michaelbel.movies.persistence.database.dao.MovieBlockingDao | ||
import org.michaelbel.movies.persistence.database.entity.pojo.MoviePojo | ||
import org.michaelbel.movies.persistence.database.typealiases.PagingKey | ||
|
||
actual class MovieBlockingPersistence internal constructor( | ||
private val movieBlockingDao: MovieBlockingDao | ||
) { | ||
|
||
fun pagingSource(pagingKey: PagingKey): PagingSource<Int, MoviePojo> { | ||
return movieBlockingDao.pagingSource(pagingKey) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...src/androidMain/kotlin/org/michaelbel/movies/persistence/database/dao/MovieBlockingDao.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,18 @@ | ||
@file:Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") | ||
|
||
package org.michaelbel.movies.persistence.database.dao | ||
|
||
import androidx.paging.PagingSource | ||
import androidx.room.Dao | ||
import androidx.room.Query | ||
import androidx.room.Transaction | ||
import org.michaelbel.movies.persistence.database.entity.pojo.MoviePojo | ||
import org.michaelbel.movies.persistence.database.typealiases.PagingKey | ||
|
||
@Dao | ||
internal actual interface MovieBlockingDao { | ||
|
||
@Transaction | ||
@Query("SELECT * FROM movies WHERE movieList = :pagingKey ORDER BY position ASC") | ||
fun pagingSource(pagingKey: PagingKey): PagingSource<Int, MoviePojo> | ||
} |
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.