diff --git a/app/src/main/kotlin/at/connyduck/pixelcat/dagger/AppModule.kt b/app/src/main/kotlin/at/connyduck/pixelcat/dagger/AppModule.kt index f40c6f8..5084b30 100644 --- a/app/src/main/kotlin/at/connyduck/pixelcat/dagger/AppModule.kt +++ b/app/src/main/kotlin/at/connyduck/pixelcat/dagger/AppModule.kt @@ -19,13 +19,11 @@ package at.connyduck.pixelcat.dagger -import android.app.Application import android.content.Context import android.content.SharedPreferences import androidx.preference.PreferenceManager import androidx.room.Room import at.connyduck.pixelcat.PixelcatApplication -import at.connyduck.pixelcat.db.AccountManager import at.connyduck.pixelcat.db.AppDatabase import at.connyduck.pixelcat.db.RoomConverter import dagger.Module @@ -36,14 +34,12 @@ import javax.inject.Singleton class AppModule { @Provides - fun providesApp(app: PixelcatApplication): Application = app + fun providesContext(app: PixelcatApplication): Context = app @Provides - fun providesContext(app: Application): Context = app - - @Provides - fun providesSharedPreferences(app: Application): SharedPreferences { - return PreferenceManager.getDefaultSharedPreferences(app) + @Singleton + fun providesSharedPreferences(context: Context): SharedPreferences { + return PreferenceManager.getDefaultSharedPreferences(context) } @Provides @@ -54,10 +50,4 @@ class AppModule { .addTypeConverter(converter) .build() } - - @Provides - @Singleton - fun providesAccountManager(db: AppDatabase): AccountManager { - return AccountManager(db) - } } diff --git a/app/src/main/kotlin/at/connyduck/pixelcat/db/AccountManager.kt b/app/src/main/kotlin/at/connyduck/pixelcat/db/AccountManager.kt index 9809d56..83a2c56 100644 --- a/app/src/main/kotlin/at/connyduck/pixelcat/db/AccountManager.kt +++ b/app/src/main/kotlin/at/connyduck/pixelcat/db/AccountManager.kt @@ -23,6 +23,8 @@ import android.util.Log import at.connyduck.pixelcat.db.entitity.AccountAuthData import at.connyduck.pixelcat.db.entitity.AccountEntity import at.connyduck.pixelcat.model.Account +import javax.inject.Inject +import javax.inject.Singleton /** * This class caches the account database and handles all account related operations @@ -30,7 +32,8 @@ import at.connyduck.pixelcat.model.Account private const val TAG = "AccountManager" -class AccountManager(db: AppDatabase) { +@Singleton +class AccountManager @Inject constructor(db: AppDatabase) { private var activeAccount: AccountEntity? = null