Merge pull request #113 from lucasnlm/fix-resume-bug
Fix mine count value on resume game
This commit is contained in:
commit
b2b2758d58
7 changed files with 28 additions and 20 deletions
|
@ -9,8 +9,8 @@ android {
|
|||
|
||||
defaultConfig {
|
||||
// versionCode and versionName must be hardcoded to support F-droid
|
||||
versionCode 702011
|
||||
versionName '7.2.1'
|
||||
versionCode 702021
|
||||
versionName '7.2.2'
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
multiDexEnabled true
|
||||
|
|
|
@ -139,7 +139,7 @@ class GameActivity : AppCompatActivity(), DialogInterface.OnDismissListener {
|
|||
val mines = area.filter { it.hasMine }
|
||||
totalArea = area.count()
|
||||
totalMines = mines.count()
|
||||
rightMines = mines.map { if (it.mark.isFlag()) 1 else 0 }.sum()
|
||||
rightMines = mines.count { it.mark.isFlag() }
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -166,13 +166,18 @@ class GameActivity : AppCompatActivity(), DialogInterface.OnDismissListener {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (status == Status.Running) {
|
||||
viewModel.refreshUserPreferences()
|
||||
viewModel.resumeGame()
|
||||
analyticsManager.sentEvent(Analytics.Resume())
|
||||
}
|
||||
val willReset = restartIfNeed()
|
||||
|
||||
restartIfNeed()
|
||||
if (!willReset) {
|
||||
if (status == Status.Running) {
|
||||
viewModel.run {
|
||||
refreshUserPreferences()
|
||||
resumeGame()
|
||||
}
|
||||
|
||||
analyticsManager.sentEvent(Analytics.Resume())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
@ -536,9 +541,11 @@ class GameActivity : AppCompatActivity(), DialogInterface.OnDismissListener {
|
|||
* If user change any accessibility preference, the game will restart the activity to
|
||||
* apply these changes.
|
||||
*/
|
||||
private fun restartIfNeed() {
|
||||
if (usingLargeArea != preferencesRepository.useLargeAreas()) {
|
||||
recreate()
|
||||
private fun restartIfNeed(): Boolean {
|
||||
return (usingLargeArea != preferencesRepository.useLargeAreas()).also {
|
||||
if (it) {
|
||||
recreate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ android {
|
|||
|
||||
defaultConfig {
|
||||
// versionCode and versionName must be hardcoded to support F-droid
|
||||
versionCode 702011
|
||||
versionName '7.2.1'
|
||||
versionCode 702021
|
||||
versionName '7.2.2'
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
|
||||
|
|
|
@ -94,6 +94,7 @@ class GameViewModel @ViewModelInject constructor(
|
|||
difficulty.postValue(save.difficulty)
|
||||
levelSetup.postValue(setup)
|
||||
refreshAll()
|
||||
refreshMineCount()
|
||||
|
||||
when {
|
||||
gameController.hasAnyMineExploded() -> eventObserver.postValue(Event.GameOver)
|
||||
|
|
|
@ -6,8 +6,8 @@ android {
|
|||
compileSdkVersion 29
|
||||
|
||||
defaultConfig {
|
||||
versionCode 702011 // MMmmPPv
|
||||
versionName '7.2.1'
|
||||
versionCode 702021 // MMmmPPv
|
||||
versionName '7.2.2'
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
resConfigs 'ar', 'en', 'cs', 'de', 'el', 'es', 'fr', 'ja', 'pt', 'ru', 'tr', 'uk', 'vi', 'zh'
|
||||
|
|
|
@ -6,8 +6,8 @@ android {
|
|||
compileSdkVersion 29
|
||||
|
||||
defaultConfig {
|
||||
versionCode 702011 // MMmmPPv
|
||||
versionName '7.2.1'
|
||||
versionCode 702021 // MMmmPPv
|
||||
versionName '7.2.2'
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
resConfigs 'ar', 'en', 'cs', 'de', 'el', 'es', 'fr', 'ja', 'pt', 'ru', 'tr', 'uk', 'vi', 'zh'
|
||||
|
|
|
@ -9,8 +9,8 @@ android {
|
|||
|
||||
defaultConfig {
|
||||
// versionCode and versionName must be hardcoded to support F-droid
|
||||
versionCode 702011
|
||||
versionName '7.2.1'
|
||||
versionCode 702021
|
||||
versionName '7.2.2'
|
||||
applicationId 'dev.lucasnlm.antimine'
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 29
|
||||
|
|
Loading…
Reference in a new issue