diff options
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterViewModel.java')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterViewModel.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterViewModel.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterViewModel.java index c42a61ebd..8a2555eb5 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterViewModel.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterViewModel.java @@ -10,6 +10,7 @@ import androidx.lifecycle.MutableLiveData; import java.util.List; +import it.niedermann.nextcloud.deck.DeckLog; import it.niedermann.nextcloud.deck.model.Label; import it.niedermann.nextcloud.deck.model.User; import it.niedermann.nextcloud.deck.model.enums.EDueType; @@ -40,8 +41,13 @@ public class FilterViewModel extends AndroidViewModel { this.filterInformation.postValue(hasActiveFilter(filterInformationDraft.getValue()) ? filterInformationDraft.getValue() : null); } - public void clearFilterInformation() { - this.filterInformationDraft.setValue(new FilterInformation()); + public void clearFilterInformation(boolean alsoFilterText) { + final FilterInformation newFilterInformation = new FilterInformation(); + if (alsoFilterText) { + final FilterInformation oldFilterInformation = this.filterInformation.getValue(); + newFilterInformation.setFilterText(oldFilterInformation != null ? oldFilterInformation.getFilterText() : ""); + } + this.filterInformationDraft.setValue(newFilterInformation); this.publishFilterInformationDraft(); this.currentFilterTab = 0; } @@ -106,6 +112,13 @@ public class FilterViewModel extends AndroidViewModel { this.currentFilterTab = newFilterTab; } + public void setFilterText(@NonNull String filterText) { + DeckLog.info("New filterText:", filterText); + FilterInformation newDraft = new FilterInformation(filterInformation.getValue()); + newDraft.setFilterText(filterText); + this.filterInformation.postValue(newDraft); + } + @IntRange(from = 0, to = 2) public int getCurrentFilterTab() { return this.currentFilterTab; |