Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- categoryViewModel = ViewModelProviders.of(this).get(CategoryViewModel.class);
- CombinedLiveData<Resource<List<Category>>, Resource<List<Category>>> categoryAndRegions = new CombinedLiveData<>(categoryViewModel.getCategories(Constants.NEWS_CATEGORY_SET), categoryViewModel.getCategories(Constants.CATEGORIES_REGIONS));
- categoryAndRegions.observe(getViewLifecycleOwner(), resourceResourcePair -> {
- if (resourceResourcePair != null) {
- if (resourceResourcePair.first.status == Resource.Status.LOADING || resourceResourcePair.second.status == Resource.Status.LOADING) {
- loadingView.setVisibility(View.VISIBLE);
- }
- if (resourceResourcePair.first.status == Resource.Status.SUCCESS || resourceResourcePair.second.status == Resource.Status.SUCCESS) {
- if (mIsRegionsView) {
- sectionsAdapter.submitList(resourceResourcePair.second.data);
- } else {
- resourceResourcePair.first.data.add(0, new Category(
- -1,
- Constants.CATEGORIES_REGIONS,
- getString(R.string.regions),
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- ""));
- sectionsAdapter.submitList(resourceResourcePair.first.data);
- }
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement