Update CloudeSaveManager code
This commit is contained in:
parent
8cdf295fd4
commit
a503838d1f
13 changed files with 54 additions and 23 deletions
|
@ -26,7 +26,6 @@ import androidx.lifecycle.Transformations
|
|||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.preference.PreferenceManager
|
||||
import dev.lucasnlm.antimine.cloud.CloudSaveManager
|
||||
import dev.lucasnlm.antimine.common.level.models.Difficulty
|
||||
import dev.lucasnlm.antimine.common.level.models.Event
|
||||
import dev.lucasnlm.antimine.common.level.models.Score
|
||||
|
|
|
@ -2,7 +2,7 @@ package dev.lucasnlm.antimine.cloud
|
|||
|
||||
import dev.lucasnlm.antimine.common.level.database.models.toHashMap
|
||||
import dev.lucasnlm.antimine.common.level.repository.IStatsRepository
|
||||
import dev.lucasnlm.antimine.core.cloud.ICloudSaveManager
|
||||
import dev.lucasnlm.antimine.core.cloud.CloudSaveManager
|
||||
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
|
||||
import dev.lucasnlm.external.ICloudStorageManager
|
||||
import dev.lucasnlm.external.IPlayGamesManager
|
||||
|
@ -12,12 +12,12 @@ import kotlinx.coroutines.GlobalScope
|
|||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class CloudSaveManager(
|
||||
class CloudSaveManagerImpl(
|
||||
private val playGamesManager: IPlayGamesManager,
|
||||
private val preferencesRepository: IPreferencesRepository,
|
||||
private val statsRepository: IStatsRepository,
|
||||
private val cloudStorageManager: ICloudStorageManager,
|
||||
) : ICloudSaveManager {
|
||||
) : CloudSaveManager {
|
||||
override fun uploadSave() {
|
||||
GlobalScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
|
@ -1,12 +1,12 @@
|
|||
package dev.lucasnlm.antimine.di
|
||||
|
||||
import dev.lucasnlm.antimine.cloud.CloudSaveManager
|
||||
import dev.lucasnlm.antimine.cloud.CloudSaveManagerImpl
|
||||
import dev.lucasnlm.antimine.support.IapHandler
|
||||
import dev.lucasnlm.antimine.common.BuildConfig
|
||||
import dev.lucasnlm.antimine.core.analytics.DebugAnalyticsManager
|
||||
import dev.lucasnlm.antimine.core.analytics.IAnalyticsManager
|
||||
import dev.lucasnlm.antimine.core.analytics.ProdAnalyticsManager
|
||||
import dev.lucasnlm.antimine.core.cloud.ICloudSaveManager
|
||||
import dev.lucasnlm.antimine.core.cloud.CloudSaveManager
|
||||
import dev.lucasnlm.antimine.share.ShareManager
|
||||
import dev.lucasnlm.external.AdsManager
|
||||
import dev.lucasnlm.external.BillingManager
|
||||
|
@ -43,7 +43,7 @@ val AppModule = module {
|
|||
|
||||
single { IapHandler(get(), get(), get()) }
|
||||
|
||||
single { CloudSaveManager(get(), get(), get(), get()) } bind ICloudSaveManager::class
|
||||
single { CloudSaveManagerImpl(get(), get(), get(), get()) } bind CloudSaveManager::class
|
||||
|
||||
single { FeatureFlagManager() } bind IFeatureFlagManager::class
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import androidx.preference.PreferenceFragmentCompat
|
|||
import androidx.preference.PreferenceManager
|
||||
import dev.lucasnlm.antimine.R
|
||||
import dev.lucasnlm.antimine.ui.ThematicActivity
|
||||
import dev.lucasnlm.antimine.cloud.CloudSaveManager
|
||||
import org.koin.android.ext.android.inject
|
||||
|
||||
class PreferencesActivity :
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.view.MenuItem
|
|||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import dev.lucasnlm.antimine.R
|
||||
import dev.lucasnlm.antimine.cloud.CloudSaveManager
|
||||
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
|
||||
import dev.lucasnlm.antimine.common.level.view.SpaceItemDecoration
|
||||
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
|
||||
|
|
|
@ -66,4 +66,10 @@ dependencies {
|
|||
|
||||
// Kotlin Lib
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10'
|
||||
|
||||
// Unit Tests
|
||||
testImplementation 'junit:junit:4.13.1'
|
||||
testImplementation 'org.mockito:mockito-core:2.24.0'
|
||||
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0'
|
||||
testImplementation "io.mockk:mockk:1.10.3"
|
||||
}
|
|
@ -12,13 +12,13 @@ import dev.lucasnlm.antimine.control.view.ControlItemView
|
|||
import dev.lucasnlm.antimine.control.view.SimpleControlItemView
|
||||
import dev.lucasnlm.antimine.control.viewmodel.ControlEvent
|
||||
import dev.lucasnlm.antimine.control.viewmodel.ControlViewModel
|
||||
import dev.lucasnlm.antimine.core.cloud.ICloudSaveManager
|
||||
import dev.lucasnlm.antimine.core.cloud.CloudSaveManager
|
||||
import dev.lucasnlm.antimine.preferences.models.ControlStyle
|
||||
import org.koin.android.ext.android.inject
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
class ControlDialogFragment : AppCompatDialogFragment() {
|
||||
private val cloudSaveManager by inject<ICloudSaveManager>()
|
||||
private val cloudSaveManager by inject<CloudSaveManager>()
|
||||
private val controlViewModel by viewModel<ControlViewModel>()
|
||||
private val adapter by lazy { ControlListAdapter(controlViewModel) }
|
||||
|
||||
|
|
|
@ -1,16 +1,34 @@
|
|||
package dev.lucasnlm.antimine.control
|
||||
package dev.lucasnlm.antimine.control.viewmodel
|
||||
|
||||
import dev.lucasnlm.antimine.IntentViewModelTest
|
||||
import dev.lucasnlm.antimine.control.viewmodel.ControlEvent
|
||||
import dev.lucasnlm.antimine.control.viewmodel.ControlViewModel
|
||||
import dev.lucasnlm.antimine.preferences.models.ControlStyle
|
||||
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
|
||||
import dev.lucasnlm.antimine.preferences.models.ControlStyle
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.TestCoroutineDispatcher
|
||||
import kotlinx.coroutines.test.resetMain
|
||||
import kotlinx.coroutines.test.setMain
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class ControlViewModelTest : IntentViewModelTest() {
|
||||
@ExperimentalCoroutinesApi
|
||||
class ControlViewModelTest {
|
||||
private val dispatcher = TestCoroutineDispatcher()
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
Dispatchers.setMain(dispatcher)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Dispatchers.resetMain()
|
||||
}
|
||||
|
||||
private fun ControlViewModel.selectedControlStyle() = singleState().let {
|
||||
it.gameControls[it.selectedIndex].controlStyle
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
package dev.lucasnlm.antimine.core.cloud
|
||||
|
||||
interface ICloudSaveManager {
|
||||
interface CloudSaveManager {
|
||||
fun uploadSave()
|
||||
}
|
||||
|
|
|
@ -37,4 +37,10 @@ dependencies {
|
|||
// AndroidX
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'androidx.preference:preference-ktx:1.1.1'
|
||||
|
||||
// Unit Tests
|
||||
testImplementation 'junit:junit:4.13.1'
|
||||
testImplementation 'org.mockito:mockito-core:2.24.0'
|
||||
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0'
|
||||
testImplementation "io.mockk:mockk:1.10.3"
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
package dev.lucasnlm.antimine.core.preferences
|
||||
package dev.lucasnlm.antimine.preferences
|
||||
|
||||
import dev.lucasnlm.antimine.preferences.PreferencesRepository
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
private class TestPreferenceManager : dev.lucasnlm.antimine.preferences.IPreferencesManager {
|
||||
private class TestPreferenceManager : IPreferencesManager {
|
||||
val values = mutableMapOf<String, Any>()
|
||||
|
||||
override fun getBoolean(key: String, defaultValue: Boolean): Boolean {
|
|
@ -60,4 +60,10 @@ dependencies {
|
|||
|
||||
// Kotlin Lib
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10'
|
||||
|
||||
// Unit Tests
|
||||
testImplementation 'junit:junit:4.13.1'
|
||||
testImplementation 'org.mockito:mockito-core:2.24.0'
|
||||
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0'
|
||||
testImplementation "io.mockk:mockk:1.10.3"
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package dev.lucasnlm.antimine.core.themes.repository
|
||||
package dev.lucasnlm.antimine.ui.repository
|
||||
|
||||
import dev.lucasnlm.antimine.ui.repository.Themes
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
Loading…
Reference in a new issue