Create Turn Summary Text

We added the large <TextView> near the bottom of the Game screen in the previous chapter to give users info about the current turn, how a turn ends, and a summary of scores when a game ends. Right now, when a turn starts, that area says nothing. And once a turn ends, that area then says...nothing. Yes, that value’s still empty from the previous chapter and is, well, useless. Let’s fix that!

We already have this block of code inside updateFromGameHandler:

 //result is a TurnResult object
 currentTurnText.value = generateTurnText(result)

As a result, we have two main additions:

  • A clearText variable, which tells us if we should clear the <TextView>.
  • A new generateTurnText method.

Step one should be done (seriously, ...

Get Kotlin and Android Development featuring Jetpack now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.