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/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..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 @@ -3,15 +3,15 @@ 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 -object FirebaseAnalyticsHelper : AnalyticsHelper { +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 +22,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..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 @@ -4,8 +4,12 @@ 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 -class TokenLocalDataSource(context: Context) : TokenDataSource { +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/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 +} diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/AnalyticsModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/AnalyticsModule.kt new file mode 100644 index 000000000..9434899ef --- /dev/null +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/AnalyticsModule.kt @@ -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 +} 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 new file mode 100644 index 000000000..e3b852420 --- /dev/null +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ApiModule.kt @@ -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 +} diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/DataSourceModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/DataSourceModule.kt new file mode 100644 index 000000000..ed94fe610 --- /dev/null +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/DataSourceModule.kt @@ -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 +} diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/RepositoryModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/RepositoryModule.kt new file mode 100644 index 000000000..fe922bbc4 --- /dev/null +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/RepositoryModule.kt @@ -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 +} diff --git a/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ServiceModule.kt b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ServiceModule.kt new file mode 100644 index 000000000..a1154dc05 --- /dev/null +++ b/android/festago/app/src/main/java/com/festago/festago/data/di/singletonscope/ServiceModule.kt @@ -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) + } +} 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..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 @@ -5,8 +5,9 @@ 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 -class AuthDefaultRepository( +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..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 @@ -5,8 +5,9 @@ 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 -class FestivalDefaultRepository( +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..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 @@ -4,8 +4,9 @@ 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 -class ReservationTicketDefaultRepository( +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..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 @@ -1,8 +1,9 @@ package com.festago.festago.data.repository import com.festago.festago.repository.SchoolRepository +import javax.inject.Inject -class SchoolDefaultRepository() : SchoolRepository { +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..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 @@ -3,8 +3,9 @@ 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 -class StudentVerificationDefaultRepository( +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..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 @@ -7,8 +7,9 @@ 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 -class TicketDefaultRepository( +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..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 @@ -6,8 +6,9 @@ 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 -class TokenDefaultRepository( +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..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 @@ -4,8 +4,9 @@ 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 -class UserDefaultRepository( +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..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 @@ -2,8 +2,9 @@ package com.festago.festago.data.retrofit import com.festago.festago.repository.TokenRepository import com.kakao.sdk.auth.TokenManagerProvider +import javax.inject.Inject -class TokenManager(private val tokenRepository: TokenRepository) { +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/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 - } -} 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 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 }