diff options
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterLabelsFragment.java')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterLabelsFragment.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterLabelsFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterLabelsFragment.java index b2e5e5c58..64384d89f 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterLabelsFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterLabelsFragment.java @@ -18,12 +18,14 @@ import it.niedermann.nextcloud.deck.persistence.sync.SyncManager; import it.niedermann.nextcloud.deck.ui.MainViewModel; import static it.niedermann.nextcloud.deck.persistence.sync.adapters.db.util.LiveDataHelper.observeOnce; +import static java.util.Objects.requireNonNull; public class FilterLabelsFragment extends Fragment implements SelectionListener<Label> { private LiveData<FilterInformation> filterInformationDraft; private DialogFilterLabelsBinding binding; private MainViewModel mainViewModel; + private FilterViewModel filterViewModel; private LabelFilterAdapter labelAdapter; @Nullable @@ -31,11 +33,12 @@ public class FilterLabelsFragment extends Fragment implements SelectionListener< public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { binding = DialogFilterLabelsBinding.inflate(requireActivity().getLayoutInflater()); mainViewModel = new ViewModelProvider(requireActivity()).get(MainViewModel.class); + filterViewModel = new ViewModelProvider(requireActivity()).get(FilterViewModel.class); final SyncManager syncManager = new SyncManager(requireActivity()); - this.filterInformationDraft = mainViewModel.getFilterInformationDraft(); + this.filterInformationDraft = filterViewModel.getFilterInformationDraft(); observeOnce(syncManager.findProposalsForLabelsToAssign(mainViewModel.getCurrentAccount().getId(), mainViewModel.getCurrentBoardLocalId()), requireActivity(), (labels) -> { - labelAdapter = new LabelFilterAdapter(labels, this.filterInformationDraft.getValue().getLabels(), this); + labelAdapter = new LabelFilterAdapter(labels, requireNonNull(this.filterInformationDraft.getValue()).getLabels(), this); binding.labels.setNestedScrollingEnabled(false); binding.labels.setAdapter(labelAdapter); }); @@ -44,11 +47,11 @@ public class FilterLabelsFragment extends Fragment implements SelectionListener< @Override public void onItemSelected(Label item) { - mainViewModel.addFilterInformationDraftLabel(item); + filterViewModel.addFilterInformationDraftLabel(item); } @Override public void onItemDeselected(Label item) { - mainViewModel.removeFilterInformationLabel(item); + filterViewModel.removeFilterInformationLabel(item); } } |