blob: bf4b5edbfb42b47ae483138204730c4b3f0a4e2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package it.niedermann.nextcloud.deck.ui.filter;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import it.niedermann.nextcloud.deck.databinding.DialogFilterLabelsBinding;
import it.niedermann.nextcloud.deck.model.internal.FilterInformation;
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;
public class FilterLabelsFragment extends Fragment {
private FilterInformation filterInformation;
private DialogFilterLabelsBinding binding;
private MainViewModel mainViewModel;
private LabelFilterAdapter labelAdapter;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = DialogFilterLabelsBinding.inflate(requireActivity().getLayoutInflater());
mainViewModel = new ViewModelProvider(requireActivity()).get(MainViewModel.class);
final SyncManager syncManager = new SyncManager(requireActivity());
this.filterInformation = mainViewModel.getFilterInformation().getValue();
if (this.filterInformation == null) {
this.filterInformation = new FilterInformation();
}
observeOnce(syncManager.findProposalsForLabelsToAssign(mainViewModel.getCurrentAccount().getId(), mainViewModel.getCurrentBoardLocalId()), requireActivity(), (labels) -> {
labelAdapter = new LabelFilterAdapter(labels, this.filterInformation.getLabels());
binding.labels.setNestedScrollingEnabled(false);
binding.labels.setAdapter(labelAdapter);
});
return super.onCreateView(inflater, container, savedInstanceState);
}
}
|