Skip to content

Commit

Permalink
ETC.
Browse files Browse the repository at this point in the history
  • Loading branch information
commandiron committed Oct 2, 2022
1 parent 61582c1 commit 7ad0a9d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package com.commandiron.toprated10films.data.di

import android.app.Application
import android.content.Context
import android.content.SharedPreferences
import androidx.room.Room
import com.commandiron.toprated10films.data.local.AppDao
import com.commandiron.toprated10films.data.local.AppDatabase
import com.commandiron.toprated10films.data.local.AppDatabase.Companion.DATABASE_NAME
import com.commandiron.toprated10films.data.local.DefaultPreferences
import com.commandiron.toprated10films.data.local.DefaultPreferences.Companion.PREF_NAME
import com.commandiron.toprated10films.data.remote.MovieApi
import com.commandiron.toprated10films.data.remote.MovieApi.Companion.BASE_URL
import com.commandiron.toprated10films.data.repository.AppRepositoryImpl
import com.commandiron.toprated10films.domain.preferences.AppPreferences
import com.commandiron.toprated10films.domain.repository.AppRepository
import dagger.Module
import dagger.Provides
Expand All @@ -23,6 +28,20 @@ import javax.inject.Singleton
@InstallIn(SingletonComponent::class)
object DataModule {

@Provides
@Singleton
fun provideSharedPreferences(
app: Application
): SharedPreferences {
return app.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
}

@Provides
@Singleton
fun providePreferences(sharedPreferences: SharedPreferences): AppPreferences {
return DefaultPreferences(sharedPreferences)
}

@Provides
@Singleton
fun provideWeatherApi(): MovieApi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ class DefaultPreferences(
)
}

companion object {
const val PREF_NAME = "shared_pref"
}
}
31 changes: 0 additions & 31 deletions app/src/main/java/com/commandiron/toprated10films/di/AppModule.kt

This file was deleted.

0 comments on commit 7ad0a9d

Please sign in to comment.