Created
December 1, 2017 03:23
-
-
Save daeun1012/a4257c4029d125a924dc8e0d7221ccc8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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