Skip to content

Commit

Permalink
[LH-112] Add DI and dependencies for board #16
Browse files Browse the repository at this point in the history
  • Loading branch information
flash159483 committed Aug 4, 2023
1 parent aa0096f commit e4bc95b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 2 deletions.
11 changes: 11 additions & 0 deletions app/src/main/java/com/lighthouse/lingo_swap/di/DataModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import androidx.security.crypto.EncryptedSharedPreferences
import androidx.security.crypto.MasterKey
import com.lighthouse.android.data.local.LocalPreferenceDataSource
import com.lighthouse.android.data.local.LocalPreferenceDataSourceImpl
import com.lighthouse.android.data.repository.BoardRepositoryImpl
import com.lighthouse.android.data.repository.DrivenRepositoryImpl
import com.lighthouse.android.data.repository.HomeRepositoryImpl
import com.lighthouse.android.data.repository.datasource.BoardRemoteDataSource
import com.lighthouse.android.data.repository.datasource.DrivenRemoteDataSource
import com.lighthouse.android.data.repository.datasource.HomeRemoteDataSource
import com.lighthouse.domain.repository.BoardRepository
import com.lighthouse.domain.repository.DrivenRepository
import com.lighthouse.domain.repository.HomeRepository
import com.lighthouse.lingo_swap.HeaderInterceptor
Expand Down Expand Up @@ -39,6 +42,14 @@ object DataModule {
return HomeRepositoryImpl(homeRemoteDataSource)
}

@Provides
@Singleton
fun provideBoardRepository(
boardRemoteDataSource: BoardRemoteDataSource,
): BoardRepository {
return BoardRepositoryImpl(boardRemoteDataSource)
}

@Provides
@Singleton
fun provideHeaderInterceptor(localPreferenceDataSource: LocalPreferenceDataSource): HeaderInterceptor {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.lighthouse.lingo_swap.di

import com.lighthouse.android.data.api.BoardApiService
import com.lighthouse.android.data.api.DrivenApiService
import com.lighthouse.android.data.api.HomeApiService
import com.lighthouse.android.data.repository.datasource.BoardRemoteDataSource
import com.lighthouse.android.data.repository.datasource.DrivenRemoteDataSource
import com.lighthouse.android.data.repository.datasource.HomeRemoteDataSource
import com.lighthouse.android.data.repository.datasourceimpl.BoardRemoteDataSourceImpl
import com.lighthouse.android.data.repository.datasourceimpl.DrivenRemoteDataSourceImpl
import com.lighthouse.android.data.repository.datasourceimpl.HomeRemoteDataSourceImpl
import com.lighthouse.lingo_swap.di.Annotation.Main
Expand All @@ -28,4 +31,10 @@ object DataSourceModule {
fun provideHomeDataSource(@Main homeApiService: HomeApiService): HomeRemoteDataSource {
return HomeRemoteDataSourceImpl(homeApiService)
}

@Provides
@Singleton
fun provideBoardDataSource(@Main boardApiService: BoardApiService): BoardRemoteDataSource {
return BoardRemoteDataSourceImpl(boardApiService)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.lighthouse.lingo_swap.di

import com.lighthouse.domain.repository.BoardRepository
import com.lighthouse.domain.repository.HomeRepository
import com.lighthouse.domain.usecase.GetMatchedUserUseCase
import com.lighthouse.domain.usecase.GetQuestionUseCase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand All @@ -16,4 +18,10 @@ object DomainModule {
fun provideHomeUseCase(homeRepository: HomeRepository): GetMatchedUserUseCase {
return GetMatchedUserUseCase(homeRepository)
}

@Provides
@Singleton
fun provideBoardUseCase(boardRepository: BoardRepository): GetQuestionUseCase {
return GetQuestionUseCase(boardRepository)
}
}
10 changes: 9 additions & 1 deletion app/src/main/java/com/lighthouse/lingo_swap/di/NetModule.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.lighthouse.lingo_swap.di

import com.google.gson.GsonBuilder
import com.lighthouse.android.data.api.BoardApiService
import com.lighthouse.android.data.api.DrivenApiService
import com.lighthouse.android.data.api.HomeApiService
import com.lighthouse.android.data.api.interceptor.ContentInterceptor
Expand Down Expand Up @@ -43,7 +44,7 @@ object NetModule {
@Main
fun provideLightHouseRetrofit(@Main okHttpClient: OkHttpClient): Retrofit {
return Retrofit.Builder()
.baseUrl(BuildConfig.TEST_BASE_URL)
.baseUrl(BuildConfig.LIGHTHOUSE_BASE_URL)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.build()
Expand Down Expand Up @@ -94,4 +95,11 @@ object NetModule {
fun provideHomeService(@Main retrofit: Retrofit): HomeApiService {
return retrofit.create(HomeApiService::class.java)
}

@Provides
@Singleton
@Main
fun provideBoardService(@Main retrofit: Retrofit): BoardApiService {
return retrofit.create(BoardApiService::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package com.lighthouse.android.common_ui.constant
object Constant {
const val PROFILE_IMAGE_SIZE = 80.0f
const val PROFILE_FLAG_SIZE = 25.0f
const val PAGE_SIZE = 10
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ room = "2.5.2"
shared-preference-security = "1.1.0-alpha06"

# Google Libraries
material = "1.9.0"
material = "1.7.0"
accompanist = "0.30.1"
in-app-update = "2.1.0"

Expand Down

0 comments on commit e4bc95b

Please sign in to comment.