Skip to content

Instantly share code, notes, and snippets.

@daeun1012
Created December 1, 2017 03:23
Show Gist options
  • Save daeun1012/a4257c4029d125a924dc8e0d7221ccc8 to your computer and use it in GitHub Desktop.
Save daeun1012/a4257c4029d125a924dc8e0d7221ccc8 to your computer and use it in GitHub Desktop.
private void subscribeUi(ProductListViewModel viewModel) {
// Update the list when the data changes
viewModel.getProducts().observe(this, new Observer<List<ProductEntity>>() {
@Override
public void onChanged(@Nullable List<ProductEntity> myProducts) {
if (myProducts != null) {
mBinding.setIsLoading(false);
mProductAdapter.setProductList(myProducts);
} else {
mBinding.setIsLoading(true);
}
// espresso does not know how to wait for data binding's loop so we execute changes
// sync.
mBinding.executePendingBindings();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment