Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

マルチモジュール対応 #56

Merged
merged 8 commits into from
Jan 3, 2023
Merged

マルチモジュール対応 #56

merged 8 commits into from
Jan 3, 2023

Conversation

LeoAndo
Copy link
Owner

@LeoAndo LeoAndo commented Jan 3, 2023

close #55

  • マルチモジュール対応
  • UI /domain / data のレイヤー単位でモジュール分割
  • DIの関係でUIレイヤでdataモジュールの依存関係を追加している
  • 適切な箇所にinternalをつけてモジュールスコープにしている

data module作成時のテンプレートはAndroid Libraryを使用

スクリーンショット 2023-01-03 20 14 31

domain module作成時のテンプレートはJava or Kotlin Libraryを使用

スクリーンショット 2023-01-03 20 15 56

設計図

スクリーンショット 2023-01-03 21 27 05

@LeoAndo LeoAndo self-assigned this Jan 3, 2023
@@ -105,7 +105,7 @@ private fun DetailScreenStateless(
@PreviewDevices
@Composable
private fun Prev_DetailScreen() {
val data = RepositoryDetail(
val data = com.leoleo.androidgithubsearch.domain.model.RepositoryDetail(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RepositoryDetailに直す

@@ -5,7 +5,7 @@ import com.leoleo.androidgithubsearch.domain.model.RepositoryDetail
sealed interface UiState {
object Initial : UiState
object Loading : UiState
data class Data(val repositoryDetail: RepositoryDetail) : UiState
data class Data(val repositoryDetail: com.leoleo.androidgithubsearch.domain.model.RepositoryDetail) : UiState
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RepositoryDetail

@@ -62,7 +67,7 @@ fun SearchScreen(
@Composable
private fun SearchScreenStateless(
modifier: Modifier,
githubRepositories: LazyPagingItems<RepositorySummary>,
githubRepositories: LazyPagingItems<com.leoleo.androidgithubsearch.domain.model.RepositorySummary>,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RepositorySummary

@@ -168,7 +173,7 @@ private fun LazyListScope.errorContent(
@Composable
private fun Prev_Initial_SearchScreen() {
val githubRepositories =
flowOf<PagingData<RepositorySummary>>(PagingData.empty()).collectAsLazyPagingItems()
flowOf<PagingData<com.leoleo.androidgithubsearch.domain.model.RepositorySummary>>(PagingData.empty()).collectAsLazyPagingItems()
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RepositorySummary

private val query: String,
private val api: GithubApi,
private val ktorHandler: KtorHandler,
) : PagingSource<Int, RepositorySummary>() {
) : PagingSource<Int, com.leoleo.androidgithubsearch.domain.model.RepositorySummary>() {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RepositorySummary

private val api: GithubApi,
private val ktorHandler: KtorHandler,
) : GithubRepoRepository {
) : com.leoleo.androidgithubsearch.domain.repository.GithubRepoRepository {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GithubRepoRepository

ktorHandler.dataOrThrow { api.fetchRepositoryDetail(ownerName, repositoryName) }

override fun searchRepositories(query: String): Flow<PagingData<RepositorySummary>> {
override fun searchRepositories(query: String): Flow<PagingData<com.leoleo.androidgithubsearch.domain.model.RepositorySummary>> {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RepositorySummary

@@ -12,4 +14,5 @@ plugins {
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
id 'org.jetbrains.kotlin.plugin.serialization' version '1.7.20' apply false
id 'org.jetbrains.kotlin.jvm' version '1.7.20' apply false
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

domain module追加時に自動的に追加された。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

マルチモジュール対応
1 participant