-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* chore: Hilt ์์กด์ฑ ์ถ๊ฐ Co-authored-by: SeongHoonC <[email protected]> * feat: ์์กด์ฑ ์ฃผ์ ๋ชจ๋ ์ถ๊ฐ Co-authored-by: SeongHoonC <[email protected]> * feat: ์์กด์ฑ ์ฃผ์ ์ hilt ์ ์ฉ Co-authored-by: SeongHoonC <[email protected]> * refactor: ์ฌ์ฉํ์ง ์๋ ์๋ di ์ฝ๋ ์ญ์ Co-authored-by: SeongHoonC <[email protected]> * chore: ktlintcheck Co-authored-by: SeongHoonC <[email protected]> * refactor: ๋ถํ์ํ ์ด๋ ธํ ์ด์ ์ ๊ฑฐ * refactor: ๋ทฐ๋ชจ๋ธ ์ค์ฝํ ๋ชจ๋ ๋ถ๋ฆฌ * chore: ์ฑ๊ธํค ๋ชจ๋ ํจํค์ง ์ด๋ * refactor: BaseUrlQualifier ์ถ๊ฐ --------- Co-authored-by: SeongHoonC <[email protected]>
- Loading branch information
Showing
48 changed files
with
357 additions
and
317 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
44 changes: 2 additions & 42 deletions
44
android/festago/app/src/main/java/com/festago/festago/FestagoApplication.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 |
---|---|---|
@@ -1,58 +1,18 @@ | ||
package com.festago.festago | ||
|
||
import android.app.Application | ||
import com.festago.festago.analytics.FirebaseAnalyticsHelper | ||
import com.festago.festago.di.AnalysisContainer | ||
import com.festago.festago.di.AuthServiceContainer | ||
import com.festago.festago.di.LocalDataSourceContainer | ||
import com.festago.festago.di.NormalServiceContainer | ||
import com.festago.festago.di.RepositoryContainer | ||
import com.festago.festago.di.TokenContainer | ||
import com.kakao.sdk.common.KakaoSdk | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class FestagoApplication : Application() { | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
initKakaoSdk() | ||
initRepositoryContainer() | ||
initFirebaseContainer() | ||
} | ||
|
||
private fun initKakaoSdk() { | ||
KakaoSdk.init(this, BuildConfig.KAKAO_NATIVE_APP_KEY) | ||
} | ||
|
||
private fun initRepositoryContainer() { | ||
normalServiceContainer = NormalServiceContainer(BuildConfig.BASE_URL) | ||
|
||
tokenContainer = TokenContainer( | ||
normalServiceContainer = normalServiceContainer, | ||
localDataSourceContainer = LocalDataSourceContainer(applicationContext), | ||
) | ||
|
||
authServiceContainer = AuthServiceContainer( | ||
baseUrl = BuildConfig.BASE_URL, | ||
tokenContainer = tokenContainer, | ||
) | ||
|
||
repositoryContainer = RepositoryContainer( | ||
authServiceContainer = authServiceContainer, | ||
normalServiceContainer = normalServiceContainer, | ||
tokenContainer = tokenContainer, | ||
) | ||
} | ||
|
||
private fun initFirebaseContainer() { | ||
FirebaseAnalyticsHelper.init(applicationContext) | ||
analysisContainer = AnalysisContainer() | ||
} | ||
|
||
companion object DependencyContainer { | ||
lateinit var normalServiceContainer: NormalServiceContainer | ||
lateinit var authServiceContainer: AuthServiceContainer | ||
lateinit var repositoryContainer: RepositoryContainer | ||
lateinit var analysisContainer: AnalysisContainer | ||
lateinit var tokenContainer: TokenContainer | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
android/festago/app/src/main/java/com/festago/festago/data/di/ViewModelScopeModule.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,30 @@ | ||
package com.festago.festago.data.di | ||
|
||
import com.festago.festago.data.repository.ReservationTicketDefaultRepository | ||
import com.festago.festago.data.repository.StudentVerificationDefaultRepository | ||
import com.festago.festago.data.repository.UserDefaultRepository | ||
import com.festago.festago.repository.ReservationTicketRepository | ||
import com.festago.festago.repository.StudentVerificationRepository | ||
import com.festago.festago.repository.UserRepository | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.components.ViewModelComponent | ||
import dagger.hilt.android.scopes.ViewModelScoped | ||
|
||
@InstallIn(ViewModelComponent::class) | ||
@Module | ||
interface ViewModelScopeModule { | ||
|
||
@Binds | ||
@ViewModelScoped | ||
fun bindsReservationTicketDefaultRepository(reservationTicketRepository: ReservationTicketDefaultRepository): ReservationTicketRepository | ||
|
||
@Binds | ||
@ViewModelScoped | ||
fun bindsStudentVerificationDefaultRepository(studentVerificationRepository: StudentVerificationDefaultRepository): StudentVerificationRepository | ||
|
||
@Binds | ||
@ViewModelScoped | ||
fun binsUserDefaultRepository(userRepository: UserDefaultRepository): UserRepository | ||
} |
19 changes: 19 additions & 0 deletions
19
...d/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/AnalyticsModule.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 com.festago.festago.data.di.singletonscope | ||
|
||
import com.festago.festago.analytics.AnalyticsHelper | ||
import com.festago.festago.analytics.FirebaseAnalyticsHelper | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@InstallIn(SingletonComponent::class) | ||
@Module | ||
interface AnalyticsModule { | ||
@Binds | ||
@Singleton | ||
fun bindsFirebaseAnalyticsHelper( | ||
analyticsHelper: FirebaseAnalyticsHelper | ||
): AnalyticsHelper | ||
} |
65 changes: 65 additions & 0 deletions
65
android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ApiModule.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,65 @@ | ||
package com.festago.festago.data.di.singletonscope | ||
|
||
import com.festago.festago.BuildConfig | ||
import com.festago.festago.data.retrofit.AuthInterceptor | ||
import com.festago.festago.data.retrofit.TokenManager | ||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import kotlinx.serialization.json.Json | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import okhttp3.OkHttpClient | ||
import retrofit2.Retrofit | ||
import javax.inject.Qualifier | ||
import javax.inject.Singleton | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class NormalRetrofitQualifier | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class AuthRetrofitQualifier | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class BaseUrlQualifier | ||
|
||
@InstallIn(SingletonComponent::class) | ||
@Module | ||
object ApiModule { | ||
|
||
@Provides | ||
@Singleton | ||
fun provideOkHttpClient(tokenManager: TokenManager): OkHttpClient = OkHttpClient | ||
.Builder() | ||
.addInterceptor(AuthInterceptor(tokenManager)) | ||
.build() | ||
|
||
@Provides | ||
@Singleton | ||
@NormalRetrofitQualifier | ||
fun providesNormalRetrofit(@BaseUrlQualifier baseUrl: String): Retrofit = Retrofit.Builder() | ||
.baseUrl(baseUrl) | ||
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) | ||
.build() | ||
|
||
@Provides | ||
@Singleton | ||
@AuthRetrofitQualifier | ||
fun providesAuthRetrofit( | ||
@BaseUrlQualifier baseUrl: String, | ||
okHttpClient: OkHttpClient | ||
): Retrofit = Retrofit.Builder() | ||
.baseUrl(baseUrl) | ||
.client(okHttpClient) | ||
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) | ||
.build() | ||
|
||
@Provides | ||
@Singleton | ||
@BaseUrlQualifier | ||
fun providesBaseUrl(): String = BuildConfig.BASE_URL | ||
} |
17 changes: 17 additions & 0 deletions
17
.../festago/app/src/main/java/com/festago/festago/data/di/singletonscope/DataSourceModule.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 @@ | ||
package com.festago.festago.data.di.singletonscope | ||
|
||
import com.festago.festago.data.datasource.TokenDataSource | ||
import com.festago.festago.data.datasource.TokenLocalDataSource | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@InstallIn(SingletonComponent::class) | ||
@Module | ||
interface DataSourceModule { | ||
@Binds | ||
@Singleton | ||
fun bindsLocalTokenDataSource(tokenDataSource: TokenLocalDataSource): TokenDataSource | ||
} |
40 changes: 40 additions & 0 deletions
40
.../festago/app/src/main/java/com/festago/festago/data/di/singletonscope/RepositoryModule.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,40 @@ | ||
package com.festago.festago.data.di.singletonscope | ||
|
||
import com.festago.festago.data.repository.AuthDefaultRepository | ||
import com.festago.festago.data.repository.FestivalDefaultRepository | ||
import com.festago.festago.data.repository.SchoolDefaultRepository | ||
import com.festago.festago.data.repository.TicketDefaultRepository | ||
import com.festago.festago.data.repository.TokenDefaultRepository | ||
import com.festago.festago.repository.AuthRepository | ||
import com.festago.festago.repository.FestivalRepository | ||
import com.festago.festago.repository.SchoolRepository | ||
import com.festago.festago.repository.TicketRepository | ||
import com.festago.festago.repository.TokenRepository | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@InstallIn(SingletonComponent::class) | ||
@Module | ||
interface RepositoryModule { | ||
|
||
@Binds | ||
fun bindsTokenDefaultRepository(tokenRepository: TokenDefaultRepository): TokenRepository | ||
|
||
@Binds | ||
fun bindsAuthDefaultRepository(authRepository: AuthDefaultRepository): AuthRepository | ||
|
||
@Binds | ||
@Singleton | ||
fun bindsFestivalDefaultRepository(festivalRepository: FestivalDefaultRepository): FestivalRepository | ||
|
||
@Binds | ||
@Singleton | ||
fun bindsSchoolDefaultRepository(schoolRepository: SchoolDefaultRepository): SchoolRepository | ||
|
||
@Binds | ||
@Singleton | ||
fun bindsTicketDefaultRepository(ticketRepository: TicketDefaultRepository): TicketRepository | ||
} |
67 changes: 67 additions & 0 deletions
67
...oid/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ServiceModule.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,67 @@ | ||
package com.festago.festago.data.di.singletonscope | ||
|
||
import com.festago.festago.data.service.FestivalRetrofitService | ||
import com.festago.festago.data.service.ReservationTicketRetrofitService | ||
import com.festago.festago.data.service.StudentVerificationRetrofitService | ||
import com.festago.festago.data.service.TicketRetrofitService | ||
import com.festago.festago.data.service.TokenRetrofitService | ||
import com.festago.festago.data.service.UserRetrofitService | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import retrofit2.Retrofit | ||
import javax.inject.Singleton | ||
|
||
@InstallIn(SingletonComponent::class) | ||
@Module | ||
object ServiceModule { | ||
|
||
@Provides | ||
@Singleton | ||
fun providesFestivalRetrofitService( | ||
@NormalRetrofitQualifier retrofit: Retrofit | ||
): FestivalRetrofitService { | ||
return retrofit.create(FestivalRetrofitService::class.java) | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
fun providesTokenRetrofitService( | ||
@NormalRetrofitQualifier retrofit: Retrofit | ||
): TokenRetrofitService { | ||
return retrofit.create(TokenRetrofitService::class.java) | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
fun providesReservationTicketRetrofitService( | ||
@NormalRetrofitQualifier retrofit: Retrofit | ||
): ReservationTicketRetrofitService { | ||
return retrofit.create(ReservationTicketRetrofitService::class.java) | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
fun providesTicketRetrofitService( | ||
@AuthRetrofitQualifier retrofit: Retrofit | ||
): TicketRetrofitService { | ||
return retrofit.create(TicketRetrofitService::class.java) | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
fun providesUserRetrofitService( | ||
@AuthRetrofitQualifier retrofit: Retrofit | ||
): UserRetrofitService { | ||
return retrofit.create(UserRetrofitService::class.java) | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
fun providesStudentVerificationRetrofitService( | ||
@AuthRetrofitQualifier retrofit: Retrofit | ||
): StudentVerificationRetrofitService { | ||
return retrofit.create(StudentVerificationRetrofitService::class.java) | ||
} | ||
} |
Oops, something went wrong.