Add defeat and victory to stats

This commit is contained in:
Lucas Lima 2020-06-12 08:53:03 -03:00
parent 513c7f1603
commit 014b4feebf
No known key found for this signature in database
GPG key ID: 0259A3F43EC1027A
3 changed files with 43 additions and 9 deletions

View file

@ -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)

View file

@ -80,7 +80,6 @@
</TableRow>
<TableRow>
<TextView
android:padding="16dp"
android:text="@string/performance"
@ -93,4 +92,32 @@
android:text="-"
tools:ignore="HardcodedText" />
</TableRow>
<TableRow>
<TextView
android:padding="16dp"
android:text="@string/victory"
android:textColor="@color/text_color" />
<TextView
android:id="@+id/victory"
android:gravity="end"
android:padding="16dp"
android:text="-"
tools:ignore="HardcodedText" />
</TableRow>
<TableRow>
<TextView
android:padding="16dp"
android:text="@string/defeat"
android:textColor="@color/text_color" />
<TextView
android:id="@+id/defeat"
android:gravity="end"
android:padding="16dp"
android:text="-"
tools:ignore="HardcodedText" />
</TableRow>
</TableLayout>

View file

@ -58,7 +58,9 @@
<string name="empty">Empty</string>
<string name="quit_confirm">You\'ll lose all moves on current game.\nBut you can also install the game before quit.</string>
<string name="you_won">You won!</string>
<string name="victory">Victory</string>
<string name="you_lost">You lost!</string>
<string name="defeat">Defeat</string>
<string name="game_over_desc_0">Long press a square to put a flag.</string>
<string name="game_over_desc_1">Good luck on your next game.</string>
<string name="game_over_desc_2">You did %1$d/%2$d in %3$d seconds.</string>