From f11fbd6bfe4cd5570f29dec5bd0073d05182abd7 Mon Sep 17 00:00:00 2001 From: EmilyCh0 Date: Tue, 19 Sep 2023 16:59:13 +0900 Subject: [PATCH 1/9] =?UTF-8?q?chore:=20Hilt=20=EC=9D=98=EC=A1=B4=EC=84=B1?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: SeongHoonC --- android/festago/app/build.gradle.kts | 15 ++++++++++++--- android/festago/build.gradle.kts | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/android/festago/app/build.gradle.kts b/android/festago/app/build.gradle.kts index 8429e2e94..6b8c2aa7f 100644 --- a/android/festago/app/build.gradle.kts +++ b/android/festago/app/build.gradle.kts @@ -9,6 +9,7 @@ plugins { id("com.google.gms.google-services") id("com.google.firebase.crashlytics") id("org.jlleitschuh.gradle.ktlint") + id("com.google.dagger.hilt.android") } android { @@ -63,13 +64,24 @@ kotlin { jvmToolchain(17) } +kapt { + correctErrorTypes = true +} + dependencies { + // domain + implementation(project(":domain")) + // android implementation("androidx.core:core-ktx:1.10.1") implementation("androidx.appcompat:appcompat:1.6.1") implementation("com.google.android.material:material:1.9.0") implementation("androidx.constraintlayout:constraintlayout:2.1.4") + // hilt + implementation("com.google.dagger:hilt-android:2.44") + kapt("com.google.dagger:hilt-android-compiler:2.44") + // recyclerview implementation("androidx.recyclerview:recyclerview:1.3.1-rc01") @@ -139,9 +151,6 @@ dependencies { // turbine testImplementation("app.cash.turbine:turbine:1.0.0") - - // domain - implementation(project(":domain")) } fun getSecretKey(propertyKey: String): String { diff --git a/android/festago/build.gradle.kts b/android/festago/build.gradle.kts index 4ae1b27c0..649598d35 100644 --- a/android/festago/build.gradle.kts +++ b/android/festago/build.gradle.kts @@ -12,4 +12,6 @@ plugins { id("com.google.gms.google-services") version "4.3.15" apply false id("com.google.firebase.crashlytics") version "2.9.7" apply false + + id("com.google.dagger.hilt.android") version "2.44" apply false } From e5b88a2d12f32bfab7e1ca708075d4f7c14d916a Mon Sep 17 00:00:00 2001 From: EmilyCh0 Date: Tue, 19 Sep 2023 17:01:47 +0900 Subject: [PATCH 2/9] =?UTF-8?q?feat:=20=EC=9D=98=EC=A1=B4=EC=84=B1=20?= =?UTF-8?q?=EC=A3=BC=EC=9E=85=20=EB=AA=A8=EB=93=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: SeongHoonC --- .../festago/data/di/AnalyticsModule.kt | 19 ++++++ .../com/festago/festago/data/di/ApiModule.kt | 59 ++++++++++++++++ .../festago/data/di/DataSourceModule.kt | 17 +++++ .../festago/data/di/RepositoryModule.kt | 59 ++++++++++++++++ .../festago/festago/data/di/ServiceModule.kt | 67 +++++++++++++++++++ 5 files changed, 221 insertions(+) create mode 100644 android/festago/app/src/main/java/com/festago/festago/data/di/AnalyticsModule.kt create mode 100644 android/festago/app/src/main/java/com/festago/festago/data/di/ApiModule.kt create mode 100644 android/festago/app/src/main/java/com/festago/festago/data/di/DataSourceModule.kt create mode 100644 android/festago/app/src/main/java/com/festago/festago/data/di/RepositoryModule.kt create mode 100644 android/festago/app/src/main/java/com/festago/festago/data/di/ServiceModule.kt diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/AnalyticsModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/AnalyticsModule.kt new file mode 100644 index 000000000..c56e30c3e --- /dev/null +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/AnalyticsModule.kt @@ -0,0 +1,19 @@ +package com.festago.festago.data.di + +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 +} diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/ApiModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/ApiModule.kt new file mode 100644 index 000000000..f5407a101 --- /dev/null +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/ApiModule.kt @@ -0,0 +1,59 @@ +package com.festago.festago.data.di + +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 + + +@InstallIn(SingletonComponent::class) +@Module +object ApiModule { + + @Provides + @Singleton + fun provideOkHttpClient(tokenManager: TokenManager): OkHttpClient = OkHttpClient + .Builder() + .addInterceptor(AuthInterceptor(tokenManager)) + .build() + + @Provides + @Singleton + @NormalRetrofitQualifier + fun providesNormalRetrofit(baseUrl: String): Retrofit = Retrofit.Builder() + .baseUrl(baseUrl) + .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) + .build() + + @Provides + @Singleton + @AuthRetrofitQualifier + fun providesAuthRetrofit(baseUrl: String, okHttpClient: OkHttpClient): Retrofit = + Retrofit.Builder() + .baseUrl(baseUrl) + .client(okHttpClient) + .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) + .build() + + @Provides + @Singleton + fun providesBaseUrl(): String = BuildConfig.BASE_URL +} diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/DataSourceModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/DataSourceModule.kt new file mode 100644 index 000000000..ddf36ee25 --- /dev/null +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/DataSourceModule.kt @@ -0,0 +1,17 @@ +package com.festago.festago.data.di + +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 +} diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/RepositoryModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/RepositoryModule.kt new file mode 100644 index 000000000..f28132fb2 --- /dev/null +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/RepositoryModule.kt @@ -0,0 +1,59 @@ +package com.festago.festago.data.di + +import com.festago.festago.data.repository.AuthDefaultRepository +import com.festago.festago.data.repository.FestivalDefaultRepository +import com.festago.festago.data.repository.ReservationTicketDefaultRepository +import com.festago.festago.data.repository.SchoolDefaultRepository +import com.festago.festago.data.repository.StudentVerificationDefaultRepository +import com.festago.festago.data.repository.TicketDefaultRepository +import com.festago.festago.data.repository.TokenDefaultRepository +import com.festago.festago.data.repository.UserDefaultRepository +import com.festago.festago.repository.AuthRepository +import com.festago.festago.repository.FestivalRepository +import com.festago.festago.repository.ReservationTicketRepository +import com.festago.festago.repository.SchoolRepository +import com.festago.festago.repository.StudentVerificationRepository +import com.festago.festago.repository.TicketRepository +import com.festago.festago.repository.TokenRepository +import com.festago.festago.repository.UserRepository +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 + @Singleton + fun bindsAuthDefaultRepository(authRepository: AuthDefaultRepository): AuthRepository + + @Binds + @Singleton + fun bindsFestivalDefaultRepository(festivalRepository: FestivalDefaultRepository): FestivalRepository + + @Binds + @Singleton + fun bindsReservationTicketDefaultRepository(reservationTicketRepository: ReservationTicketDefaultRepository): ReservationTicketRepository + + @Binds + @Singleton + fun bindsSchoolDefaultRepository(schoolRepository: SchoolDefaultRepository): SchoolRepository + + @Binds + @Singleton + fun bindsStudentVerificationDefaultRepository(studentVerificationRepository: StudentVerificationDefaultRepository): StudentVerificationRepository + + @Binds + @Singleton + fun bindsTicketDefaultRepository(ticketRepository: TicketDefaultRepository): TicketRepository + + @Binds + @Singleton + fun bindsTokenDefaultRepository(tokenRepository: TokenDefaultRepository): TokenRepository + + @Binds + @Singleton + fun binsUserDefaultRepository(userRepository: UserDefaultRepository): UserRepository +} diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/ServiceModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/ServiceModule.kt new file mode 100644 index 000000000..dad849bda --- /dev/null +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/ServiceModule.kt @@ -0,0 +1,67 @@ +package com.festago.festago.data.di + +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) + } +} From f3705d41355235103426086afdecc078925c40e8 Mon Sep 17 00:00:00 2001 From: EmilyCh0 Date: Tue, 19 Sep 2023 17:02:59 +0900 Subject: [PATCH 3/9] =?UTF-8?q?feat:=20=EC=9D=98=EC=A1=B4=EC=84=B1=20?= =?UTF-8?q?=EC=A3=BC=EC=9E=85=EC=97=90=20hilt=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: SeongHoonC --- .../com/festago/festago/FestagoApplication.kt | 44 +------------------ .../analytics/FirebaseAnalyticsHelper.kt | 20 ++++++--- .../data/datasource/TokenLocalDataSource.kt | 8 +++- .../data/repository/AuthDefaultRepository.kt | 5 ++- .../repository/FestivalDefaultRepository.kt | 5 ++- .../ReservationTicketDefaultRepository.kt | 5 ++- .../repository/SchoolDefaultRepository.kt | 5 ++- .../StudentVerificationDefaultRepository.kt | 5 ++- .../repository/TicketDefaultRepository.kt | 5 ++- .../data/repository/TokenDefaultRepository.kt | 5 ++- .../data/repository/UserDefaultRepository.kt | 5 ++- .../festago/data/retrofit/TokenManager.kt | 5 ++- .../ui/customview/OkDialogFragment.kt | 2 + .../presentation/ui/home/HomeActivity.kt | 5 ++- .../presentation/ui/home/HomeViewModel.kt | 5 ++- .../home/festivallist/FestivalListFragment.kt | 5 ++- .../festivallist/FestivalListViewModel.kt | 5 ++- .../ui/home/mypage/MyPageFragment.kt | 5 ++- .../ui/home/mypage/MyPageViewModel.kt | 5 ++- .../ui/home/ticketlist/TicketListFragment.kt | 5 ++- .../ui/home/ticketlist/TicketListViewModel.kt | 5 ++- .../ReservationCompleteActivity.kt | 2 + .../presentation/ui/signin/SignInActivity.kt | 5 ++- .../presentation/ui/signin/SignInViewModel.kt | 5 ++- .../StudentVerificationActivity.kt | 5 ++- .../StudentVerificationViewModel.kt | 5 ++- .../ui/ticketentry/TicketEntryActivity.kt | 5 ++- .../ui/ticketentry/TicketEntryViewModel.kt | 5 ++- .../ui/tickethistory/TicketHistoryActivity.kt | 5 ++- .../tickethistory/TicketHistoryViewModel.kt | 5 ++- .../ui/ticketreserve/TicketReserveActivity.kt | 5 ++- .../ticketreserve/TicketReserveViewModel.kt | 5 ++- .../TicketReserveBottomSheetFragment.kt | 2 + 33 files changed, 127 insertions(+), 86 deletions(-) diff --git a/android/festago/app/src/main/java/com/festago/festago/FestagoApplication.kt b/android/festago/app/src/main/java/com/festago/festago/FestagoApplication.kt index 91aab83e0..1a1877069 100644 --- a/android/festago/app/src/main/java/com/festago/festago/FestagoApplication.kt +++ b/android/festago/app/src/main/java/com/festago/festago/FestagoApplication.kt @@ -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 - } } diff --git a/android/festago/app/src/main/java/com/festago/festago/analytics/FirebaseAnalyticsHelper.kt b/android/festago/app/src/main/java/com/festago/festago/analytics/FirebaseAnalyticsHelper.kt index 062e5903f..6c5faea32 100644 --- a/android/festago/app/src/main/java/com/festago/festago/analytics/FirebaseAnalyticsHelper.kt +++ b/android/festago/app/src/main/java/com/festago/festago/analytics/FirebaseAnalyticsHelper.kt @@ -3,15 +3,17 @@ package com.festago.festago.analytics import android.content.Context import android.os.Bundle import com.google.firebase.analytics.FirebaseAnalytics +import dagger.hilt.android.qualifiers.ApplicationContext +import javax.inject.Inject +import javax.inject.Singleton -object FirebaseAnalyticsHelper : AnalyticsHelper { +@Singleton +class FirebaseAnalyticsHelper @Inject constructor( + @ApplicationContext context: Context +) : AnalyticsHelper { - private const val LOG_NAME = "festago_log" - private lateinit var firebaseAnalytics: FirebaseAnalytics - - fun init(context: Context) { - if (::firebaseAnalytics.isInitialized) return - firebaseAnalytics = FirebaseAnalytics.getInstance(context.applicationContext) + private val firebaseAnalytics: FirebaseAnalytics by lazy { + FirebaseAnalytics.getInstance(context.applicationContext) } override fun logEvent(event: AnalyticsEvent) { @@ -22,4 +24,8 @@ object FirebaseAnalyticsHelper : AnalyticsHelper { } firebaseAnalytics.logEvent(LOG_NAME, params) } + + companion object { + private const val LOG_NAME = "festago_log" + } } diff --git a/android/festago/app/src/main/java/com/festago/festago/data/datasource/TokenLocalDataSource.kt b/android/festago/app/src/main/java/com/festago/festago/data/datasource/TokenLocalDataSource.kt index 6cce56927..c0515b236 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/datasource/TokenLocalDataSource.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/datasource/TokenLocalDataSource.kt @@ -4,8 +4,14 @@ import android.content.Context import android.content.SharedPreferences import androidx.security.crypto.EncryptedSharedPreferences import androidx.security.crypto.MasterKey +import dagger.hilt.android.qualifiers.ApplicationContext +import javax.inject.Inject +import javax.inject.Singleton -class TokenLocalDataSource(context: Context) : TokenDataSource { +@Singleton +class TokenLocalDataSource @Inject constructor( + @ApplicationContext context: Context +) : TokenDataSource { private val sharedPreference: SharedPreferences by lazy { val masterKeyAlias = MasterKey diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/AuthDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/AuthDefaultRepository.kt index 2594cb3c4..303b72107 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/AuthDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/AuthDefaultRepository.kt @@ -5,8 +5,11 @@ import com.festago.festago.data.util.runCatchingWithErrorHandler import com.festago.festago.repository.AuthRepository import com.festago.festago.repository.TokenRepository import com.kakao.sdk.user.UserApiClient +import javax.inject.Inject +import javax.inject.Singleton -class AuthDefaultRepository( +@Singleton +class AuthDefaultRepository @Inject constructor( private val userRetrofitService: UserRetrofitService, private val tokenRepository: TokenRepository, ) : AuthRepository { diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/FestivalDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/FestivalDefaultRepository.kt index d7fece84d..f124ac853 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/FestivalDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/FestivalDefaultRepository.kt @@ -5,8 +5,11 @@ import com.festago.festago.data.util.runCatchingWithErrorHandler import com.festago.festago.model.Festival import com.festago.festago.model.Reservation import com.festago.festago.repository.FestivalRepository +import javax.inject.Inject +import javax.inject.Singleton -class FestivalDefaultRepository( +@Singleton +class FestivalDefaultRepository @Inject constructor( private val festivalRetrofitService: FestivalRetrofitService, ) : FestivalRepository { override suspend fun loadFestivals(): Result> { diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/ReservationTicketDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/ReservationTicketDefaultRepository.kt index 8519a45fe..c3f60e22b 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/ReservationTicketDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/ReservationTicketDefaultRepository.kt @@ -4,8 +4,11 @@ import com.festago.festago.data.service.ReservationTicketRetrofitService import com.festago.festago.data.util.runCatchingWithErrorHandler import com.festago.festago.model.ReservationTicket import com.festago.festago.repository.ReservationTicketRepository +import javax.inject.Inject +import javax.inject.Singleton -class ReservationTicketDefaultRepository( +@Singleton +class ReservationTicketDefaultRepository @Inject constructor( private val reservationTicketRetrofitService: ReservationTicketRetrofitService, ) : ReservationTicketRepository { diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/SchoolDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/SchoolDefaultRepository.kt index 7ec45167e..cc6c3d2c5 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/SchoolDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/SchoolDefaultRepository.kt @@ -1,8 +1,11 @@ package com.festago.festago.data.repository import com.festago.festago.repository.SchoolRepository +import javax.inject.Inject +import javax.inject.Singleton -class SchoolDefaultRepository() : SchoolRepository { +@Singleton +class SchoolDefaultRepository @Inject constructor() : SchoolRepository { override suspend fun loadSchoolEmail(schoolId: Long): Result { // TODO: API 연동 작업 필요 diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/StudentVerificationDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/StudentVerificationDefaultRepository.kt index df79b8793..4aab8c1c9 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/StudentVerificationDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/StudentVerificationDefaultRepository.kt @@ -3,8 +3,11 @@ package com.festago.festago.data.repository import com.festago.festago.data.service.StudentVerificationRetrofitService import com.festago.festago.model.StudentVerificationCode import com.festago.festago.repository.StudentVerificationRepository +import javax.inject.Inject +import javax.inject.Singleton -class StudentVerificationDefaultRepository( +@Singleton +class StudentVerificationDefaultRepository @Inject constructor( private val studentVerificationRetrofitService: StudentVerificationRetrofitService, ) : StudentVerificationRepository { diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/TicketDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/TicketDefaultRepository.kt index a04facbac..bdce56d5d 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/TicketDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/TicketDefaultRepository.kt @@ -7,8 +7,11 @@ import com.festago.festago.model.ReservedTicket import com.festago.festago.model.Ticket import com.festago.festago.model.TicketCode import com.festago.festago.repository.TicketRepository +import javax.inject.Inject +import javax.inject.Singleton -class TicketDefaultRepository( +@Singleton +class TicketDefaultRepository @Inject constructor( private val ticketRetrofitService: TicketRetrofitService, ) : TicketRepository { diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/TokenDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/TokenDefaultRepository.kt index 3b9c7d87c..757b9a470 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/TokenDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/TokenDefaultRepository.kt @@ -6,8 +6,11 @@ import com.festago.festago.data.service.TokenRetrofitService import com.festago.festago.data.util.runCatchingWithErrorHandler import com.festago.festago.repository.TokenRepository import kotlinx.coroutines.runBlocking +import javax.inject.Inject +import javax.inject.Singleton -class TokenDefaultRepository( +@Singleton +class TokenDefaultRepository @Inject constructor( private val tokenLocalDataSource: TokenDataSource, private val tokenRetrofitService: TokenRetrofitService, ) : TokenRepository { diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/UserDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/UserDefaultRepository.kt index 5babfa87c..5a4507380 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/UserDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/UserDefaultRepository.kt @@ -4,8 +4,11 @@ import com.festago.festago.data.service.UserRetrofitService import com.festago.festago.data.util.runCatchingWithErrorHandler import com.festago.festago.model.UserProfile import com.festago.festago.repository.UserRepository +import javax.inject.Inject +import javax.inject.Singleton -class UserDefaultRepository( +@Singleton +class UserDefaultRepository @Inject constructor( private val userProfileService: UserRetrofitService, ) : UserRepository { override suspend fun loadUserProfile(): Result { diff --git a/android/festago/app/src/main/java/com/festago/festago/data/retrofit/TokenManager.kt b/android/festago/app/src/main/java/com/festago/festago/data/retrofit/TokenManager.kt index 4cb33e5a4..f7a98b9a3 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/retrofit/TokenManager.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/retrofit/TokenManager.kt @@ -2,8 +2,11 @@ package com.festago.festago.data.retrofit import com.festago.festago.repository.TokenRepository import com.kakao.sdk.auth.TokenManagerProvider +import javax.inject.Inject +import javax.inject.Singleton -class TokenManager(private val tokenRepository: TokenRepository) { +@Singleton +class TokenManager @Inject constructor(private val tokenRepository: TokenRepository) { val token: String get() = tokenRepository.token ?: NULL_TOKEN diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/customview/OkDialogFragment.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/customview/OkDialogFragment.kt index 7d4a431d9..1b3500a8a 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/customview/OkDialogFragment.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/customview/OkDialogFragment.kt @@ -11,7 +11,9 @@ import android.view.WindowManager import androidx.fragment.app.DialogFragment import com.festago.festago.databinding.FragmentOkDialogBinding import com.festago.festago.presentation.ui.customview.OkDialogFragment.OnClickListener +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class OkDialogFragment : DialogFragment() { private var _binding: FragmentOkDialogBinding? = null diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/HomeActivity.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/HomeActivity.kt index d2df6fc11..24fcdeed0 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/HomeActivity.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/HomeActivity.kt @@ -8,18 +8,19 @@ import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import com.festago.festago.R import com.festago.festago.databinding.ActivityHomeBinding -import com.festago.festago.presentation.ui.FestagoViewModelFactory import com.festago.festago.presentation.ui.home.festivallist.FestivalListFragment import com.festago.festago.presentation.ui.home.mypage.MyPageFragment import com.festago.festago.presentation.ui.home.ticketlist.TicketListFragment import com.festago.festago.presentation.ui.signin.SignInActivity +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class HomeActivity : AppCompatActivity() { private var _binding: ActivityHomeBinding? = null private val binding get() = _binding!! - private val vm: HomeViewModel by viewModels { FestagoViewModelFactory } + private val vm: HomeViewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/HomeViewModel.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/HomeViewModel.kt index 23e25f3e4..27944a088 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/HomeViewModel.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/HomeViewModel.kt @@ -7,8 +7,11 @@ import com.festago.festago.presentation.ui.home.HomeItemType.TICKET_LIST import com.festago.festago.presentation.util.MutableSingleLiveData import com.festago.festago.presentation.util.SingleLiveData import com.festago.festago.repository.AuthRepository +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject -class HomeViewModel(private val authRepository: AuthRepository) : ViewModel() { +@HiltViewModel +class HomeViewModel @Inject constructor(private val authRepository: AuthRepository) : ViewModel() { private val _event = MutableSingleLiveData() val event: SingleLiveData = _event diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListFragment.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListFragment.kt index a69fb51c5..f07c2a518 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListFragment.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListFragment.kt @@ -8,16 +8,17 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import com.festago.festago.R import com.festago.festago.databinding.FragmentFestivalListBinding -import com.festago.festago.presentation.ui.FestagoViewModelFactory import com.festago.festago.presentation.ui.home.ticketlist.TicketListFragment import com.festago.festago.presentation.ui.ticketreserve.TicketReserveActivity +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class FestivalListFragment : Fragment(R.layout.fragment_festival_list) { private var _binding: FragmentFestivalListBinding? = null private val binding get() = _binding!! - private val vm: FestivalListViewModel by viewModels { FestagoViewModelFactory } + private val vm: FestivalListViewModel by viewModels() private lateinit var adapter: FestivalListAdapter override fun onCreateView( diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListViewModel.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListViewModel.kt index 08da64fdb..ed586fc36 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListViewModel.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListViewModel.kt @@ -10,9 +10,12 @@ import com.festago.festago.presentation.ui.home.festivallist.FestivalListEvent.S import com.festago.festago.presentation.util.MutableSingleLiveData import com.festago.festago.presentation.util.SingleLiveData import com.festago.festago.repository.FestivalRepository +import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch +import javax.inject.Inject -class FestivalListViewModel( +@HiltViewModel +class FestivalListViewModel @Inject constructor( private val festivalRepository: FestivalRepository, private val analyticsHelper: AnalyticsHelper, ) : ViewModel() { diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/mypage/MyPageFragment.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/mypage/MyPageFragment.kt index 6c8c95fff..478d0fdd1 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/mypage/MyPageFragment.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/mypage/MyPageFragment.kt @@ -9,18 +9,19 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import com.festago.festago.R import com.festago.festago.databinding.FragmentMyPageBinding -import com.festago.festago.presentation.ui.FestagoViewModelFactory import com.festago.festago.presentation.ui.home.HomeActivity import com.festago.festago.presentation.ui.signin.SignInActivity import com.festago.festago.presentation.ui.studentverification.StudentVerificationActivity import com.festago.festago.presentation.ui.tickethistory.TicketHistoryActivity +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class MyPageFragment : Fragment(R.layout.fragment_my_page) { private var _binding: FragmentMyPageBinding? = null private val binding get() = _binding!! - private val vm: MyPageViewModel by viewModels { FestagoViewModelFactory } + private val vm: MyPageViewModel by viewModels() override fun onCreateView( inflater: LayoutInflater, diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/mypage/MyPageViewModel.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/mypage/MyPageViewModel.kt index 6c254b915..27ea3319e 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/mypage/MyPageViewModel.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/mypage/MyPageViewModel.kt @@ -11,10 +11,13 @@ import com.festago.festago.presentation.util.SingleLiveData import com.festago.festago.repository.AuthRepository import com.festago.festago.repository.TicketRepository import com.festago.festago.repository.UserRepository +import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.async import kotlinx.coroutines.launch +import javax.inject.Inject -class MyPageViewModel( +@HiltViewModel +class MyPageViewModel @Inject constructor( private val userRepository: UserRepository, private val ticketRepository: TicketRepository, private val authRepository: AuthRepository, diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/ticketlist/TicketListFragment.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/ticketlist/TicketListFragment.kt index 76bf53220..7918bc185 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/ticketlist/TicketListFragment.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/ticketlist/TicketListFragment.kt @@ -11,9 +11,10 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels import com.festago.festago.R import com.festago.festago.databinding.FragmentTicketListBinding -import com.festago.festago.presentation.ui.FestagoViewModelFactory import com.festago.festago.presentation.ui.ticketentry.TicketEntryActivity +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class TicketListFragment : Fragment(R.layout.fragment_ticket_list) { private var _binding: FragmentTicketListBinding? = null @@ -23,7 +24,7 @@ class TicketListFragment : Fragment(R.layout.fragment_ticket_list) { private lateinit var resultLauncher: ActivityResultLauncher - private val vm: TicketListViewModel by viewModels { FestagoViewModelFactory } + private val vm: TicketListViewModel by viewModels() override fun onCreateView( inflater: LayoutInflater, diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/ticketlist/TicketListViewModel.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/ticketlist/TicketListViewModel.kt index c777d84be..e6e8b27ea 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/ticketlist/TicketListViewModel.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/home/ticketlist/TicketListViewModel.kt @@ -9,9 +9,12 @@ import com.festago.festago.analytics.logNetworkFailure import com.festago.festago.presentation.util.MutableSingleLiveData import com.festago.festago.presentation.util.SingleLiveData import com.festago.festago.repository.TicketRepository +import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch +import javax.inject.Inject -class TicketListViewModel( +@HiltViewModel +class TicketListViewModel @Inject constructor( private val ticketRepository: TicketRepository, private val analyticsHelper: AnalyticsHelper, ) : ViewModel() { diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/reservationcomplete/ReservationCompleteActivity.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/reservationcomplete/ReservationCompleteActivity.kt index 237a87b5f..145bbb44d 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/reservationcomplete/ReservationCompleteActivity.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/reservationcomplete/ReservationCompleteActivity.kt @@ -6,7 +6,9 @@ import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import com.festago.festago.databinding.ActivityReservationCompleteBinding import com.festago.festago.presentation.util.getParcelableExtraCompat +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class ReservationCompleteActivity : AppCompatActivity() { private lateinit var binding: ActivityReservationCompleteBinding diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/signin/SignInActivity.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/signin/SignInActivity.kt index 974494da1..81e9d037c 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/signin/SignInActivity.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/signin/SignInActivity.kt @@ -11,18 +11,19 @@ import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.lifecycleScope import com.festago.festago.R import com.festago.festago.databinding.ActivitySignInBinding -import com.festago.festago.presentation.ui.FestagoViewModelFactory import com.festago.festago.presentation.ui.customview.OkDialogFragment import com.festago.festago.presentation.ui.home.HomeActivity import com.festago.festago.presentation.util.loginWithKakao import com.kakao.sdk.user.UserApiClient +import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch +@AndroidEntryPoint class SignInActivity : AppCompatActivity() { private lateinit var binding: ActivitySignInBinding - private val vm: SignInViewModel by viewModels { FestagoViewModelFactory } + private val vm: SignInViewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/signin/SignInViewModel.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/signin/SignInViewModel.kt index ce770e3d4..1a1ff5e7a 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/signin/SignInViewModel.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/signin/SignInViewModel.kt @@ -7,9 +7,12 @@ import com.festago.festago.analytics.logNetworkFailure import com.festago.festago.presentation.util.MutableSingleLiveData import com.festago.festago.presentation.util.SingleLiveData import com.festago.festago.repository.AuthRepository +import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch +import javax.inject.Inject -class SignInViewModel( +@HiltViewModel +class SignInViewModel @Inject constructor( private val authRepository: AuthRepository, private val analyticsHelper: AnalyticsHelper, ) : ViewModel() { diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/studentverification/StudentVerificationActivity.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/studentverification/StudentVerificationActivity.kt index ee22e982d..7f4fa86f6 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/studentverification/StudentVerificationActivity.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/studentverification/StudentVerificationActivity.kt @@ -7,18 +7,19 @@ import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import com.festago.festago.R import com.festago.festago.databinding.ActivityStudentVerificationBinding -import com.festago.festago.presentation.ui.FestagoViewModelFactory import com.festago.festago.presentation.util.repeatOnStarted +import dagger.hilt.android.AndroidEntryPoint import java.time.LocalTime import java.time.format.DateTimeFormatter +@AndroidEntryPoint class StudentVerificationActivity : AppCompatActivity() { private val binding: ActivityStudentVerificationBinding by lazy { ActivityStudentVerificationBinding.inflate(layoutInflater) } - private val vm: StudentVerificationViewModel by viewModels { FestagoViewModelFactory } + private val vm: StudentVerificationViewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/studentverification/StudentVerificationViewModel.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/studentverification/StudentVerificationViewModel.kt index 8df23b16e..e490ab2e8 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/studentverification/StudentVerificationViewModel.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/studentverification/StudentVerificationViewModel.kt @@ -9,6 +9,7 @@ import com.festago.festago.model.timer.Timer import com.festago.festago.model.timer.TimerListener import com.festago.festago.repository.SchoolRepository import com.festago.festago.repository.StudentVerificationRepository +import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharedFlow @@ -16,8 +17,10 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch +import javax.inject.Inject -class StudentVerificationViewModel( +@HiltViewModel +class StudentVerificationViewModel @Inject constructor( private val schoolRepository: SchoolRepository, private val studentVerificationRepository: StudentVerificationRepository, private val analyticsHelper: AnalyticsHelper, diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryActivity.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryActivity.kt index ec654e3d0..5458d2185 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryActivity.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryActivity.kt @@ -8,15 +8,16 @@ import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import androidx.core.content.res.ResourcesCompat import com.festago.festago.databinding.ActivityTicketEntryBinding -import com.festago.festago.presentation.ui.FestagoViewModelFactory import com.google.zxing.BarcodeFormat import com.journeyapps.barcodescanner.BarcodeEncoder +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class TicketEntryActivity : AppCompatActivity() { private lateinit var binding: ActivityTicketEntryBinding - private val vm: TicketEntryViewModel by viewModels { FestagoViewModelFactory } + private val vm: TicketEntryViewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryViewModel.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryViewModel.kt index 8c797aa4d..9377ba926 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryViewModel.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryViewModel.kt @@ -10,9 +10,12 @@ import com.festago.festago.model.TicketCode import com.festago.festago.model.timer.Timer import com.festago.festago.model.timer.TimerListener import com.festago.festago.repository.TicketRepository +import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch +import javax.inject.Inject -class TicketEntryViewModel( +@HiltViewModel +class TicketEntryViewModel @Inject constructor( private val ticketRepository: TicketRepository, private val analyticsHelper: AnalyticsHelper, ) : ViewModel() { diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/tickethistory/TicketHistoryActivity.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/tickethistory/TicketHistoryActivity.kt index ed95ff13a..bc60b476b 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/tickethistory/TicketHistoryActivity.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/tickethistory/TicketHistoryActivity.kt @@ -6,12 +6,13 @@ import android.os.Bundle import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import com.festago.festago.databinding.ActivityTicketHistoryBinding -import com.festago.festago.presentation.ui.FestagoViewModelFactory +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class TicketHistoryActivity : AppCompatActivity() { private lateinit var binding: ActivityTicketHistoryBinding - private val vm: TicketHistoryViewModel by viewModels { FestagoViewModelFactory } + private val vm: TicketHistoryViewModel by viewModels() private var adapter: TicketHistoryAdapter = TicketHistoryAdapter() diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/tickethistory/TicketHistoryViewModel.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/tickethistory/TicketHistoryViewModel.kt index 868440399..9a5e7a077 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/tickethistory/TicketHistoryViewModel.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/tickethistory/TicketHistoryViewModel.kt @@ -7,9 +7,12 @@ import androidx.lifecycle.viewModelScope import com.festago.festago.analytics.AnalyticsHelper import com.festago.festago.analytics.logNetworkFailure import com.festago.festago.repository.TicketRepository +import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch +import javax.inject.Inject -class TicketHistoryViewModel( +@HiltViewModel +class TicketHistoryViewModel @Inject constructor( private val ticketRepository: TicketRepository, private val analyticsHelper: AnalyticsHelper, ) : ViewModel() { diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/TicketReserveActivity.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/TicketReserveActivity.kt index a7f4b46cf..790cd9abe 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/TicketReserveActivity.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/TicketReserveActivity.kt @@ -10,7 +10,6 @@ import com.festago.festago.R import com.festago.festago.databinding.ActivityTicketReserveBinding import com.festago.festago.model.ReservationTicket import com.festago.festago.model.ReservedTicket -import com.festago.festago.presentation.ui.FestagoViewModelFactory import com.festago.festago.presentation.ui.customview.OkDialogFragment import com.festago.festago.presentation.ui.reservationcomplete.ReservationCompleteActivity import com.festago.festago.presentation.ui.reservationcomplete.ReservedTicketArg @@ -23,14 +22,16 @@ import com.festago.festago.presentation.ui.ticketreserve.adapter.TicketReserveAd import com.festago.festago.presentation.ui.ticketreserve.adapter.TicketReserveHeaderAdapter import com.festago.festago.presentation.ui.ticketreserve.bottomsheet.BottomSheetReservationTicketArg import com.festago.festago.presentation.ui.ticketreserve.bottomsheet.TicketReserveBottomSheetFragment +import dagger.hilt.android.AndroidEntryPoint import java.time.LocalDateTime import java.time.format.DateTimeFormatter import java.util.Locale +@AndroidEntryPoint class TicketReserveActivity : AppCompatActivity() { private lateinit var binding: ActivityTicketReserveBinding - private val vm: TicketReserveViewModel by viewModels { FestagoViewModelFactory } + private val vm: TicketReserveViewModel by viewModels() private val contentsAdapter by lazy { TicketReserveAdapter() } private val headerAdapter by lazy { TicketReserveHeaderAdapter() } diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/TicketReserveViewModel.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/TicketReserveViewModel.kt index 0a22913d7..e295c6dc7 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/TicketReserveViewModel.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/TicketReserveViewModel.kt @@ -13,10 +13,13 @@ import com.festago.festago.repository.AuthRepository import com.festago.festago.repository.FestivalRepository import com.festago.festago.repository.ReservationTicketRepository import com.festago.festago.repository.TicketRepository +import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch import java.time.LocalDateTime +import javax.inject.Inject -class TicketReserveViewModel( +@HiltViewModel +class TicketReserveViewModel @Inject constructor( private val reservationTicketRepository: ReservationTicketRepository, private val festivalRepository: FestivalRepository, private val ticketRepository: TicketRepository, diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/bottomsheet/TicketReserveBottomSheetFragment.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/bottomsheet/TicketReserveBottomSheetFragment.kt index fab58b27c..d665e2b94 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/bottomsheet/TicketReserveBottomSheetFragment.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/bottomsheet/TicketReserveBottomSheetFragment.kt @@ -9,7 +9,9 @@ import com.festago.festago.databinding.FragmentTicketReserveBottomSheetBinding import com.festago.festago.presentation.ui.ticketreserve.TicketReserveViewModel import com.festago.festago.presentation.util.getParcelableArrayListCompat import com.google.android.material.bottomsheet.BottomSheetDialogFragment +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class TicketReserveBottomSheetFragment : BottomSheetDialogFragment() { private var _binding: FragmentTicketReserveBottomSheetBinding? = null From 2be9fcb11c1d112ae0eb20498d50fc4fe75c5006 Mon Sep 17 00:00:00 2001 From: EmilyCh0 Date: Tue, 19 Sep 2023 17:03:30 +0900 Subject: [PATCH 4/9] =?UTF-8?q?refactor:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=88=98=EB=8F=99=20di=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: SeongHoonC --- .../festago/festago/di/AnalysisContainer.kt | 8 -- .../festago/di/AuthServiceContainer.kt | 37 --------- .../festago/di/LocalDataSourceContainer.kt | 9 --- .../festago/di/NormalServiceContainer.kt | 28 ------- .../festago/festago/di/RepositoryContainer.kt | 55 -------------- .../com/festago/festago/di/TokenContainer.kt | 15 ---- .../presentation/ui/ViewModelFactory.kt | 76 ------------------- 7 files changed, 228 deletions(-) delete mode 100644 android/festago/app/src/main/java/com/festago/festago/di/AnalysisContainer.kt delete mode 100644 android/festago/app/src/main/java/com/festago/festago/di/AuthServiceContainer.kt delete mode 100644 android/festago/app/src/main/java/com/festago/festago/di/LocalDataSourceContainer.kt delete mode 100644 android/festago/app/src/main/java/com/festago/festago/di/NormalServiceContainer.kt delete mode 100644 android/festago/app/src/main/java/com/festago/festago/di/RepositoryContainer.kt delete mode 100644 android/festago/app/src/main/java/com/festago/festago/di/TokenContainer.kt delete mode 100644 android/festago/app/src/main/java/com/festago/festago/presentation/ui/ViewModelFactory.kt diff --git a/android/festago/app/src/main/java/com/festago/festago/di/AnalysisContainer.kt b/android/festago/app/src/main/java/com/festago/festago/di/AnalysisContainer.kt deleted file mode 100644 index ad63cda83..000000000 --- a/android/festago/app/src/main/java/com/festago/festago/di/AnalysisContainer.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.festago.festago.di - -import com.festago.festago.analytics.AnalyticsHelper -import com.festago.festago.analytics.FirebaseAnalyticsHelper - -class AnalysisContainer { - val analyticsHelper: AnalyticsHelper = FirebaseAnalyticsHelper -} diff --git a/android/festago/app/src/main/java/com/festago/festago/di/AuthServiceContainer.kt b/android/festago/app/src/main/java/com/festago/festago/di/AuthServiceContainer.kt deleted file mode 100644 index 496232581..000000000 --- a/android/festago/app/src/main/java/com/festago/festago/di/AuthServiceContainer.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.festago.festago.di - -import com.festago.festago.data.retrofit.AuthInterceptor -import com.festago.festago.data.service.StudentVerificationRetrofitService -import com.festago.festago.data.service.TicketRetrofitService -import com.festago.festago.data.service.UserRetrofitService -import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory -import kotlinx.serialization.json.Json -import okhttp3.MediaType.Companion.toMediaType -import okhttp3.OkHttpClient -import retrofit2.Retrofit - -class AuthServiceContainer(baseUrl: String, tokenContainer: TokenContainer) { - - private val okHttpClient: OkHttpClient = OkHttpClient - .Builder() - .addInterceptor(AuthInterceptor(tokenContainer.tokenManager)) - .build() - - private val authRetrofit: Retrofit = Retrofit.Builder() - .baseUrl(baseUrl) - .client(okHttpClient) - .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) - .build() - - val ticketRetrofitService: TicketRetrofitService by lazy { - authRetrofit.create(TicketRetrofitService::class.java) - } - - val userRetrofitService: UserRetrofitService by lazy { - authRetrofit.create(UserRetrofitService::class.java) - } - - val studentVerificationRetrofitService: StudentVerificationRetrofitService by lazy { - authRetrofit.create(StudentVerificationRetrofitService::class.java) - } -} diff --git a/android/festago/app/src/main/java/com/festago/festago/di/LocalDataSourceContainer.kt b/android/festago/app/src/main/java/com/festago/festago/di/LocalDataSourceContainer.kt deleted file mode 100644 index a1b9aa242..000000000 --- a/android/festago/app/src/main/java/com/festago/festago/di/LocalDataSourceContainer.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.festago.festago.di - -import android.content.Context -import com.festago.festago.data.datasource.TokenDataSource -import com.festago.festago.data.datasource.TokenLocalDataSource - -class LocalDataSourceContainer(context: Context) { - val tokenDataSource: TokenDataSource = TokenLocalDataSource(context) -} diff --git a/android/festago/app/src/main/java/com/festago/festago/di/NormalServiceContainer.kt b/android/festago/app/src/main/java/com/festago/festago/di/NormalServiceContainer.kt deleted file mode 100644 index 509fd36f0..000000000 --- a/android/festago/app/src/main/java/com/festago/festago/di/NormalServiceContainer.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.festago.festago.di - -import com.festago.festago.data.service.FestivalRetrofitService -import com.festago.festago.data.service.ReservationTicketRetrofitService -import com.festago.festago.data.service.TokenRetrofitService -import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory -import kotlinx.serialization.json.Json -import okhttp3.MediaType.Companion.toMediaType -import retrofit2.Retrofit - -class NormalServiceContainer(baseUrl: String) { - private val normalRetrofit: Retrofit = Retrofit.Builder() - .baseUrl(baseUrl) - .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) - .build() - - val festivalRetrofitService: FestivalRetrofitService by lazy { - normalRetrofit.create(FestivalRetrofitService::class.java) - } - - val tokenRetrofitService: TokenRetrofitService by lazy { - normalRetrofit.create(TokenRetrofitService::class.java) - } - - val reservationTicketRetrofitService: ReservationTicketRetrofitService by lazy { - normalRetrofit.create(ReservationTicketRetrofitService::class.java) - } -} diff --git a/android/festago/app/src/main/java/com/festago/festago/di/RepositoryContainer.kt b/android/festago/app/src/main/java/com/festago/festago/di/RepositoryContainer.kt deleted file mode 100644 index 3b655a30f..000000000 --- a/android/festago/app/src/main/java/com/festago/festago/di/RepositoryContainer.kt +++ /dev/null @@ -1,55 +0,0 @@ -package com.festago.festago.di - -import com.festago.festago.data.repository.AuthDefaultRepository -import com.festago.festago.data.repository.FestivalDefaultRepository -import com.festago.festago.data.repository.ReservationTicketDefaultRepository -import com.festago.festago.data.repository.SchoolDefaultRepository -import com.festago.festago.data.repository.StudentVerificationDefaultRepository -import com.festago.festago.data.repository.TicketDefaultRepository -import com.festago.festago.data.repository.UserDefaultRepository -import com.festago.festago.repository.AuthRepository -import com.festago.festago.repository.FestivalRepository -import com.festago.festago.repository.ReservationTicketRepository -import com.festago.festago.repository.SchoolRepository -import com.festago.festago.repository.StudentVerificationRepository -import com.festago.festago.repository.TicketRepository -import com.festago.festago.repository.UserRepository - -class RepositoryContainer( - private val authServiceContainer: AuthServiceContainer, - private val normalServiceContainer: NormalServiceContainer, - tokenContainer: TokenContainer, -) { - val authRepository: AuthRepository = AuthDefaultRepository( - tokenRepository = tokenContainer.tokenRepository, - userRetrofitService = authServiceContainer.userRetrofitService, - ) - - val festivalRepository: FestivalRepository - get() = FestivalDefaultRepository( - festivalRetrofitService = normalServiceContainer.festivalRetrofitService, - ) - - val ticketRepository: TicketRepository - get() = TicketDefaultRepository( - ticketRetrofitService = authServiceContainer.ticketRetrofitService, - ) - - val userRepository: UserRepository - get() = UserDefaultRepository( - userProfileService = authServiceContainer.userRetrofitService, - ) - - val reservationTicketRepository: ReservationTicketRepository - get() = ReservationTicketDefaultRepository( - reservationTicketRetrofitService = normalServiceContainer.reservationTicketRetrofitService, - ) - - val studentVerificationRepository: StudentVerificationRepository - get() = StudentVerificationDefaultRepository( - studentVerificationRetrofitService = authServiceContainer.studentVerificationRetrofitService, - ) - - val schoolRepository: SchoolRepository - get() = SchoolDefaultRepository() -} diff --git a/android/festago/app/src/main/java/com/festago/festago/di/TokenContainer.kt b/android/festago/app/src/main/java/com/festago/festago/di/TokenContainer.kt deleted file mode 100644 index d17a15af9..000000000 --- a/android/festago/app/src/main/java/com/festago/festago/di/TokenContainer.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.festago.festago.di - -import com.festago.festago.data.repository.TokenDefaultRepository -import com.festago.festago.data.retrofit.TokenManager - -class TokenContainer( - normalServiceContainer: NormalServiceContainer, - localDataSourceContainer: LocalDataSourceContainer, -) { - val tokenRepository = TokenDefaultRepository( - tokenRetrofitService = normalServiceContainer.tokenRetrofitService, - tokenLocalDataSource = localDataSourceContainer.tokenDataSource, - ) - val tokenManager = TokenManager(tokenRepository) -} diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ViewModelFactory.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ViewModelFactory.kt deleted file mode 100644 index 3b541c35f..000000000 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ViewModelFactory.kt +++ /dev/null @@ -1,76 +0,0 @@ -package com.festago.festago.presentation.ui - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProvider -import com.festago.festago.FestagoApplication -import com.festago.festago.presentation.ui.home.HomeViewModel -import com.festago.festago.presentation.ui.home.festivallist.FestivalListViewModel -import com.festago.festago.presentation.ui.home.mypage.MyPageViewModel -import com.festago.festago.presentation.ui.home.ticketlist.TicketListViewModel -import com.festago.festago.presentation.ui.signin.SignInViewModel -import com.festago.festago.presentation.ui.studentverification.StudentVerificationViewModel -import com.festago.festago.presentation.ui.ticketentry.TicketEntryViewModel -import com.festago.festago.presentation.ui.tickethistory.TicketHistoryViewModel -import com.festago.festago.presentation.ui.ticketreserve.TicketReserveViewModel - -@Suppress("UNCHECKED_CAST") -val FestagoViewModelFactory: ViewModelProvider.Factory = object : ViewModelProvider.Factory { - val repositoryContainer = FestagoApplication.repositoryContainer - val analysisContainer = FestagoApplication.analysisContainer - - override fun create(modelClass: Class): T { - return when { - modelClass.isAssignableFrom(TicketHistoryViewModel::class.java) -> TicketHistoryViewModel( - ticketRepository = repositoryContainer.ticketRepository, - analyticsHelper = analysisContainer.analyticsHelper, - ) - - modelClass.isAssignableFrom(TicketReserveViewModel::class.java) -> TicketReserveViewModel( - reservationTicketRepository = repositoryContainer.reservationTicketRepository, - festivalRepository = repositoryContainer.festivalRepository, - ticketRepository = repositoryContainer.ticketRepository, - authRepository = repositoryContainer.authRepository, - analyticsHelper = analysisContainer.analyticsHelper, - ) - - modelClass.isAssignableFrom(TicketEntryViewModel::class.java) -> TicketEntryViewModel( - ticketRepository = repositoryContainer.ticketRepository, - analyticsHelper = analysisContainer.analyticsHelper, - ) - - modelClass.isAssignableFrom(SignInViewModel::class.java) -> SignInViewModel( - authRepository = repositoryContainer.authRepository, - analyticsHelper = analysisContainer.analyticsHelper, - ) - - modelClass.isAssignableFrom(HomeViewModel::class.java) -> HomeViewModel( - authRepository = repositoryContainer.authRepository, - ) - - modelClass.isAssignableFrom(FestivalListViewModel::class.java) -> FestivalListViewModel( - festivalRepository = repositoryContainer.festivalRepository, - analyticsHelper = analysisContainer.analyticsHelper, - ) - - modelClass.isAssignableFrom(MyPageViewModel::class.java) -> MyPageViewModel( - userRepository = repositoryContainer.userRepository, - ticketRepository = repositoryContainer.ticketRepository, - authRepository = repositoryContainer.authRepository, - analyticsHelper = analysisContainer.analyticsHelper, - ) - - modelClass.isAssignableFrom(TicketListViewModel::class.java) -> TicketListViewModel( - ticketRepository = repositoryContainer.ticketRepository, - analyticsHelper = analysisContainer.analyticsHelper, - ) - - modelClass.isAssignableFrom(StudentVerificationViewModel::class.java) -> StudentVerificationViewModel( - schoolRepository = repositoryContainer.schoolRepository, - studentVerificationRepository = repositoryContainer.studentVerificationRepository, - analyticsHelper = analysisContainer.analyticsHelper, - ) - - else -> throw IllegalArgumentException("ViewModelFactory에 정의되지않은 뷰모델을 생성하였습니다 : ${modelClass.name}") - } as T - } -} From 3cca61488098b835467f6b80c2e1c5fb9b5c3140 Mon Sep 17 00:00:00 2001 From: EmilyCh0 Date: Tue, 19 Sep 2023 17:27:27 +0900 Subject: [PATCH 5/9] chore: ktlintcheck Co-authored-by: SeongHoonC --- .../app/src/main/java/com/festago/festago/data/di/ApiModule.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/ApiModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/ApiModule.kt index f5407a101..24fb92032 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/di/ApiModule.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/ApiModule.kt @@ -23,7 +23,6 @@ annotation class NormalRetrofitQualifier @Retention(AnnotationRetention.BINARY) annotation class AuthRetrofitQualifier - @InstallIn(SingletonComponent::class) @Module object ApiModule { From 8bd56d92e937feb43d92c3110a0d76a30cb5b2d6 Mon Sep 17 00:00:00 2001 From: EmilyCh0 Date: Wed, 20 Sep 2023 15:10:12 +0900 Subject: [PATCH 6/9] =?UTF-8?q?refactor:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/festago/festago/analytics/FirebaseAnalyticsHelper.kt | 2 -- .../com/festago/festago/data/datasource/TokenLocalDataSource.kt | 2 -- .../festago/festago/data/repository/AuthDefaultRepository.kt | 2 -- .../festago/data/repository/FestivalDefaultRepository.kt | 2 -- .../data/repository/ReservationTicketDefaultRepository.kt | 2 -- .../festago/festago/data/repository/SchoolDefaultRepository.kt | 2 -- .../data/repository/StudentVerificationDefaultRepository.kt | 2 -- .../festago/festago/data/repository/TicketDefaultRepository.kt | 2 -- .../festago/festago/data/repository/TokenDefaultRepository.kt | 2 -- .../festago/festago/data/repository/UserDefaultRepository.kt | 2 -- .../main/java/com/festago/festago/data/retrofit/TokenManager.kt | 2 -- 11 files changed, 22 deletions(-) diff --git a/android/festago/app/src/main/java/com/festago/festago/analytics/FirebaseAnalyticsHelper.kt b/android/festago/app/src/main/java/com/festago/festago/analytics/FirebaseAnalyticsHelper.kt index 6c5faea32..393795bf6 100644 --- a/android/festago/app/src/main/java/com/festago/festago/analytics/FirebaseAnalyticsHelper.kt +++ b/android/festago/app/src/main/java/com/festago/festago/analytics/FirebaseAnalyticsHelper.kt @@ -5,9 +5,7 @@ import android.os.Bundle import com.google.firebase.analytics.FirebaseAnalytics import dagger.hilt.android.qualifiers.ApplicationContext import javax.inject.Inject -import javax.inject.Singleton -@Singleton class FirebaseAnalyticsHelper @Inject constructor( @ApplicationContext context: Context ) : AnalyticsHelper { diff --git a/android/festago/app/src/main/java/com/festago/festago/data/datasource/TokenLocalDataSource.kt b/android/festago/app/src/main/java/com/festago/festago/data/datasource/TokenLocalDataSource.kt index c0515b236..fb76e1361 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/datasource/TokenLocalDataSource.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/datasource/TokenLocalDataSource.kt @@ -6,9 +6,7 @@ import androidx.security.crypto.EncryptedSharedPreferences import androidx.security.crypto.MasterKey import dagger.hilt.android.qualifiers.ApplicationContext import javax.inject.Inject -import javax.inject.Singleton -@Singleton class TokenLocalDataSource @Inject constructor( @ApplicationContext context: Context ) : TokenDataSource { diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/AuthDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/AuthDefaultRepository.kt index 303b72107..1a793f5c0 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/AuthDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/AuthDefaultRepository.kt @@ -6,9 +6,7 @@ import com.festago.festago.repository.AuthRepository import com.festago.festago.repository.TokenRepository import com.kakao.sdk.user.UserApiClient import javax.inject.Inject -import javax.inject.Singleton -@Singleton class AuthDefaultRepository @Inject constructor( private val userRetrofitService: UserRetrofitService, private val tokenRepository: TokenRepository, diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/FestivalDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/FestivalDefaultRepository.kt index f124ac853..935064243 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/FestivalDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/FestivalDefaultRepository.kt @@ -6,9 +6,7 @@ import com.festago.festago.model.Festival import com.festago.festago.model.Reservation import com.festago.festago.repository.FestivalRepository import javax.inject.Inject -import javax.inject.Singleton -@Singleton class FestivalDefaultRepository @Inject constructor( private val festivalRetrofitService: FestivalRetrofitService, ) : FestivalRepository { diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/ReservationTicketDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/ReservationTicketDefaultRepository.kt index c3f60e22b..dd9a57656 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/ReservationTicketDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/ReservationTicketDefaultRepository.kt @@ -5,9 +5,7 @@ import com.festago.festago.data.util.runCatchingWithErrorHandler import com.festago.festago.model.ReservationTicket import com.festago.festago.repository.ReservationTicketRepository import javax.inject.Inject -import javax.inject.Singleton -@Singleton class ReservationTicketDefaultRepository @Inject constructor( private val reservationTicketRetrofitService: ReservationTicketRetrofitService, ) : ReservationTicketRepository { diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/SchoolDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/SchoolDefaultRepository.kt index cc6c3d2c5..86d2ac26b 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/SchoolDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/SchoolDefaultRepository.kt @@ -2,9 +2,7 @@ package com.festago.festago.data.repository import com.festago.festago.repository.SchoolRepository import javax.inject.Inject -import javax.inject.Singleton -@Singleton class SchoolDefaultRepository @Inject constructor() : SchoolRepository { override suspend fun loadSchoolEmail(schoolId: Long): Result { diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/StudentVerificationDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/StudentVerificationDefaultRepository.kt index 4aab8c1c9..a12b551e2 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/StudentVerificationDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/StudentVerificationDefaultRepository.kt @@ -4,9 +4,7 @@ import com.festago.festago.data.service.StudentVerificationRetrofitService import com.festago.festago.model.StudentVerificationCode import com.festago.festago.repository.StudentVerificationRepository import javax.inject.Inject -import javax.inject.Singleton -@Singleton class StudentVerificationDefaultRepository @Inject constructor( private val studentVerificationRetrofitService: StudentVerificationRetrofitService, ) : StudentVerificationRepository { diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/TicketDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/TicketDefaultRepository.kt index bdce56d5d..12a43636c 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/TicketDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/TicketDefaultRepository.kt @@ -8,9 +8,7 @@ import com.festago.festago.model.Ticket import com.festago.festago.model.TicketCode import com.festago.festago.repository.TicketRepository import javax.inject.Inject -import javax.inject.Singleton -@Singleton class TicketDefaultRepository @Inject constructor( private val ticketRetrofitService: TicketRetrofitService, ) : TicketRepository { diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/TokenDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/TokenDefaultRepository.kt index 757b9a470..1f3d083b5 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/TokenDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/TokenDefaultRepository.kt @@ -7,9 +7,7 @@ import com.festago.festago.data.util.runCatchingWithErrorHandler import com.festago.festago.repository.TokenRepository import kotlinx.coroutines.runBlocking import javax.inject.Inject -import javax.inject.Singleton -@Singleton class TokenDefaultRepository @Inject constructor( private val tokenLocalDataSource: TokenDataSource, private val tokenRetrofitService: TokenRetrofitService, diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/UserDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/UserDefaultRepository.kt index 5a4507380..692d5dd18 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/UserDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/UserDefaultRepository.kt @@ -5,9 +5,7 @@ import com.festago.festago.data.util.runCatchingWithErrorHandler import com.festago.festago.model.UserProfile import com.festago.festago.repository.UserRepository import javax.inject.Inject -import javax.inject.Singleton -@Singleton class UserDefaultRepository @Inject constructor( private val userProfileService: UserRetrofitService, ) : UserRepository { diff --git a/android/festago/app/src/main/java/com/festago/festago/data/retrofit/TokenManager.kt b/android/festago/app/src/main/java/com/festago/festago/data/retrofit/TokenManager.kt index f7a98b9a3..5832c8c38 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/retrofit/TokenManager.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/retrofit/TokenManager.kt @@ -3,9 +3,7 @@ package com.festago.festago.data.retrofit import com.festago.festago.repository.TokenRepository import com.kakao.sdk.auth.TokenManagerProvider import javax.inject.Inject -import javax.inject.Singleton -@Singleton class TokenManager @Inject constructor(private val tokenRepository: TokenRepository) { val token: String From 9b8a2613d8f897ff6e221b9b81b3f98e43815fcd Mon Sep 17 00:00:00 2001 From: EmilyCh0 Date: Wed, 20 Sep 2023 15:10:46 +0900 Subject: [PATCH 7/9] =?UTF-8?q?refactor:=20=EB=B7=B0=EB=AA=A8=EB=8D=B8=20?= =?UTF-8?q?=EC=8A=A4=EC=BD=94=ED=94=84=20=EB=AA=A8=EB=93=88=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Module.kt => SingletonRepositoryModule.kt} | 29 ++++-------------- .../festago/data/di/ViewModelScopeModule.kt | 30 +++++++++++++++++++ 2 files changed, 35 insertions(+), 24 deletions(-) rename android/festago/app/src/main/java/com/festago/festago/data/di/{RepositoryModule.kt => SingletonRepositoryModule.kt} (60%) create mode 100644 android/festago/app/src/main/java/com/festago/festago/data/di/ViewModelScopeModule.kt diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/RepositoryModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/SingletonRepositoryModule.kt similarity index 60% rename from android/festago/app/src/main/java/com/festago/festago/data/di/RepositoryModule.kt rename to android/festago/app/src/main/java/com/festago/festago/data/di/SingletonRepositoryModule.kt index f28132fb2..55a77df66 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/di/RepositoryModule.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/SingletonRepositoryModule.kt @@ -2,20 +2,14 @@ package com.festago.festago.data.di import com.festago.festago.data.repository.AuthDefaultRepository import com.festago.festago.data.repository.FestivalDefaultRepository -import com.festago.festago.data.repository.ReservationTicketDefaultRepository import com.festago.festago.data.repository.SchoolDefaultRepository -import com.festago.festago.data.repository.StudentVerificationDefaultRepository import com.festago.festago.data.repository.TicketDefaultRepository import com.festago.festago.data.repository.TokenDefaultRepository -import com.festago.festago.data.repository.UserDefaultRepository import com.festago.festago.repository.AuthRepository import com.festago.festago.repository.FestivalRepository -import com.festago.festago.repository.ReservationTicketRepository import com.festago.festago.repository.SchoolRepository -import com.festago.festago.repository.StudentVerificationRepository import com.festago.festago.repository.TicketRepository import com.festago.festago.repository.TokenRepository -import com.festago.festago.repository.UserRepository import dagger.Binds import dagger.Module import dagger.hilt.InstallIn @@ -24,36 +18,23 @@ import javax.inject.Singleton @InstallIn(SingletonComponent::class) @Module -interface RepositoryModule { - @Binds - @Singleton - fun bindsAuthDefaultRepository(authRepository: AuthDefaultRepository): AuthRepository +interface SingletonRepositoryModule { @Binds - @Singleton - fun bindsFestivalDefaultRepository(festivalRepository: FestivalDefaultRepository): FestivalRepository + fun bindsTokenDefaultRepository(tokenRepository: TokenDefaultRepository): TokenRepository @Binds - @Singleton - fun bindsReservationTicketDefaultRepository(reservationTicketRepository: ReservationTicketDefaultRepository): ReservationTicketRepository + fun bindsAuthDefaultRepository(authRepository: AuthDefaultRepository): AuthRepository @Binds @Singleton - fun bindsSchoolDefaultRepository(schoolRepository: SchoolDefaultRepository): SchoolRepository + fun bindsFestivalDefaultRepository(festivalRepository: FestivalDefaultRepository): FestivalRepository @Binds @Singleton - fun bindsStudentVerificationDefaultRepository(studentVerificationRepository: StudentVerificationDefaultRepository): StudentVerificationRepository + fun bindsSchoolDefaultRepository(schoolRepository: SchoolDefaultRepository): SchoolRepository @Binds @Singleton fun bindsTicketDefaultRepository(ticketRepository: TicketDefaultRepository): TicketRepository - - @Binds - @Singleton - fun bindsTokenDefaultRepository(tokenRepository: TokenDefaultRepository): TokenRepository - - @Binds - @Singleton - fun binsUserDefaultRepository(userRepository: UserDefaultRepository): UserRepository } diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/ViewModelScopeModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/ViewModelScopeModule.kt new file mode 100644 index 000000000..403a4f89f --- /dev/null +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/ViewModelScopeModule.kt @@ -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 +} From c466dd77cf1b98ec5d3aeca61d3042b25b67338d Mon Sep 17 00:00:00 2001 From: EmilyCh0 Date: Wed, 20 Sep 2023 15:32:58 +0900 Subject: [PATCH 8/9] =?UTF-8?q?chore:=20=EC=8B=B1=EA=B8=80=ED=86=A4=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20=ED=8C=A8=ED=82=A4=EC=A7=80=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../festago/data/di/{ => singletonscope}/AnalyticsModule.kt | 2 +- .../festago/festago/data/di/{ => singletonscope}/ApiModule.kt | 2 +- .../festago/data/di/{ => singletonscope}/DataSourceModule.kt | 2 +- .../RepositoryModule.kt} | 4 ++-- .../festago/data/di/{ => singletonscope}/ServiceModule.kt | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename android/festago/app/src/main/java/com/festago/festago/data/di/{ => singletonscope}/AnalyticsModule.kt (90%) rename android/festago/app/src/main/java/com/festago/festago/data/di/{ => singletonscope}/ApiModule.kt (97%) rename android/festago/app/src/main/java/com/festago/festago/data/di/{ => singletonscope}/DataSourceModule.kt (90%) rename android/festago/app/src/main/java/com/festago/festago/data/di/{SingletonRepositoryModule.kt => singletonscope/RepositoryModule.kt} (94%) rename android/festago/app/src/main/java/com/festago/festago/data/di/{ => singletonscope}/ServiceModule.kt (97%) diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/AnalyticsModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/AnalyticsModule.kt similarity index 90% rename from android/festago/app/src/main/java/com/festago/festago/data/di/AnalyticsModule.kt rename to android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/AnalyticsModule.kt index c56e30c3e..9434899ef 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/di/AnalyticsModule.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/AnalyticsModule.kt @@ -1,4 +1,4 @@ -package com.festago.festago.data.di +package com.festago.festago.data.di.singletonscope import com.festago.festago.analytics.AnalyticsHelper import com.festago.festago.analytics.FirebaseAnalyticsHelper diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/ApiModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ApiModule.kt similarity index 97% rename from android/festago/app/src/main/java/com/festago/festago/data/di/ApiModule.kt rename to android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ApiModule.kt index 24fb92032..c91535f57 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/di/ApiModule.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ApiModule.kt @@ -1,4 +1,4 @@ -package com.festago.festago.data.di +package com.festago.festago.data.di.singletonscope import com.festago.festago.BuildConfig import com.festago.festago.data.retrofit.AuthInterceptor diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/DataSourceModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/DataSourceModule.kt similarity index 90% rename from android/festago/app/src/main/java/com/festago/festago/data/di/DataSourceModule.kt rename to android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/DataSourceModule.kt index ddf36ee25..ed94fe610 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/di/DataSourceModule.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/DataSourceModule.kt @@ -1,4 +1,4 @@ -package com.festago.festago.data.di +package com.festago.festago.data.di.singletonscope import com.festago.festago.data.datasource.TokenDataSource import com.festago.festago.data.datasource.TokenLocalDataSource diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/SingletonRepositoryModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/RepositoryModule.kt similarity index 94% rename from android/festago/app/src/main/java/com/festago/festago/data/di/SingletonRepositoryModule.kt rename to android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/RepositoryModule.kt index 55a77df66..fe922bbc4 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/di/SingletonRepositoryModule.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/RepositoryModule.kt @@ -1,4 +1,4 @@ -package com.festago.festago.data.di +package com.festago.festago.data.di.singletonscope import com.festago.festago.data.repository.AuthDefaultRepository import com.festago.festago.data.repository.FestivalDefaultRepository @@ -18,7 +18,7 @@ import javax.inject.Singleton @InstallIn(SingletonComponent::class) @Module -interface SingletonRepositoryModule { +interface RepositoryModule { @Binds fun bindsTokenDefaultRepository(tokenRepository: TokenDefaultRepository): TokenRepository diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/ServiceModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ServiceModule.kt similarity index 97% rename from android/festago/app/src/main/java/com/festago/festago/data/di/ServiceModule.kt rename to android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ServiceModule.kt index dad849bda..a1154dc05 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/di/ServiceModule.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ServiceModule.kt @@ -1,4 +1,4 @@ -package com.festago.festago.data.di +package com.festago.festago.data.di.singletonscope import com.festago.festago.data.service.FestivalRetrofitService import com.festago.festago.data.service.ReservationTicketRetrofitService From 4b0fb3623ce7c8abbd37c57b7b23faaeb98d6bb5 Mon Sep 17 00:00:00 2001 From: EmilyCh0 Date: Wed, 20 Sep 2023 15:37:47 +0900 Subject: [PATCH 9/9] =?UTF-8?q?refactor:=20BaseUrlQualifier=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/di/singletonscope/ApiModule.kt | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ApiModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ApiModule.kt index c91535f57..e3b852420 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ApiModule.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ApiModule.kt @@ -23,6 +23,10 @@ annotation class NormalRetrofitQualifier @Retention(AnnotationRetention.BINARY) annotation class AuthRetrofitQualifier +@Qualifier +@Retention(AnnotationRetention.BINARY) +annotation class BaseUrlQualifier + @InstallIn(SingletonComponent::class) @Module object ApiModule { @@ -37,7 +41,7 @@ object ApiModule { @Provides @Singleton @NormalRetrofitQualifier - fun providesNormalRetrofit(baseUrl: String): Retrofit = Retrofit.Builder() + fun providesNormalRetrofit(@BaseUrlQualifier baseUrl: String): Retrofit = Retrofit.Builder() .baseUrl(baseUrl) .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) .build() @@ -45,14 +49,17 @@ object ApiModule { @Provides @Singleton @AuthRetrofitQualifier - fun providesAuthRetrofit(baseUrl: String, okHttpClient: OkHttpClient): Retrofit = - Retrofit.Builder() - .baseUrl(baseUrl) - .client(okHttpClient) - .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) - .build() + 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 }