Close search bar when clicking on clear filter button if filter is empty

This commit is contained in:
Sylvain Berfini 2024-04-26 10:02:02 +02:00
parent 00b92a61b4
commit e9f0bed2d2
2 changed files with 6 additions and 2 deletions

View file

@ -201,7 +201,12 @@ open class AbstractMainViewModel @UiThread constructor() : ViewModel() {
@UiThread
fun clearFilter() {
searchFilter.value = ""
if (searchFilter.value.orEmpty().isEmpty()) {
searchBarVisible.value = false
focusSearchBarEvent.value = Event(false)
} else {
searchFilter.value = ""
}
}
@UiThread

View file

@ -117,7 +117,6 @@
<ImageView
android:id="@+id/clear_field"
android:onClick="@{() -> viewModel.clearFilter()}"
android:enabled="@{viewModel.searchFilter.length() > 0}"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:padding="15dp"