Class MainViewModel
- java.lang.Object
-
- androidx.lifecycle.ViewModel
-
- androidx.lifecycle.AndroidViewModel
-
- edu.cnm.deepdive.scalescroller.viewmodel.MainViewModel
-
- All Implemented Interfaces:
LifecycleObserver
public class MainViewModel extends AndroidViewModel implements LifecycleObserver
Serves as the ViewModel for all fragments except the GameFragment.
-
-
Constructor Summary
Constructors Constructor Description MainViewModel(Application application)
The constructor initializes repositories, services, and other elements needed by the ViewModel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LiveData<List<ChallengeAttemptWithPlayer>>
getHighScores()
Returns LiveData of a list of the highest-scoring challenge attempts and their associated players.LiveData<Player>
getPlayer()
Returns LiveData of the current player.LiveData<List<Scale>>
getScales()
Returns LiveData of a list of all scales in the database, ordered by difficulty.-
Methods inherited from class androidx.lifecycle.AndroidViewModel
getApplication
-
-
-
-
Constructor Detail
-
MainViewModel
public MainViewModel(@NonNull Application application)
The constructor initializes repositories, services, and other elements needed by the ViewModel.- Parameters:
application
- The ScaleScroller application.
-
-
Method Detail
-
getPlayer
public LiveData<Player> getPlayer()
Returns LiveData of the current player.- Returns:
LiveData
of the currentPlayer
.
-
getHighScores
public LiveData<List<ChallengeAttemptWithPlayer>> getHighScores()
Returns LiveData of a list of the highest-scoring challenge attempts and their associated players. Uses the default number of high scores.- Returns:
LiveData
of aList
of the highest-scoringChallengeAttemptWithPlayer
.
-
-