Class MainViewModel
- java.lang.Object
-
- androidx.lifecycle.ViewModel
-
- androidx.lifecycle.AndroidViewModel
-
- edu.cnm.deepdive.teamassignmentsandroid.viewmodel.MainViewModel
-
public class MainViewModel extends AndroidViewModel
Prepares and manages data for the activities and fragments and presents it to the UI.
-
-
Constructor Summary
Constructors Constructor Description MainViewModel(Application application)
Manages data for acitivities and fragmetns.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteGroup(long groupId)
void
deleteTask(long groupId, long taskId)
LiveData<Group>
getGroup()
LiveData<List<Group>>
getGroups()
Gets group from model.Group.LiveData<List<Group>>
getOwnedGroups()
Gets Owned groups from management fragment.LiveData<Task>
getTask()
LiveData<List<Task>>
getTasks()
Gets tasks from pojo.void
loadGroup(long groupId)
void
loadGroups()
Posts Group to thread to set given value.void
loadOwnedGroups()
Groups will be loaded from the database.void
loadTask(long groupId, long taskId)
void
loadTasks(long groupId)
Posts Task to thread to set given value.void
saveGroup(Group group)
Groups come from management fragment and gets saved to the database.void
saveTask(long groupId, Task task)
Saves a task to the database.-
Methods inherited from class androidx.lifecycle.AndroidViewModel
getApplication
-
-
-
-
Constructor Detail
-
MainViewModel
public MainViewModel(@NonNull Application application)
Manages data for acitivities and fragmetns.- Parameters:
application
- is only parameter accepted by viewModel constructor.
-
-
Method Detail
-
getGroups
public LiveData<List<Group>> getGroups()
Gets group from model.Group.- Returns:
- group as live data.
-
getOwnedGroups
public LiveData<List<Group>> getOwnedGroups()
Gets Owned groups from management fragment.- Returns:
- list of owned groups.
-
loadTasks
public void loadTasks(long groupId)
Posts Task to thread to set given value.- Parameters:
groupId
- The group's id.
-
loadGroup
public void loadGroup(long groupId)
-
deleteGroup
public void deleteGroup(long groupId)
-
loadTask
public void loadTask(long groupId, long taskId)
-
loadGroups
public void loadGroups()
Posts Group to thread to set given value.
-
loadOwnedGroups
public void loadOwnedGroups()
Groups will be loaded from the database.
-
saveGroup
public void saveGroup(Group group)
Groups come from management fragment and gets saved to the database.- Parameters:
group
- will be saved to database.
-
saveTask
public void saveTask(long groupId, Task task)
Saves a task to the database.- Parameters:
groupId
- id required to assign tasktask
- is assigned to group id
-
deleteTask
public void deleteTask(long groupId, long taskId)
-
-