Create Another ViewModel (Game)
This class will look similar to PickPlayersViewModel on a high level, but there’s going to be a lot more going on here since this will handle the connection between the Game view and the GameHandler we’ll be building in Chapter 4, Update LiveData with Conditional Game Logic.
We’re going to start with an empty GameViewModel class, and we can add the pieces in later on. It’ll look like this:
| package dev.mfazio.pennydrop.viewmodels |
| |
| import androidx.lifecycle.ViewModel |
| |
| class GameViewModel: ViewModel() { |
| //Logic will go in here. |
| } |
Once GameViewModel is available, we can add a List<Player> to hold everyone we added in the Pick Players view. We’ll need a little setup before we can do that, though. ...
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.