在我的主要活动中,我有逻辑地观察从房间数据库到UI的实时数据。我希望这种逻辑体现在viewModel
的编写方式中:
detailsViewModel.getHereAllDetails().observe(this, new Observer<DetailsEntity>() {
@Override
public void onChanged(@Nullable DetailsEntity detailsEntity)
{
if (detailsEntity != null)
{
details.setCheckIn(detailsEntity.getCheckIn());
details.setCheckOut(detailsEntity.getCheckOut());
details.setNoOfRooms(detailsEntity.getNoOfRooms());
details.setNoOfGuests(detailsEntity.getNoOfGuest());
detailsViewModel.setDetails(details);
}
}
});