Use AccountManager
This commit is contained in:
@@ -5,6 +5,7 @@ import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import gq.kirmanak.mealient.R
|
||||
import gq.kirmanak.mealient.data.auth.AuthDataSource
|
||||
import gq.kirmanak.mealient.data.auth.AuthRepo
|
||||
import gq.kirmanak.mealient.data.auth.AuthStorage
|
||||
@@ -16,6 +17,7 @@ import gq.kirmanak.mealient.data.baseurl.BaseURLStorage
|
||||
import gq.kirmanak.mealient.data.network.RetrofitBuilder
|
||||
import gq.kirmanak.mealient.data.network.ServiceFactory
|
||||
import gq.kirmanak.mealient.data.network.createServiceFactory
|
||||
import gq.kirmanak.mealient.service.auth.AccountParameters
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@@ -24,12 +26,26 @@ interface AuthModule {
|
||||
|
||||
companion object {
|
||||
|
||||
const val ACCOUNT_TYPE = "Mealient"
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideAuthServiceFactory(
|
||||
retrofitBuilder: RetrofitBuilder,
|
||||
fun provideAuthServiceFactory(retrofitBuilder: RetrofitBuilder,
|
||||
baseURLStorage: BaseURLStorage,
|
||||
): ServiceFactory<AuthService> = retrofitBuilder.createServiceFactory(baseURLStorage)
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideAccountManager(@ApplicationContext context: Context): AccountManager {
|
||||
return AccountManager.get(context)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideAccountType(@ApplicationContext context: Context) = AccountParameters(
|
||||
accountType = context.getString(R.string.account_type),
|
||||
authTokenType = context.getString(R.string.auth_token_type),
|
||||
)
|
||||
}
|
||||
|
||||
@Binds
|
||||
|
||||
Reference in New Issue
Block a user