From 014b4feebfaaf0cb54b99c3ec1b06164b386a9b7 Mon Sep 17 00:00:00 2001 From: Lucas Lima Date: Fri, 12 Jun 2020 08:53:03 -0300 Subject: [PATCH] Add defeat and victory to stats --- .../lucasnlm/antimine/stats/StatsActivity.kt | 21 +++++++++----- app/src/main/res/layout/activity_stats.xml | 29 ++++++++++++++++++- common/src/main/res/values/strings.xml | 2 ++ 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/dev/lucasnlm/antimine/stats/StatsActivity.kt b/app/src/main/java/dev/lucasnlm/antimine/stats/StatsActivity.kt index b5afd585..93461ee7 100644 --- a/app/src/main/java/dev/lucasnlm/antimine/stats/StatsActivity.kt +++ b/app/src/main/java/dev/lucasnlm/antimine/stats/StatsActivity.kt @@ -24,14 +24,19 @@ class StatsActivity : DaggerAppCompatActivity() { setTitle(R.string.events) viewModel = ViewModelProviders.of(this).get(StatsViewModel::class.java) - viewModel.statsObserver.observe(this, Observer { - minesCount.text = it.mines.toString() - totalTime.text = formatTime(it.duration) - averageTime.text = formatTime(it.averageDuration) - totalGames.text = it.totalGames.toString() - performance.text = formatPercentage(100.0 * it.victory / it.totalGames) - openAreas.text = it.openArea.toString() - }) + viewModel.statsObserver.observe( + this, + Observer { + minesCount.text = it.mines.toString() + totalTime.text = formatTime(it.duration) + averageTime.text = formatTime(it.averageDuration) + totalGames.text = it.totalGames.toString() + performance.text = formatPercentage(100.0 * it.victory / it.totalGames) + openAreas.text = it.openArea.toString() + victory.text = it.victory.toString() + defeat.text = (it.totalGames - it.victory).toString() + } + ) GlobalScope.launch { viewModel.loadStats(statsRepository) diff --git a/app/src/main/res/layout/activity_stats.xml b/app/src/main/res/layout/activity_stats.xml index 5b79b190..e7b9b821 100644 --- a/app/src/main/res/layout/activity_stats.xml +++ b/app/src/main/res/layout/activity_stats.xml @@ -80,7 +80,6 @@ - + + + + + + + + + + + + diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index a6e4aff7..073eac9a 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -58,7 +58,9 @@ Empty You\'ll lose all moves on current game.\nBut you can also install the game before quit. You won! + Victory You lost! + Defeat Long press a square to put a flag. Good luck on your next game. You did %1$d/%2$d in %3$d seconds.