Fix Application context provides

This commit is contained in:
Lucas Lima 2020-06-20 12:22:22 -03:00
parent 50effbc1d5
commit 38d518a686
No known key found for this signature in database
GPG key ID: 0259A3F43EC1027A
4 changed files with 13 additions and 13 deletions

View file

@ -58,7 +58,7 @@ open class LevelModule {
@Provides
open fun provideGameViewModelFactory(
application: Application,
@ApplicationContext context: Context,
eventObserver: MutableLiveData<Event>,
savesRepository: ISavesRepository,
statsRepository: IStatsRepository,
@ -69,7 +69,7 @@ open class LevelModule {
analyticsManager: AnalyticsManager,
clock: Clock
) = GameViewModelFactory(
application,
context,
eventObserver,
savesRepository,
statsRepository,
@ -83,7 +83,7 @@ open class LevelModule {
@Provides
open fun provideDimensionRepository(
context: Context,
@ApplicationContext context: Context,
preferencesRepository: IPreferencesRepository
): IDimensionRepository =
DimensionRepository(context, preferencesRepository)
@ -103,10 +103,10 @@ open class LevelModule {
@Provides
open fun provideHapticFeedbackInteractor(
application: Application,
@ApplicationContext context: Context,
preferencesRepository: IPreferencesRepository
): IHapticFeedbackInteractor =
HapticFeedbackInteractor(application, preferencesRepository)
HapticFeedbackInteractor(context, preferencesRepository)
companion object {
private const val DATA_BASE_NAME = "saves-db"

View file

@ -1,6 +1,6 @@
package dev.lucasnlm.antimine.common.level.utils
import android.app.Application
import android.content.Context
import android.content.Context.VIBRATOR_SERVICE
import android.os.Build
import android.os.VibrationEffect
@ -13,10 +13,10 @@ interface IHapticFeedbackInteractor {
}
class HapticFeedbackInteractor(
application: Application,
context: Context,
private val preferencesRepository: IPreferencesRepository
) : IHapticFeedbackInteractor {
private val vibrator: Vibrator = application.getSystemService(VIBRATOR_SERVICE) as Vibrator
private val vibrator: Vibrator = context.getSystemService(VIBRATOR_SERVICE) as Vibrator
override fun toggleFlagFeedback() {
if (preferencesRepository.useHapticFeedback()) {

View file

@ -1,6 +1,6 @@
package dev.lucasnlm.antimine.common.level.viewmodel
import android.app.Application
import android.content.Context
import android.os.Handler
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
@ -27,7 +27,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
class GameViewModel(
val application: Application,
val context: Context,
val eventObserver: MutableLiveData<Event>,
private val savesRepository: ISavesRepository,
private val statsRepository: IStatsRepository,

View file

@ -1,6 +1,6 @@
package dev.lucasnlm.antimine.common.level.viewmodel
import android.app.Application
import android.content.Context
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
@ -16,7 +16,7 @@ import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import javax.inject.Inject
class GameViewModelFactory @Inject constructor(
private val application: Application,
private val context: Context,
private val eventObserver: MutableLiveData<Event>,
private val savesRepository: ISavesRepository,
private val statsRepository: IStatsRepository,
@ -32,7 +32,7 @@ class GameViewModelFactory @Inject constructor(
override fun <T : ViewModel?> create(modelClass: Class<T>): T =
if (modelClass.isAssignableFrom(GameViewModel::class.java)) {
GameViewModel(
application,
context,
eventObserver,
savesRepository,
statsRepository,