diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-05-05 11:08:44 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-05-05 11:08:44 +0300 |
commit | 83fe12cbb24bdeada4ef1b88a8b4cd5eae8664ac (patch) | |
tree | 64490c216e2caf9cff5424bf3998350b0dafcc0d /app/src/main/java/it/niedermann/nextcloud/deck/ui/stack | |
parent | 960935ebd07e717158c89ab5ccaa9180020665bc (diff) |
Move filter stuff to own ViewModel
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/stack')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java index a221fcbff..def22c3f7 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/StackFragment.java @@ -24,6 +24,7 @@ import it.niedermann.nextcloud.deck.ui.MainViewModel; import it.niedermann.nextcloud.deck.ui.branding.BrandedFragment; import it.niedermann.nextcloud.deck.ui.card.CardAdapter; import it.niedermann.nextcloud.deck.ui.card.SelectCardListener; +import it.niedermann.nextcloud.deck.ui.filter.FilterViewModel; public class StackFragment extends BrandedFragment implements DragAndDropTab<CardAdapter> { @@ -60,11 +61,12 @@ public class StackFragment extends BrandedFragment implements DragAndDropTab<Car binding = FragmentStackBinding.inflate(inflater, container, false); activity = requireActivity(); - final MainViewModel viewModel = new ViewModelProvider(activity).get(MainViewModel.class); + final MainViewModel mainViewModel = new ViewModelProvider(activity).get(MainViewModel.class); + final FilterViewModel filterViewModel = new ViewModelProvider(activity).get(FilterViewModel.class); syncManager = new SyncManager(activity); - adapter = new CardAdapter(requireContext(), viewModel.getCurrentAccount(), viewModel.getCurrentBoardLocalId(), stackId, viewModel.currentBoardHasEditPermission(), syncManager, this, (requireActivity() instanceof SelectCardListener) ? (SelectCardListener) requireActivity() : null); + adapter = new CardAdapter(requireContext(), mainViewModel.getCurrentAccount(), mainViewModel.getCurrentBoardLocalId(), stackId, mainViewModel.currentBoardHasEditPermission(), syncManager, this, (requireActivity() instanceof SelectCardListener) ? (SelectCardListener) requireActivity() : null); binding.recyclerView.setAdapter(adapter); if (onScrollListener != null) { @@ -79,7 +81,7 @@ public class StackFragment extends BrandedFragment implements DragAndDropTab<Car }); } - if (!viewModel.currentBoardHasEditPermission()) { + if (!mainViewModel.currentBoardHasEditPermission()) { binding.emptyContentView.hideDescription(); } @@ -92,12 +94,12 @@ public class StackFragment extends BrandedFragment implements DragAndDropTab<Car } }); - cardsLiveData = syncManager.getFullCardsForStack(viewModel.getCurrentAccount().getId(), stackId, viewModel.getFilterInformation().getValue()); + cardsLiveData = syncManager.getFullCardsForStack(mainViewModel.getCurrentAccount().getId(), stackId, filterViewModel.getFilterInformation().getValue()); cardsLiveData.observe(getViewLifecycleOwner(), cardsObserver); - viewModel.getFilterInformation().observe(getViewLifecycleOwner(), (filterInformation -> { + filterViewModel.getFilterInformation().observe(getViewLifecycleOwner(), (filterInformation -> { cardsLiveData.removeObserver(cardsObserver); - cardsLiveData = syncManager.getFullCardsForStack(viewModel.getCurrentAccount().getId(), stackId, filterInformation); + cardsLiveData = syncManager.getFullCardsForStack(mainViewModel.getCurrentAccount().getId(), stackId, filterInformation); cardsLiveData.observe(getViewLifecycleOwner(), cardsObserver); })); |