Merge pull request #196 from lucasnlm/new-release

Fix bug
This commit is contained in:
Lucas Nunes 2020-10-12 19:22:33 -03:00 committed by GitHub
commit 9c91fb365d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 5 deletions

View file

@ -750,7 +750,13 @@ class GameActivity : ThematicActivity(R.layout.activity_game), DialogInterface.O
keepScreenOn(false)
if (!isResuming) {
lifecycleScope.launch {
gameViewModel.saveGame()
gameViewModel.saveStats()
}
cloudSaveManager.uploadSave()
gameViewModel.addNewTip()
waitAndShowEndGameAlert(
@ -773,8 +779,10 @@ class GameActivity : ThematicActivity(R.layout.activity_game), DialogInterface.O
if (!isResuming) {
cloudSaveManager.uploadSave()
GlobalScope.launch(context = Dispatchers.Main) {
lifecycleScope.launch {
gameViewModel.gameOver(isResuming)
gameViewModel.saveGame()
gameViewModel.saveStats()
waitAndShowEndGameAlert(
victory = false,
await = true

View file

@ -73,6 +73,8 @@ class SplashViewModel(
} catch (e: Exception) {
null
}
}.distinctBy {
it.uid
}.forEach {
statsRepository.addStats(it)
}

View file

@ -234,7 +234,7 @@ open class GameViewModel(
}
}
private suspend fun saveStats() {
suspend fun saveStats() {
if (initialized) {
gameController.let {
if (it.hasMines()) {
@ -466,9 +466,6 @@ open class GameViewModel(
}
viewModelScope.launch {
saveStats()
saveGame()
checkVictoryAchievements()
}
}