The following code shows a simple database query, which gets a list of "inactive groups":
viewModel.getInactiveGroups().observe(this, new Observer>() {
@Override
public void onChanged(List inactiveGroupList) {
if (inactiveGroupList == null){
int activeGroupNumber = ***I don't know what to do here***;
if (activeGroupNumber != 0)
buttonViewActiveGroups.setVisibility(View.VISIBLE);
} else {
//Rest of code to display list in recyclerview
}
}
});
When the list of inactive groups is empty, I need to check if there are any active groups to make a button visible
The problem is that I don't know how I should make that new query inside onChanged, is it necessary to do it with LiveData or what method can I use?
Basically this is my query I need: SELECT COUNT(*) FROM Group WHERE isActive=1
It is a database with Room, ViewModel and Repository, I do not attach more code because I do not consider it necessary, I only have doubts about the way in which a new query should be made within the onChanged method
