Class UserViewModel
- java.lang.Object
-
- androidx.lifecycle.ViewModel
-
- androidx.lifecycle.AndroidViewModel
-
- edu.cnm.deepdive.tunefull.viewmodel.UserViewModel
-
public class UserViewModel extends AndroidViewModel
TheUserViewModel
talks to theUserRepository
to communicate with the server.
-
-
Constructor Summary
Constructors Constructor Description UserViewModel(Application application)
The constructor initializes theMutableLiveData
used in the viewmodel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LiveData<User.Genre>
getGenre()
Returns LiveData of the user's current genre.LiveData<User>
getUser()
Returns LiveData of the current user.void
loadUser()
Loads a user from the server.void
saveGenre(User.Genre genre)
Saves a genre for the current user.-
Methods inherited from class androidx.lifecycle.AndroidViewModel
getApplication
-
-
-
-
Constructor Detail
-
UserViewModel
public UserViewModel(Application application)
The constructor initializes theMutableLiveData
used in the viewmodel.- Parameters:
application
- The current application.
-
-
Method Detail
-
getGenre
public LiveData<User.Genre> getGenre()
Returns LiveData of the user's current genre.- Returns:
- LiveData of the user's current genre.
-
getUser
public LiveData<User> getUser()
Returns LiveData of the current user.- Returns:
- LiveData of the current user.
-
saveGenre
public void saveGenre(User.Genre genre)
Saves a genre for the current user.- Parameters:
genre
- The genre to be saved.
-
loadUser
public void loadUser()
Loads a user from the server.
-
-